Skip to main content

Crate oximo

Crate oximo 

Source
Expand description
oximo logo Website Examples crates version oximo Docs.rs Build Status

§oximo

oximo is a Rust algebraic modeling library for mathematical optimization. It provides a compact modeling API for variables, indexed domains, algebraic constraints, objectives, nonlinear expressions, and multiple solver backends.

use oximo::prelude::*;
use oximo::solvers::Highs;

let demand = [4.0, 6.0, 5.0];

let m = Model::new("production");
variable!(m, production[p in 0..2, t in 0..3] >= 0.0);
constraint!(m, meet[t in 0..3],
    sum!(production[p, t] for p in 0..2) >= demand[t]);
objective!(m, Min, sum!(production[p, t] for p in 0..2, t in 0..3));

let mut solver = Highs;
let result = solver.solve(&m, &HighsOptions::default())?;
println!("objective = {:?}", result.objective());

Expressions use standard Rust operators. Variable domains and bounds are declared directly in the model:

variable!(m, x >= 0.0);       // continuous
variable!(m, y, Bin);         // binary
variable!(m, z >= 0.0, Int);  // integer

constraint!(m, capacity, 2.0 * x + y <= 10.0);
objective!(m, Max, 3.0 * x + 4.0 * y);

Quadratic, nonlinear, and second-order-cone expressions are also available:

objective!(m, Min, (1.0 - x).powi(2) + 100.0 * (y - x.powi(2)).powi(2));
constraint!(m, disk, x.powi(2) + y.powi(2) <= 1.0);
soc_constraint!(m, cone, [x, y] <= t);

§Problem types

oximo supports the following algebraic problem classes. Which classes can be solved depends on the selected backend:

  • Linear programming (LP)
  • Quadratic programming and quadratically constrained programming (QP/QCP)
  • Nonlinear programming (NLP)
  • Mixed-integer linear programming (MILP)
  • Mixed-integer quadratic and quadratically constrained programming (MIQP/MIQCP)
  • Mixed-integer nonlinear programming (MINLP)
  • Second-order cone programming (SOCP/MISOCP)

§Solver features

FeatureBackend / capabilityDefault
highsHiGHS - LP/MILP/QP (bundled, requires a C/C++ compiler)no
ioNL, MPS, and LP readers and writersyes
gurobiGurobi v13+ (requires licensed install)no
mosekMOSEK 11.2 - convex LP/MIP/QP/QCP/SOCPno
gamsGAMS bridge - capability depends on the selected sub-solverno
baronBARON - global non-convex solver (requires licensed install)no
clarabelClarabel - LP/QP/SOCP (pure Rust, no install)no
clarabel-faerClarabel with the faer sparse linear-algebra backendno
pouncePOUNCE - pure-Rust LP/QP/QCP/NLP backendno
pounce-enzymePOUNCE with exact Enzyme derivatives (nightly)no

For example, use HiGHS for a bundled LP/MILP/QP solver:

[dependencies]
oximo = { version = "0.5", features = ["highs"] }

Licensed or external backends may require an installed solver, environment variables, and a valid license. See the backend documentation and the webdocs for setup details.

§Results

SolverResult provides the termination status, objective value, variable values, duals, reduced costs, and (where supported) bounds, gaps, and solution pools.

§License

MIT OR Apache-2.0

Re-exports§

pub use oximo_core as core;
pub use oximo_expr as expr;
pub use oximo_solver as solver;
pub use oximo_io as io;io

Modules§

gamsgams
GAMS backend types: sub-solver selection and per-solver option structs.
pouncepounce
prelude
Glob-import target. Brings the modeling and solver surface into scope.
solvers
Concrete solver backends, gated by cargo features.

Structs§

BaronOptionsbaron
BARON-specific solver options.
ClarabelOptionsclarabel
Clarabel-specific solver options.
GamsOptionsgams
GAMS-specific solver options.
HighsOptionshighs
HiGHS-specific solver options.

Enums§

ClarabelDirectSolveclarabel
Direct linear (KKT) solver method for Clarabel.
GamsSolvergams
Named GAMS sub-solver. Use GamsSolver::Custom for any name that isn’t a pre-enumerated variant.
HighsMethodhighs
HiGHS LP / root-relaxation algorithm.
HighsPresolvehighs
HiGHS presolve options.