JMPI - Java Mathematical Programming Interface
Links
Introduction
JMPI (speak: jumpy) is a Java interface to mathematical programming solvers for Integer Linear Programming and Quadratic Programming.
JMPI is open source under MIT license.
JMPI requires Java 6 or higher.
Supported 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
import static net.sf.jmpi.main.expression.MpExpr.prod;
import static net.sf.jmpi.main.expression.MpExpr.sum;
...
MpSolver solver = new SolverGurobi();
/**
* Constructing a Problem:
* Maximize: 143x+60y
* Subject to:
* 120x+210y <= 15000
* 110x+30y <= 4000
* x+y <= 75
*
* With x,y being integers
*
*/
MpProblem problem = new MpProblem();
problem.addVar("x", Integer.class);
problem.addVar("y", Integer.class);
MpExpr objective = sum(prod(143, "x"), prod(60, "y"));
problem.setObjective(objective, MpDirection.MAX);
problem.add(sum(prod(100, "x"), prod(20, "x"), prod(210, "y")), "<=", 15000);
problem.add(sum(prod(110, "x"), prod(30, "y")), "<=", 4000);
problem.add(sum("x"), "<=", sum(75, prod(-1, "y")));
solver.add(problem);
MpResult result = solver.solve();
System.out.println(result);
Results in the following output:
Objective: 6266.0 {y=52.0, x=22.0}
Documentation
Read the Java API Reference.
Copyright 2014, Martin Lukasiewycz