12 releases

0.1.11 Oct 18, 2020
0.1.10 May 23, 2020
0.1.9 Nov 22, 2019
0.1.6 Oct 15, 2019
0.1.3 Sep 13, 2019

#47 in #linear

Download history 1/week @ 2022-04-17 13/week @ 2022-04-24 26/week @ 2022-05-01 108/week @ 2022-05-08 205/week @ 2022-05-15 50/week @ 2022-05-22 87/week @ 2022-05-29 87/week @ 2022-06-05 3/week @ 2022-06-12 2/week @ 2022-06-19 12/week @ 2022-06-26 25/week @ 2022-07-03 12/week @ 2022-07-10 24/week @ 2022-07-17 26/week @ 2022-07-24 25/week @ 2022-07-31

87 downloads per month
Used in slp-cli

MIT license

38KB
939 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 not maintained.

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

~5.5MB
~102K SLoC