Crate highs[−][src]
Safe rust binding to the HiGHS linear programming solver.
Usage example
use highs::{Problem, Sense, Model, HighsModelStatus}; // max: x + 2y + z // under constraints: // c1: 3x + y <= 6 // c2: y + 2z <= 7 let mut pb = Problem::default(); let c1 = pb.add_row(..6.); let c2 = pb.add_row(..7.); // x pb.add_column(1., 0.., &[(c1, 3.)]); // y pb.add_column(2., 0.., &[(c1, 1.), (c2, 1.)]); // z pb.add_column(1., 0.., vec![(c2, 2.)]); let mut model = Model::default(); model.set_problem(pb); model.set_sense(Sense::Maximise); let solved = model.solve(); assert_eq!(solved.status(), HighsModelStatus::Optimal); let solution = solved.get_solution(); // The expected solution is x=0 y=6 z=0.5 assert_eq!(solution.columns(), vec![0., 6., 0.5]); // All the constraints are at their maximum assert_eq!(solution.rows(), vec![6., 7.]);
Structs
Model | A model to solve |
Problem | A complete optimization problem |
Row | Represents a constraint |
Solution | Concrete values of the solution |
SolvedModel | A solved model |
Enums
HighsModelStatus | The kinds of results of an optimization |
HighsStatus | The status of a highs operation |
Sense | Whether to maximize or minimize the objective function |