[−][src]Crate slp
slp
is a Linear Programming Solver.
To see the usage docs, visit here.
An example
fn main() { use slp::lp::*; use slp::Solution; let input = " 3 2 # 3 is number of constraints and 2 is number of variables 2 3 # coefficients of objective function to be maximized: 2x1 + 3x2 2 1 18 # Constraint 1: 2x1 + x2 <= 18 6 5 60 # Constraint 2: 6x1 + 5x2 <= 60 2 5 40 # Constraint 3: 2x1 + 5x2 <= 40 # x1 >= 0 and x2 >= 0 are always assumed "; let mut solver = Solver::new(LP::new_from_buf_reader(&mut input.as_bytes())); let solution = solver.solve(); assert_eq!(solution, Solution::Optimal(28.0, vec![5.0, 6.0])); match solution { Solution::Infeasible => println!("INFEASIBLE"), Solution::Unbounded => println!("UNBOUNDED"), Solution::Optimal(obj, model) => { println!("OPTIMAL {}", obj); print!("SOLUTION"); for v in model { print!(" {}", v); } println!(); } } }
Modules
lp | A General Linear Programming Solver. |
Structs
ParseRatioError | |
Ratio | Represents the ratio between two numbers. |
Enums
Solution | Solution to an LP instance as returned by the solve method of an LP instance. |
SolverSettings | Solver settings that can be passed to the solver instance. |
Traits
One | Defines a multiplicative identity element for |
Zero | Defines an additive identity element for |
Type Definitions
BigRational | Alias for arbitrary precision rationals. |
Rational | Alias for a |
Rational32 | Alias for a |
Rational64 | Alias for a |