Expand description
A fast linear programming solver library.
Linear programming is a technique for finding the minimum (or maximum) of a linear function of a set of continuous variables subject to linear equality and inequality constraints.
§Features
- Pure Rust implementation.
- Able to solve problems with hundreds of thousands of variables and constraints.
- Incremental: add constraints to an existing solution without solving it from scratch.
- Interruptible: time/node limits with clean resume, warm starts from known solutions, and MIP gap reporting for integer problems.
§Entry points
Begin by creating a Problem instance, declaring variables and adding
constraints. Solving it will produce a Solution that can be used to
get the optimal objective value, corresponding variable values and to add more constraints
to the problem.
§Example
use microlp::{Problem, OptimizationDirection, ComparisonOp};
// Maximize an objective function x + 2 * y of two variables x >= 0 and 0 <= y <= 3
let mut problem = Problem::new(OptimizationDirection::Maximize);
let x = problem.add_var(1.0, (0.0, f64::INFINITY));
let y = problem.add_var(2.0, (0.0, 3.0));
// subject to constraints: x + y <= 4 and 2 * x + y >= 2.
problem.add_constraint(&[(x, 1.0), (y, 1.0)], ComparisonOp::Le, 4.0);
problem.add_constraint(&[(x, 2.0), (y, 1.0)], ComparisonOp::Ge, 2.0);
// Optimal value is 7, achieved at x = 1 and y = 3.
let solution = problem.solve().unwrap();
assert_eq!(solution.objective(), 7.0);
assert_eq!(solution[x], 1.0);
assert_eq!(solution[y], 3.0);Structs§
- Linear
Expr - A sum of variables multiplied by constant coefficients used as a left-hand side when defining constraints.
- Problem
- A specification of a linear programming problem.
- Solution
- A solution of a problem.
- Solution
Iter - An iterator over the variable-value pairs of a
Solution. - Solve
Options - Options controlling a solve. Construct with
SolveOptions::defaultand mutate the fields you need. - Stats
- Statistics of a solve, available via
crate::Solution::stats. - Tolerances
- Expert-level numeric tolerances for a solve (see
SolveOptions::tolerances). - Variable
- A reference to a variable in a linear programming problem.
Enums§
- Comparison
Op - An operator specifying the relation between left-hand and right-hand sides of the constraint.
- Error
- An error encountered while solving a problem.
- Optimization
Direction - An enum indicating whether to minimize or maximize objective function.
- Status
- The outcome class of a finished or interrupted solve.
- VarDomain
- The domain of a variable.