oximo-highs
HiGHS LP/MILP backend for oximo.
Wraps the highs crate (HiGHS bundled, no separate install required). Supports LP, MILP, and convex continuous QP model kinds.
Usage
Most users should depend on the umbrella oximo crate with the highs feature (enabled by default):
[]
= "0.5.1"
To use this crate directly:
[]
= "0.5.1"
= "0.5.1"
= "0.5.1"
Quick example
use *;
use ;
use ;
let m = new;
variable!;
variable!;
constraint!;
constraint!;
objective!;
let result = Highs.solve.unwrap;
assert_eq!;
println!; // 34.0
println!; // 6.0
println!; // 4.0
Persistent handle (repeated solves)
Highs.solve builds a fresh HiGHS instance every call. When you re-solve one model
many times (parameter sweeps, sensitivity studies, column generation, rolling
horizons, etc) build a resident handle with Highs.persistent() and call solve on it
instead. HighsPersistent is a plain Solver, it keeps the HiGHS instance resident
and, when only objective coefficients or variable bounds changed since the last call,
pushes those deltas and warm-starts from the previous basis. Any structural change
(new rows/columns, changed matrix coefficients or row bounds, flipped integrality or
sense, or a quadratic objective) triggers a transparent rebuild, so results always
match a cold solve.
Quadratic programs (QP)
A quadratic objective (e.g. x.powi(2), x * y) with linear constraints is
detected as QP and solved by uploading the Hessian Q via
Highs_passHessian. oximo derives Q from the objective with
oximo_expr::extract_quadratic; HiGHS then minimizes c'x + 0.5·x'Qx.
use *;
use ;
use ;
let m = new;
variable!;
variable!;
constraint!;
objective!; // min x^2 + y^2
let result = Highs.solve.unwrap;
assert_eq!; // x = y = 0.5, obj = 0.5
Convexity. HiGHS supports only convex QPs. For minimization,
Qmust be positive semidefinite (PSD), and for maximization,Qmust be negative semidefinite (NSD). HiGHS does not check this condition, so supplying an indefinite or incorrectly signed Hessian may lead to incorrect or non-optimal solutions.
HiGHS does not support MIQP (integer + quadratic, returned as
UnsupportedKind) or quadratic constraints (returned as Nonlinear).
Options
HighsOptions is a typed builder. All methods return Self for chaining.
| Method | Type | HiGHS option | Default |
|---|---|---|---|
.time_limit(Duration) |
universal | time_limit |
none |
.threads(usize) |
universal | threads |
none |
.verbose(bool) |
universal | output_flag, log_to_console |
none |
.mip_gap(f64) |
HiGHS-only | mip_rel_gap |
none |
.presolve(HighsPresolve) |
HiGHS-only | presolve |
none |
.method(HighsMethod) |
HiGHS-only | solver |
none |
.parallel(bool) |
HiGHS-only | parallel |
none |
HighsMethod variants: Choose (let HiGHS decide), Simplex, Ipm (interior-point), PdLp (first-order).
HighsPresolve variants: Off, On, Auto ("choose").
use Duration;
use ;
use UniversalOptionsExt;
let opts = default
.time_limit
.threads
.mip_gap
.presolve
.method
.parallel;
Result
SolverResult fields, populated whenever a usable point is available (primal_status is FeasiblePoint or OptimalPoint):
solutions- primal points (Vec<SolutionPoint>). This backend returns a single point holding theprimalvalues keyed byVarIdand theobjective(adjusted for any constant term). Access viaresult.objective()/result.value_of(var)dual- constraint duals, keyed byConstraintId, access viaresult.dual_of(c).reduced_costs- variable reduced costs, keyed byVarIdtermination- why the solve stopped (Optimal,Infeasible,Unbounded,InfeasibleOrUnbounded,TimeLimit,IterationLimit, ...), mapped from the HiGHS model statusprimal_status- whether a usable point came back (NoSolution/FeasiblePoint/OptimalPoint), taken from HiGHS's own primal-solution flag,result.has_solution()is the shortcutbest_bound- the MIP dual bound (mip_dual_bound),Nonefor LP/QPgap- relative MIP gap (mip_gap),Nonefor LP/QPsolve_time- wall time measured around the HiGHS solve calliterations- total solver iterations, summed across HiGHS's per-algorithm counters (simplex/qp/ipm/pdlp/crossover). HiGHS populates only the counter for the method it ran, so the sum is whichever applies;0when the model is solved entirely in presolve
License
MIT OR Apache-2.0