Solvers

Solve oximo models with a variety of solvers.

oximo is solver-agnostic, and provides a variety of backends to solve your optimization models.

Every backend implements the same Solver trait, so swapping engines is a one-line change. The general pattern is:

let result = Backend.solve(&model, &BackendOptions::default())?;

result is a SolverResult, the same struct regardless of backend.

πŸ”—Choosing a backend

To determine what backend to use, consider what each backend solves (by model kind) and what it costs and offers (license, install, diagnostics). Each backend's Cargo feature flag is named in its own section below.

πŸ”—Model kind support

Each row is what Solver::supports accepts for that backend, against every ModelKind:

BackendLPMILPQPMIQPQCPMIQCPSOCPMISOCPNLPMINLP
Highsβœ“βœ“βœ“β€”β€”β€”β€”β€”β€”β€”
Clarabelβœ“β€”βœ“β€”β€”β€”βœ“β€”β€”β€”
Pounceβœ“β€”βœ“β€”βœ“β€”β€”β€”βœ“β€”
Gurobiβœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“
Mosekβœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“β€”β€”
Baronβœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“
Gamsβœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“βœ“

Gams accepts every kind at the oximo layer, but the actual coverage is the GAMS sub-solver's. Pick one that handles the kind you emit.

πŸ”—Requirements & capabilities

Deployment cost and diagnostic/solve capability per backend.

βœ“ = yes/supported; β€” = no.

BackendLicenseSeparate installC compilerDirect interfaceIISWarm startSol. poolDualsParallel
Highsβ€”β€”βœ“βœ“β€”β€ βœ“β€”βœ“βœ“
Clarabelβ€”β€”β€”βœ“β€”βœ“β€”βœ“βœ“
Pounceβ€”β€”β€”βœ“β€”βœ“β€”βœ“β€”
Gurobiβœ“βœ“β€”βœ“βœ“βœ“βœ“βœ“βœ“
Mosekβœ“βœ“β€”βœ“β€”βœ“β€”βœ“βœ“
Baronβœ“βœ“β€”β€”βœ“β€”βœ“βœ“βœ“
Gamsβœ“βœ“β€”β€”β€”β€”βœ“ΒΆβœ“βœ“

Column meanings:

  • License: the underlying solver is commercial and needs a license at runtime. The oximo wrapper crates are all MIT OR Apache-2.0.
  • Direct interface: talks to the solver in-process. C API/FFI for HiGHS, Gurobi, and MOSEK. Pure Rust for Clarabel and Pounce. BARON and GAMS instead exchange model/result files (.bar, .gms) with an external executable.
  • C compiler: whether a C/C++ compiler is required at build time.
  • IIS: computes an irreducible infeasible set to explain an infeasible model.
  • Warm start: persistent handle for incremental re-solves.
  • Sol. pool: returns multiple solutions, best-first.
  • Duals: shadow prices/reduced costs.
  • Parallel: solver can solve in parallel.

Footnotes:

  • † The highs crate does not support IIS yet.
  • ΒΆ GAMS's pool and duals come from the underlying sub-solver's GDX output (e.g. CPLEX solnpool).

A backend rejects model kinds it can't handle, so check Model::kind() if a solve returns SolverError::UnsupportedKind.

πŸ”—External solver setup

Gurobi, MOSEK, BARON, and GAMS need software installed outside Cargo. Add the corresponding feature only after that software is installed and licensed.

πŸ”—Gurobi

Enable gurobi, set GUROBI_HOME to the Gurobi installation, and make sure a Gurobi license is active. The backend links through the grb crate.

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

πŸ”—MOSEK

Enable mosek, install MOSEK 11.2, and configure a valid license. Set MOSEK_BINDIR_112 to MOSEK's platform bin directory when the installation is not in its default location. The backend links through the mosek crate.

Note for Windows: the current mosek crate build script emits an unquoted linker flag, so setting MOSEK_BINDIR_112 directly to a path containing spaces can fail. Create a junction with a space-free path, then point the environment variable at that junction. See mosek.rust#1.

Note: We currently support only MOSEK 11.2. Support for other versions of MOSEK is planned.

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

πŸ”—BARON and GAMS

Enable baron or gams after placing the respective executable on PATH. Both backends exchange files with an external program rather than linking the solver into your process.

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

Use features = ["gams"] instead for GAMS.

πŸ”—HiGHS

Highs is bundled by default via the highs Cargo feature. No external install required, but a C/C++ compiler is needed at build time.

