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.
Dev in progress.
This first alpha version provide this DSL to make a LP Model : ```rust use lpmodeler::problem::{LpObjective, Problem, LpProblem}; use lpmodeler::operations::{LpOperations}; use lpmodeler::variables::LpInteger; use lpmodeler::solvers::{SolverTrait, CbcSolver};
let ref a = LpInteger::new("a"); let ref b = LpInteger::new("b"); let ref c = LpInteger::new("c");
let mut problem = LpProblem::new("One Problem", LpObjective::Maximize);
// Maximize 10a + 20b problem += 10.0 * a + 20.0 * b;
// 500a + 1200b + 1500c <= 10000 problem += (500a + 1200b + 1500c).le(10000); // a <= b problem += (a).le(b);
let solver = CbcSolver::new();
match solver.run(&problem) { Ok((status, res)) => { println!("Status {:?}", status); for (name, value) in res.iter() { println!("value of {} = {}", name, value); } }, Err(msg) => println!("{}", msg), } ```
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