[−][src]Crate slp
slp
is a Linear Programming Solver.
To see the usage docs, visit here.
An example
fn main() { 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 1 0 -1 "; let mut lp = slp::LP::new_from_buf_reader(&mut input.as_bytes()); let solution = lp.solve(); assert_eq!(solution, slp::Solution::Optimal(28.0, vec![5.0, 6.0])); match solution { slp::Solution::Infeasible => println!("INFEASIBLE"), slp::Solution::Unbounded => println!("UNBOUNDED"), slp::Solution::Optimal(obj, model) => { println!("OPTIMAL {}", obj); print!("SOLUTION"); for v in model { print!(" {}", v); } println!(); } } }
Structs
LP | Represents an LP instance |
Enums
Solution | Solution to an LP instance as returned by the solve method of an LP instance. |