Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ztlpn/minilp
A pure Rust linear programming solver
https://github.com/ztlpn/minilp
linear-programming rust simplex-algorithm
Last synced: 1 day ago
JSON representation
A pure Rust linear programming solver
- Host: GitHub
- URL: https://github.com/ztlpn/minilp
- Owner: ztlpn
- License: apache-2.0
- Archived: true
- Created: 2020-01-24T14:46:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-11T03:17:06.000Z (about 4 years ago)
- Last Synced: 2024-10-16T04:11:47.096Z (about 1 month ago)
- Topics: linear-programming, rust, simplex-algorithm
- Language: Rust
- Homepage:
- Size: 298 KB
- Stars: 80
- Watchers: 4
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - minilp - linear programming solver. (Projects / Provers and Solvers)
README
# minilp
[![Crates.io](https://img.shields.io/crates/v/minilp.svg)](https://crates.io/crates/minilp)
[![Documentation](https://docs.rs/minilp/badge.svg)](https://docs.rs/minilp/)A fast linear programming solver library.
[Linear programming](https://en.wikipedia.org/wiki/Linear_programming) is a technique for
finding the minimum (or maximum) of a linear function of a set of continuous variables
subject to linear equality and inequality constraints.## Features
* Pure Rust implementation.
* Able to solve problems with hundreds of thousands of variables and constraints.
* Incremental: add constraints to an existing solution without solving it from scratch.
* Problems can be defined via an API or parsed from an
[MPS](https://en.wikipedia.org/wiki/MPS_(format)) file.Warning: this is an early-stage project. Although the library is already quite powerful and fast,
it will probably cycle, lose precision or panic on some harder problems. Please report
bugs and contribute code!## Examples
Basic usage
```rust
use minilp::{Problem, OptimizationDirection, ComparisonOp};// Maximize an objective function x + 2 * y of two variables x >= 0 and 0 <= y <= 3
let mut problem = Problem::new(OptimizationDirection::Maximize);
let x = problem.add_var(1.0, (0.0, f64::INFINITY));
let y = problem.add_var(2.0, (0.0, 3.0));// subject to constraints: x + y <= 4 and 2 * x + y >= 2.
problem.add_constraint(&[(x, 1.0), (y, 1.0)], ComparisonOp::Le, 4.0);
problem.add_constraint(&[(x, 2.0), (y, 1.0)], ComparisonOp::Ge, 2.0);// Optimal value is 7, achieved at x = 1 and y = 3.
let solution = problem.solve().unwrap();
assert_eq!(solution.objective(), 7.0);
assert_eq!(solution[x], 1.0);
assert_eq!(solution[y], 3.0);
```For a more involved example, see [examples/tsp](examples#tsp), a solver for the travelling
salesman problem.## License
This project is licensed under the [Apache License, Version 2.0](./LICENSE).