use oximo::prelude::*;
use oximo::solvers::Highs;
use std::time::Duration;

let result = Highs.solve(&m, &HighsOptions::default()
    .time_limit(Duration::from_secs(60))
    .threads(4)
    .mip_gap(0.01)
    .verbose(true)
    .method(HighsMethod::Ipm))?;

Common HighsOptions:

MethodEffect
.time_limit(d)Stop after d (std::time::Duration)
.threads(n)Cap parallelism
.mip_gap(g)Relative MIP optimality gap (e.g. 0.01 = 1%)
.verbose(b)Stream the solver log
.method(m)LP algorithm via HighsMethod (Simplex, Ipm, …)

πŸ”—Clarabel

Clarabel is a pure-Rust conic interior-point solver. No install, no license. It handles continuous LP, QP (convex quadratic objectives), and SOCP models.

use oximo::prelude::*;
use oximo::solvers::Clarabel;

let result = Clarabel.solve(&m, &ClarabelOptions::default())?;

πŸ”—POUNCE

Pounce is a pure-Rust port of IPOPT, covering continuous LP/QP/QCP/NLP. Enable the pounce feature.

use oximo::prelude::*;
use oximo::pounce::Pounce;

let result = Pounce.solve(&m, &PounceOptions::default())?;

Purely linear/quadratic models solve with exact analytic derivatives. Models containing a nonlinear function fall back to finite differences and an L-BFGS Hessian unless you enable the nightly-only pounce-enzyme feature, which supplies exact gradients plus sparse Jacobians and Hessians.

For any nonlinear model, enabling pounce-enzyme is highly recommended. Exact derivatives are faster and far more accurate than the finite-difference fallback, which improves both convergence and robustness. It requires a nightly toolchain and a fat-LTO build (see Installation > Advanced: exact nonlinear derivatives).

πŸ”—Gurobi

Gurobi requires the gurobi Cargo feature plus a licensed Gurobi installation reachable via GUROBI_HOME.

Note: Only Gurobi v12 and later are supported.

use oximo::prelude::*;
use oximo::solvers::Gurobi;
use std::time::Duration;

let result = Gurobi.solve(&m, &GurobiOptions::default()
    .time_limit(Duration::from_secs(120))
    .mip_focus(1)
    .seed(101))?;

Common GurobiOptions:

MethodEffect
.time_limit(d)Wall-clock limit
.mip_focus(n)Gurobi MIPFocus (1 = feasibility, 2 = optimality, 3 = bound)
.mip_gap(g)Relative MIP optimality gap
.seed(n)Random seed for reproducible runs

πŸ”—MOSEK

Mosek supports LP, MILP, convex QP/MIQP, convex QCP/MIQCP, and SOCP/MISOCP models. It requires the mosek Cargo feature, a licensed MOSEK 11.2 installation, and MOSEK_BINDIR_112 when MOSEK is outside its default location. MOSEK validates the convexity of quadratic data.

use oximo::prelude::*;
use oximo::solvers::Mosek;
use std::time::Duration;

let result = Mosek.solve(&m, &MosekOptions::default()
    .time_limit(Duration::from_secs(120))
    .threads(4)
    .mio_tol_rel_gap(1e-4))?;

MosekOptions provides builders for every MOSEK 11.2 parameter. Universal options such as time_limit, threads, and verbose are applied first. MOSEK-specific parameter builders are then applied in call order.

πŸ”—BARON

Baron is a global solver for nonconvex LP/MILP/QP/MIQP/NLP/MINLP. Requires the baron feature and a licensed BARON install on PATH.

use oximo::prelude::*;
use oximo::solvers::Baron;

let result = Baron::new().solve(&m, &BaronOptions::default())?;

πŸ”—GAMS

Gams requires the gams Cargo feature plus a GAMS install on PATH. Useful when you want to route a model through GAMS-managed solvers (CPLEX, BARON, IPOPT, KNITRO, ...).

use oximo::prelude::*;
use oximo::solvers::Gams;

let result = Gams.solve(&m, &GamsOptions::default())?;

See GamsOptions and the per-solver option structs in oximo::gams (GamsCplexOptions, GamsBaronOptions, GamsIpoptOptions, ...) for tuning the underlying solver.

πŸ”—Next steps

  • Results: inspect solver status, values, duals, and solution pools
  • Printing & Debugging: print a model as algebra and track down what it actually says
  • I/O: write your model to MPS, LP or NL for use with external tools