### 10 releases

✓ Uses Rust 2018 edition

0.1.9 | Nov 22, 2019 |
---|---|

0.1.8 | Nov 3, 2019 |

0.1.6 | Oct 15, 2019 |

0.1.3 | Sep 13, 2019 |

#**79** in Science

**115** downloads per month

Used in slp-cli

**MIT**license

36KB

862 lines

# slp

SolHOP Linear Programming Solver.

Currently, the simplex method is implemented. Soon ILP and MIP will be supported.

This projetct is still in development. The APIs can change a lot before the first stable release v1.0.0.

## License

###
`lib.rs`

:

is a Linear Programming Solver.`slp`

To see the usage docs, visit here.

## An example

`fn` `main``(``)`` ``{`
`use` `slp``::``*``;`
`use` `slp``::`Rational64`;`
`use` `slp``::`Solution`;`
`let` input `=` `"`
vars x1>=0, x2>=0
max 2x1+3x2
subject to
2x1 + x2 <= 18,
6x1 + 5x2 <= 60,
2x1 + 5x2 <= 40
`"``;`
`let` `mut` solver `=` `Solver``::``<`Rational64`>``::`new`(``&`input`)``;`
`let` solution `=` solver`.``solve``(``)``;`
`assert_eq!``(`solution`,` `Solution``::`Optimal`(``Rational64``::`from_integer`(``28``)``,` `vec!``[`
`Rational64``::`from_integer`(``5``)``,`
`Rational64``::`from_integer`(``6``)`
`]``)``)``;`
`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!``(``)``;`
`}`
`}`
`}`

#### Dependencies

~5MB

~86K SLoC