lp-modeler
A linear programming modeler written in Rust. This api helps to write LP model and use solver such as CBC, Gurobi, lp_solve, ...
This library is inspired by coin-or PuLP which provide such an API for python 2.x.
Usage
Dev in progress.
This first alpha version provide this DSL to make a LP Model :
use ;
use ;
use LpInteger;
use ;
let ref a = new;
let ref b = new;
let ref c = new;
let mut problem = new;
// Maximize 10*a + 20*b
problem += 10.0 * a + 20.0 * b;
// 500*a + 1200*b + 1500*c <= 10000
problem += .le;
// a <= b
problem += .le;
let solver = new;
match solver.run
This version are tested with Coinor-Cbc and Gurobi.
It is possible to export the model into the lp file format.
problem.write_lp("problem.lp")
will produce :
\ One Problem
Maximize
10 a + 20 b
Subject To
c1: 500 a + 1200 b <= -10000
c2: a - b <= 0
Generals
a c b
End
With this file, you can directly use it with a solver supporting lp file format :
- open source solvers :
- lp_solve
- glpk
- cbc
- commercial solvers :
- Gurobi
- Cplex
Limitation
- Use with CBC for now
Todo
- Config for GLPK, lp_solve and CPLEX
Further work
- it would be great to use some constraint for binary variable like
- a && b which is the constraint a + b = 2
- a || b which is the constraint a + b >= 1
- a <=> b which is the constraint a = b
- a => b which is the constraint a <= b
- All these cases is easy with two constraints but more complex with expressions
- ...