lp-solvers

Library implementing interaction with various linear programming solvers.

It uses the [.lp file format] to interact with external solver binaries.

Supported solvers

You need to have the solver you want to use installed on your machine already for this library to work.

Example

```rust

use lpsolvers::lpformat::{Constraint, LpObjective}; use lpsolvers::problem::{Problem, StrExpression, Variable}; use lpsolvers::solvers::{CbcSolver, SolverTrait}; use lp_solvers::solvers::Status::Optimal;

fn solveintegerproblemwithsolver(solver: S) { let pb = Problem { // Alternatively, you can implement the LpProblem trait on your own structure name: "intproblem".tostring(), sense: LpObjective::Maximize, objective: StrExpression("x - y".tostring()), // You can use other expression representations variables: vec![ Variable { name: "x".tostring(), isinteger: true, lowerbound: -10., upperbound: -1., }, Variable { name: "y".tostring(), isinteger: true, lowerbound: 4., upperbound: 7., }, ], constraints: vec![Constraint { lhs: StrExpression("x - y".tostring()), operator: Ordering::Less, rhs: -4.5, }], }; let solution = solver.run(&pb).expect("Failed to run solver"); assert_eq!(solution.status, Optimal); // solution.results is now {"x":-1, "y":4} }

fn main() { solveintegerproblemwithsolver(CbcSolver::default()) } ```