10 releases

✓ Uses Rust 2018 edition

0.1.9 Nov 22, 2019
0.1.8 Nov 3, 2019
0.1.6 Oct 15, 2019
0.1.3 Sep 13, 2019

#92 in Science

Download history 36/week @ 2019-09-06 38/week @ 2019-09-13 81/week @ 2019-09-20 24/week @ 2019-09-27 24/week @ 2019-10-04 17/week @ 2019-10-11 36/week @ 2019-10-18 18/week @ 2019-10-25 56/week @ 2019-11-01 10/week @ 2019-11-08 29/week @ 2019-11-15

123 downloads per month
Used in 1 crate

MIT license

36KB
862 lines

slp

SolHOP Linear Programming Solver.

Crates.io Crates.io Crates.io Docs

Currently, the simplex method is implemented. Soon ILP and MIP will be supported.

This projetct is still in development. The APIs can change a lot before the first stable release v1.0.0.

License

MIT


lib.rs:

slp is a Linear Programming Solver.

To see the usage docs, visit here.

An example

fn main() {
    use slp::*;
    use slp::Rational64;
    use slp::Solution;
    let input = "
        vars x1>=0, x2>=0
        max 2x1+3x2
        subject to
            2x1 +  x2 <= 18,
            6x1 + 5x2 <= 60,
            2x1 + 5x2 <= 40
        ";
    let mut solver = Solver::<Rational64>::new(&input);
    let solution = solver.solve();
    assert_eq!(solution, Solution::Optimal(Rational64::from_integer(28), vec![
        Rational64::from_integer(5),
        Rational64::from_integer(6)
    ]));
    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!();
        }
    }
}

Dependencies

~5MB
~86K SLoC