#linear-programming #optimization #math #solver

highs

Safe rust bindings for the HiGHS linear programming solver. See http://highs.dev.

16 releases (6 breaking)

0.6.0 Dec 2, 2021
0.5.0 Oct 5, 2021
0.4.0 Mar 19, 2021

#4 in #linear-programming

Download history 17/week @ 2021-10-06 20/week @ 2021-10-13 15/week @ 2021-10-20 29/week @ 2021-10-27 33/week @ 2021-11-03 8/week @ 2021-11-10 31/week @ 2021-11-17 17/week @ 2021-11-24 72/week @ 2021-12-01 46/week @ 2021-12-08 48/week @ 2021-12-15 1/week @ 2021-12-22 8/week @ 2021-12-29 11/week @ 2022-01-05 30/week @ 2022-01-12 15/week @ 2022-01-19

64 downloads per month
Used in good_lp

MIT license

35KB
608 lines

highs

highs docs badge

Safe rust bindings to the Highs MILP Solver. Best used from the good_lp linear programming modeler.

Usage examples

Building a problem variable by variable

use highs::{ColProblem, Sense};

fn main() {
    let mut pb = ColProblem::new();
    // We cannot use more then 5 units of sugar in total.
    let sugar = pb.add_row(..=5);
    // We cannot use more then 3 units of milk in total.
    let milk = pb.add_row(..=3);
    // We have a first cake that we can sell for 2€. Baking it requires 1 unit of milk and 2 of sugar.
    pb.add_integer_column(2., 0.., &[(sugar, 2.), (milk, 1.)]);
    // We have a second cake that we can sell for 8€. Baking it requires 2 units of milk and 3 of sugar.
    pb.add_integer_column(8., 0.., &[(sugar, 3.), (milk, 2.)]);
    // Find the maximal possible profit
    let solution = pb.optimise(Sense::Maximise).solve().get_solution();
    // The solution is to bake one cake of each sort
    assert_eq!(solution.columns(), vec![1., 1.]);
}

Building a problem constraint by constraint

use highs::*;

fn main() {
    let mut pb = RowProblem::new();
    // Optimize 3x - 2y with x<=6 and y>=5
    let x = pb.add_column(3., ..6);
    let y = pb.add_column(-2., 5..);
    pb.add_row(2.., &[(x, 3.), (y, 8.)]); // 2 <= x*3 + y*8
}

Dependencies

~4–5.5MB
~116K SLoC