Java ILP - Java Interface to ILP Solvers



Java ILP is a java interface to integer linear programming (ILP) solvers. There exist several ILP solvers, free or commercial, that offer a java interface. However, these java interfaces are mostly adapted from the c/c++ code leading to a complicated configuration with arrays, integer variables, etc. In contrast, Java ILP aims to provide a simple object-oriented interface as a front-end increasing the ease of development.

Java ILP is licensed under LGPL (

Java ILP requires Java 5 or higher.

Supported ILP Solvers

You will need the solver specific JNI jar file and the system dependent libraries which are dll files on windows and so files on linux. The jar files have to be on the classpath and the libraries in the library path.

Code example

SolverFactory factory = new SolverFactoryLpSolve(); // use lp_solve
factory.setParameter(Solver.VERBOSE, 0);
factory.setParameter(Solver.TIMEOUT, 100); // set timeout to 100 seconds

* Constructing a Problem:
* Maximize: 143x+60y
* Subject to:
* 120x+210y <= 15000
* 110x+30y <= 4000
* x+y <= 75
* With x,y being integers
Problem problem = new Problem();

Linear linear = new Linear();
linear.add(143, "x");
linear.add(60, "y");

problem.setObjective(linear, OptType.MAX);

linear = new Linear();
linear.add(120, "x");
linear.add(210, "y");

problem.add(linear, "<=", 15000);

linear = new Linear();
linear.add(110, "x");
linear.add(30, "y");

problem.add(linear, "<=", 4000);

linear = new Linear();
linear.add(1, "x");
linear.add(1, "y");

problem.add(linear, "<=", 75);

problem.setVarType("x", Integer.class);
problem.setVarType("y", Integer.class);

Solver solver = factory.get(); // you should use this solver only once for one problem
Result result = solver.solve(problem);


* Extend the problem with x <= 16 and solve it again
problem.setVarUpperBound("x", 16);

solver = factory.get();
result = solver.solve(problem);


Results in the following output:

Objective: 6266.0 {y=52, x=22}
Objective: 5828.0 {y=59, x=16}


Read the Java API Reference.

Copyright 2008, Martin Lukasiewycz