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 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, Gurobi or GLPK for now
- 'complex' algebra operations such as commutative and distributivity are under development
New features
0.3.1
- Add distributive property (ex:
3 * (a + b + 2) = 3*a + 3*b + 6) - Add trivial rules (ex:
3 * a * 0 = 0or3 + 0 = 3) - Add commutative property to simplify some computations
- Support for GLPK
0.3.0
- Functional lib with simple algebra properties
Contributors
- Joel Cavat (jcavat)
- Thomas Vincent (tvincent2)
Todo
- Config for 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
- ...