simplex

Crates.iosimplex
lib.rssimplex
version1.0.0
sourcesrc
created_at2019-08-23 10:12:54.86675
updated_at2020-09-12 18:25:23.04255
descriptionA Linear Programming solver
homepage
repository
max_upload_size
id159170
size21,458
Adrián Arroyo Calle (aarroyoc)

documentation

README

simplex

A Linear Programming solver.

Use it to solve your linear programming problems directly from Rust. For example, for this problem:

minimize -3x +  y - 2z
    with  2x - 2y + 3z <= 5
           x +  y -  z <= 3
           x -  y +  z <= 2

You can do:

use simplex::*;

fn main(){
    let program = Simplex::minimize(&vec![-3.0, 1.0, -2.0])
    .with(vec![
        SimplexConstraint::LessThan(vec![2.0, -2.0, 3.0], 5.0),
        SimplexConstraint::LessThan(vec![1.0, 1.0, -1.0], 3.0),
        SimplexConstraint::LessThan(vec![1.0, -1.0, 1.0], 2.0),
    ]);
    let mut simplex = program.unwrap();
    match simplex.solve() {
        SimplexOutput::UniqueOptimum(x) => println!("{}", x),
        SimplexOutput::MultipleOptimum(x) => println!("{}", x),
        _ => panic!("No solution or unbounded"),
    }
    println!("{:?}", simplex.get_var(1));
    println!("{:?}", simplex.get_var(2));
    println!("{:?}", simplex.get_var(3));
}
Commit count: 0

cargo fmt