#linear-programming #optimization #solver #math

highs

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

23 releases (6 stable)

1.6.1 Nov 26, 2023
1.5.0 Jan 18, 2023
1.2.2 Aug 21, 2022
1.2.1 Mar 23, 2022
0.4.0 Mar 19, 2021

#184 in Algorithms

Download history 228/week @ 2024-08-03 198/week @ 2024-08-10 164/week @ 2024-08-17 176/week @ 2024-08-24 366/week @ 2024-08-31 356/week @ 2024-09-07 408/week @ 2024-09-14 315/week @ 2024-09-21 258/week @ 2024-09-28 404/week @ 2024-10-05 301/week @ 2024-10-12 267/week @ 2024-10-19 395/week @ 2024-10-26 282/week @ 2024-11-02 406/week @ 2024-11-09 261/week @ 2024-11-16

1,383 downloads per month
Used in 3 crates (2 directly)

MIT license

41KB
740 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

~5.5–7MB
~148K SLoC