- Version: v2.3.3
- Last update: 26/05/2019
Imagine that, a easy way to solve optimally non-linear problems like below, all this using standard linear programming solvers.
The MINLP proposes make linear transformations to solve this for you, and creates abstractions to do in a easy and transparent way. MINLP is a high level abstraction to encode Mixed Integer Nonlinear Programming (MINLP) models in Java. Some ways to use MINLP.
-
Frist time:
- Create a new Java project using some IDE (I suggest to use NetBeans 8.2)
- Download and import MINLP.jar in your project.
- Download and install one of the solvers supported, then import the java (.jar) lib in your project (I suggest Glpk, here a easy link for windows or linux users).
- Make your on models, see the samples on MINLP
-
Updates to new versions:
- If you already has MINLP you can easy donwload the last version here MINLP.jar and replace it on your project.
-
To contribute and develop new features for MINLP project:
- Download or clone this repository
- Open this project using NetBeans 8.2 IDE
- Download and install one of the solvers supported, then import the java (.jar) lib in your project.
- Make all modifications you need, code new samples, be happy.
MINLP is a library thats encode the models using the folowing suported solvers Cplex, Glpk and Gurobi, then you need to install the ones you intend to use, see how to install this dependencies on links below:
define: let x ∈ R let y ∈ {0,1} v = x*y <-- this is non-linear logical expected result: v = x if y=1 or v = 0 if y=0 linear transformation: let v ∈ R M*(y-1) + x ≤ v ≤ x - M*(y-1) -M*y ≤ v ≤ M*y where M is a abritrary big positive number
- ∑i∈I ( xi )
mip.sum(I, (i) -> x[i])
- ∑i∈I ∑j∈J ( Cij xij )
mip.sum(I, J, (i,j) -> mip.prod(C[i][j], x[i][j]) )
- xi ≤ bi ∀(i∈I)
mip.forAll(I, (i)->{
mip.addLe(x[i], b[i]);
});
- ∑i∈I ( Aji xi ) ≥ Bj ∀(j∈J)
mip.forAll(J, (j)->{
mip.addGe(mip.sum(I, (i) -> mip.prod(A[j][i], x[i])), B[j]);
});
MINLP mip = new CPLEX(); //to diferent solvers use: CPLEX or Gurobi or GLPK;
//set of ingredients I = {0, 1, 2} <-> {bone meal, soy flour, fish's flour}
Set I = mip.range(3);
//set of nutrients J = {0, 1} <-> {protein, calcium}
Set J = mip.range(2);
//Ci : cost per kg of ingredient i
double C[] = {0.56, 0.81, 0.46};
//Aji: amount of nutrient j per kg of ingredient i
double A[][] = {
{0.2, 0.5, 0.4},
{0.6, 0.4, 0.4},
};
//Bj: minimum amount of nutrient j already
double B[] = {0.3, 0.5};
//xi >= 0
Var x[] = mip.numVarArray(I, "x");
//obj = sum_i{Ci * xi}
Expr obj = mip.sum(I, i -> mip.prod(C[i],x[i]));
mip.addMinimize(obj);
//for all j in J
mip.forAll(J, (j)->{
//sum_i{Aji * xi} >= Bj
mip.addGe(mip.sum(I, i -> mip.prod(A[j][i], x[i])), B[j]);
});
//sum_i{xi} = 1
mip.addEq(mip.sum(I, i-> x[i]), 1);
mip.exportModel("model.lp");
if(mip.solve()){
System.out.println(mip.getStatus());
System.out.println(mip.getObjValue());
mip.forAll(I, (i)->{
System.out.printf("x[%d] = %f\n", i, mip.getValue(x[i]));
});
}else{
System.out.println(mip.getStatus());
}
For more samples see Java classes below:
- Basic basic and started samples for LP, IP and MILP problemas commons on literature
- Medium a little more complex samples
- Non-Linear non-linear samples using MINLP, this is unique and show how MINLP can use linear transformations to solve some types of non linear constraints and functions.
- Specific some specific problems, stochastic programming, nonlinear global optimization functions, and so on.