Rust algebraic modeling for mathematical optimization
Define optimization models declaratively in Rust. Solver-agnostic and type-safe.
cargo add oximo
Math to Code
\[
\begin{aligned}
\max \quad & 3x + 4y \\
\text{s.t.} \quad & x + 2y \le 14 \\
& 3x \ge y \\
& x \le y + 2 \\
& x \ge 0 \\
& 0 \le y \le 4
\end{aligned}
\]
solution
\(\text{obj} = 34,\ x = 6,\ y = 4\)
use oximo::prelude::*;
use oximo::solvers::Highs;
let m = Model::new("transport");
variable!(m, x >= 0.0);
variable!(m, 0.0 <= y <= 4.0);
constraint!(m, c1, x + 2.0 * y <= 14.0);
constraint!(m, c2, 3.0 * x >= y);
constraint!(m, c3, x <= y + 2.0);
objective!(m, Max, 3.0 * x + 4.0 * y);
let result = Highs.solve(&m, &HighsOptions::default())?;
println!("obj = {:?}", result.objective()); // 34.0
println!("x = {:?}", result.value_of(x)); // 6.0
println!("y = {:?}", result.value_of(y)); // 4.0
Guides
- Installation Add oximo to a Rust project and configure an optional solver backend.
- Quickstart Build and solve your first LP with oximo in under a minute.
- Modeling Variables, index sets, expressions, and constraints in oximo.
- Solvers Solve oximo models with a variety of solvers.
- Results Inspect solver status, solutions, duals, and solution pools.
- Printing & Debugging Print an oximo model as readable algebra and track down what it actually says.
- I/O Export oximo models to MPS, LP or NL files.
- Contributing Report bugs, improve the docs, and send code to oximo.