### 12 releases

0.1.11 | Oct 18, 2020 |
---|---|

0.1.10 | May 23, 2020 |

0.1.9 | Nov 22, 2019 |

0.1.6 | Oct 15, 2019 |

0.1.3 | Sep 13, 2019 |

#**43** in #programming

Used in slp-cli

**MIT**license

38KB

939 lines

# slp

SolHOP Linear Programming Solver.

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

This projetct is not maintained.

## 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

~5.5MB

~106K SLoC