[][src]Crate slp

slp is a Linear Programming Solver.

To see the usage docs, visit here.

An example

fn main() {
    use slp::lp::*;
    use slp::Solution;
    let input = "
        3 2 # 3 is number of constraints and 2 is number of variables
        2 3 # coefficients of objective function to be maximized: 2x1 + 3x2
        2 1 18 # Constraint 1: 2x1 +  x2 <= 18
        6 5 60 # Constraint 2: 6x1 + 5x2 <= 60
        2 5 40 # Constraint 3: 2x1 + 5x2 <= 40
        # x1 >= 0 and x2 >= 0 are always assumed
        ";
    let mut solver = Solver::new(LP::new_from_buf_reader(&mut input.as_bytes()));
    let solution = solver.solve();
    assert_eq!(solution, Solution::Optimal(28.0, vec![5.0, 6.0]));
    match solution {
        Solution::Infeasible => println!("INFEASIBLE"),
        Solution::Unbounded => println!("UNBOUNDED"),
        Solution::Optimal(obj, model) => {
            println!("OPTIMAL {}", obj);
            print!("SOLUTION");
            for v in model {
                print!(" {}", v);
            }
            println!();
        }
    }
}

Re-exports

pub use num;

Modules

lp

A General Linear Programming Solver.

parser

Parser module for Linear Programming Problems.

Structs

Ratio

Represents the ratio between two numbers.

Enums

Solution

Solution to an LP instance as returned by the solve method of an LP instance.

SolverSettings

Solver settings that can be passed to the solver instance.

Traits

Number

Number trait used in this library.

Type Definitions

BigRational

Alias for arbitrary precision rationals.

Rational

Alias for a Ratio of machine-sized integers.

Rational32

Alias for a Ratio of 32-bit-sized integers.

Rational64

Alias for a Ratio of 64-bit-sized integers.