Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rust-or/highs
Safe rust bindings to the Highs MILP Solver.
https://github.com/rust-or/highs
Last synced: 1 day ago
JSON representation
Safe rust bindings to the Highs MILP Solver.
- Host: GitHub
- URL: https://github.com/rust-or/highs
- Owner: rust-or
- License: mit
- Created: 2021-02-26T16:23:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T04:16:01.000Z (8 months ago)
- Last Synced: 2024-05-22T21:32:07.461Z (6 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/highs
- Size: 56.6 KB
- Stars: 18
- Watchers: 6
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - highs - safe rust bindings for the [HiGHS](https://highs.dev) linear programming solver. (Projects / Libraries)
README
# highs
[![highs docs badge](https://docs.rs/highs/badge.svg)](https://docs.rs/highs)
Safe rust bindings to the Highs MILP Solver. Best used from the [**good_lp**](https://crates.io/crates/good_lp) linear
programming modeler.## Usage examples
#### Building a problem variable by variable
```rust
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
```rust
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
}
```