ellp
Linear programming library that provides primal and dual simplex solvers. Both solvers are currently working for a small set of test problems. This library is an early work-in-progress.
Examples
Here is example code that sets up a linear program, and then solves it with both the primal and dual simplex solvers.
use *;
let mut prob = new;
let x1 = prob
.add_var
.unwrap;
let x2 = prob
.add_var
.unwrap;
let x3 = prob
.add_var
.unwrap;
let x4 = prob
.add_var
.unwrap;
let x5 = prob
.add_var
.unwrap;
prob.add_constraint
.unwrap;
prob.add_constraint
.unwrap;
prob.add_constraint
.unwrap;
println!;
let primal_solver = default;
let dual_solver = default;
let primal_result = primal_solver.solve.unwrap;
let dual_result = dual_solver.solve.unwrap;
if let Optimal = primal_result else
if let Optimal = dual_result else
The output is
minimize
+ 2 x1 + 10 x2 + 1 x4
subject to
+ 2.5 x1 + 3.5 x2 ≥ 5
+ 2.5 x2 + 4.5 x1 ≤ 1
- 1 x3 - 3 x4 - 4 x5 = 2
with the bounds
-1 ≤ x1 ≤ 1
x2 ≤ 6
x3 ≥ 0
x4 = 0
x5 free
primal obj: 19.157894736842103
primal opt point:
┌ ┐
│ -0.9473684210526313 │
│ 2.1052631578947367 │
│ 0 │
│ 0 │
│ -0.5 │
└ ┘
dual obj: 19.157894736842103
dual opt point:
┌ ┐
│ -0.9473684210526313 │
│ 2.1052631578947367 │
│ 0 │
│ 0 │
│ -0.5 │
└ ┘
If the problem is infeasible or unbounded, then solve will return SolverResult::Infeasible or SolverResult::Unbounded, respectively.
Development priorities
- clean up the code, add proper logging
- performance improvements (LU factorization update, steepest edge)
- add benchmarks and test problems, and document how to run them (and how to run all tests)
- switch to sparse matrices (perhaps make it optional)
- make a binary that solves problems given by mps files
Various notes
- problems in MPS format taken from https://netlib.org/lp/
- can run them with
cargo test --features benchmarks