Expand description
§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
| Feature | Backend / capability | Default |
|---|---|---|
highs | HiGHS - LP/MILP/QP (bundled, requires a C/C++ compiler) | no |
io | NL, MPS, and LP readers and writers | yes |
gurobi | Gurobi v13+ (requires licensed install) | no |
mosek | MOSEK 11.2 - convex LP/MIP/QP/QCP/SOCP | no |
gams | GAMS bridge - capability depends on the selected sub-solver | no |
baron | BARON - global non-convex solver (requires licensed install) | no |
clarabel | Clarabel - LP/QP/SOCP (pure Rust, no install) | no |
clarabel-faer | Clarabel with the faer sparse linear-algebra backend | no |
pounce | POUNCE - pure-Rust LP/QP/QCP/NLP backend | no |
pounce-enzyme | POUNCE with exact Enzyme derivatives (nightly) | no |
For example, use HiGHS for a bundled LP/MILP/QP solver:
[dependencies]
oximo = { version = "0.7", 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
§API map
The most commonly used modeling and solver types are re-exported at the crate
root and by prelude:
- Build models with
Model,variable!,constraint!, andobjective!. - Create indexed families with
Set,IndexedVar, andIndexedParam. - Compose algebraic expressions with
Expr,sum!,min!, andmax!. - Select a backend from
solversand solve through theSolvertrait. - Inspect termination, primal, and dual information in
SolverResult. - Read or write optimization formats through the
iomodule when that feature is enabled.
Lower-level modeling, expression, and solver APIs remain available through
core, expr, and solver, respectively.
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§
- gams
gams - GAMS backend types: sub-solver selection and per-solver option structs.
- pounce
pounce - POUNCE backend options, algorithm selection, and persistent solver types.
- prelude
- Glob-import target. Brings the modeling and solver surface into scope.
- solvers
- Concrete solver backends, gated by cargo features.
Macros§
- constraint
constraint!(model, [name|name[idx]], lhs <op> rhs), register a constraint, an auto-named anonymous constraint, or an indexed family of constraints.- indicator_
constraint - Register a native binary-triggered affine constraint.
indicator_constraint!(model, [name|name[idx]], binary == 0|1 => relation). - max
max!(body for pat in domain[, pat in domain ...][ if cond]), an indexed maximum.- min
min!(body for pat in domain[, pat in domain ...][ if cond]), an indexed minimum.- objective
objective!(model, Min|Max, expr), set the model objective and sense.objective!(model, Feasibility)(alsofeasibility/feas) declares a feasibility problem with no objective to optimize.- param
param!(model, name = value), declare a re-bindable scalar parameter and bind it to a local of the same name.- set
set!(name = domain), bind a local to an indexSet. A plain right side (0..5,a * b) is normalized to an owned set (a top-level*is a borrowing Cartesian product). Apat in domain[ if cond]comprehension builds (and optionally filters) the set. See the crate docs.- soc_
constraint soc_constraint!(model, [name|name = expr|name[idx]], [terms] <= bound), register the second-order cone constraint||terms||_2 <= bound(every term and the bound must be affine), an auto-named anonymous cone, or an indexed family of cones.- sos_
constraint sos_constraint!(model, [name|name[idx]], SOS1|SOS2, [var, ...]). Explicit weights can be supplied as[(var, weight), ...]. The short form assigns consecutive weights starting at one.- sum
sum!(body for pat in domain[, pat in domain ...]), algebraic summation, lowered to nestedsum_overfolds. To allow an empty domain (or an empty filter), anchor the sum to its model:sum!(model, body for pat in domain). Sums written insideconstraint!,soc_constraint!,objective!, or an anchored sum inherit its expression context automatically. Selected terms must belong to that model. Standalone unanchored sums require a first term.- variable
variable!(model, spec), declare a decision variable (or an indexed family) and bind it to a local of the same name. See the crate docs for the grammar.
Structs§
- Baron
Options baron - BARON-specific solver options.
- Clarabel
Options clarabel - Clarabel-specific solver options.
- Constraint
- A single algebraic constraint, canonicalized as the interval
lower <= lhs <= upperwith numeric bounds. RHS expressions are folded intolhsduring construction, so backends only ever see this canonical shape. - Constraint
Evaluation - Activity and feasibility information for an algebraic constraint.
- Constraint
Expr - In-progress constraint produced by
Relate::le/Relate::ge/Relate::eq. Registered through theconstraint!macro. - Constraint
Handle - A model-bound handle to an algebraic constraint.
- Constraint
Id - Expr
- Lightweight handle to a node in an
ExprArenaCell. - ExprId
- Gams
Options gams - GAMS-specific solver options.
- Highs
Options highs - HiGHS-specific solver options.
- Iis
- An irreducible infeasible subsystem (IIS).
- IisReport
- A printable, model-aware listing of an
Iis. Created byIis::report. - Indexed
Constraint - Owned handle returned by an indexed single-relation
constraint!declaration. - Indexed
Indicator Constraint - Owned handles returned by an indexed single-relation indicator declaration.
- Indexed
Range Constraint - Owned handle returned by an indexed two-sided range
constraint!declaration. - Indexed
Range Indicator Constraint - Owned handles returned by an indexed two-sided indicator declaration.
- Indexed
VarBuilder - Indicator
Constraint - A binary-triggered affine row, stored canonically as
trigger == active_value => lower <= lhs <= upper. - Indicator
Constraint Handle - Model-bound handle returned by a scalar indicator declaration.
- Indicator
Constraint Id - Stable identifier for a native indicator constraint.
- Indicator
Reformulation Artifacts - IDs appended while replacing one source indicator.
- Indicator
Reformulation Options - Settings for explicit indicator-to-MILP reformulation.
- Model
- The optimization model. Owns the expression arena, variable/parameter registries, constraints, and (optional) objective.
- Model
Constraints - Unified borrowed view of every constraint declared on a
Model. - ModelId
- Stable identity shared by a model, its expression handles, and its results.
- Model
Mismatch Error - An expression, indexed family, model, or result came from another model.
- Model
Report - A printable, model-aware summary of a
SolverResult. Created bySolverResult::report. - Objective
- The model’s objective: an expression to optimize and the direction.
- ParamId
- Parameter
- Parameter identity (id + name). Parameters are scalars referenced symbolically in expressions and re-bound between solves.
- Pounce
Options pounce - POUNCE-specific solver options.
- Reformulated
Model - An independent transformed model plus source-to-generated provenance.
- Set
- A finite, ordered index set, parameterized by the type
Kits keys decode to. - SetIter
- SocConstraint
- An explicit second-order cone constraint
||terms||_2 <= bound. - SocConstraint
Handle - A model-bound handle to an explicit second-order-cone constraint.
- SocConstraint
Id - SocEvaluation
- Activity and feasibility information for an explicit second-order cone.
- SocForm
- Normalized second-order cone data:
|| A x + a ||_2 <= b'x + beta, oneLinearTermsper row ofA x + aplus one for the bound side. Produced by shared solver preparation for algebraic and explicit cones. - Solution
Point - A single primal point returned by a solver.
- Solver
Result - A solver’s final result on a model.
- SosConstraint
- An explicit SOS1 or SOS2 constraint.
- SosConstraint
Handle - A model-bound handle to an SOS constraint.
- SosConstraint
Id - SosMember
- SosReformulation
Artifacts - IDs appended while replacing one source SOS constraint.
- SosReformulation
Options - Settings for an SOS-to-MILP reformulation.
- Universal
Options - Options valid for every solver, including NLP backends.
Each backend’s options struct embeds this via
HasUniversal; theUniversalOptionsExtblanket impl then provides typed builder setters. - VarBuilder
- Builder backing the
variable!macro. Configure bounds / domain, then callSelf::buildto register the variable and obtain anExprhandle. - VarId
- Variable
- Variable metadata held by the
Model. Users do not construct this directly, they get anExprback fromVarBuilder::buildand look up solution values viacrate::Model/oximo_solver::SolverResult.
Enums§
- Clarabel
Direct Solve clarabel - Direct linear (KKT) solver method for Clarabel.
- Constraint
Ref - A borrowed constraint from a
Model. - Domain
- The domain of a variable, which determines the type of values it can take.
- Dual
Status - Availability and quality of the dual solution returned by a solver.
- Error
- Errors that can occur during model construction.
These are distinct from backend errors, which are opaque and translated into
SolverError. - Gams
Solver gams - Named GAMS sub-solver. Use
GamsSolver::Customfor any name that isn’t a pre-enumerated variant. - Highs
Method highs - HiGHS LP / root-relaxation algorithm.
- Highs
Presolve highs - HiGHS presolve options.
- Index
Key - A serializable index key from a
Set. - Model
Kind - The kind of mathematical program a
Modelrepresents. - MuStrategy
pounce mu_strategyvalues.- Objective
Sense - Whether the model minimizes or maximizes its objective.
- Pounce
Algorithm pounce - POUNCE algorithms available through its Rust library API.
- Pounce
Option Value pounce - A raw POUNCE option value for
PounceOptions::extra. - Pounce
Solver Selection pounce - POUNCE solver route selected after classifying the oximo model.
- Primal
Status - The status of the primal point held in a
crate::SolverResult. - Range
Constraint Handles - Model-bound handles produced by a two-sided range declaration.
- Range
Constraint Ids - Model row IDs produced by a two-sided range declaration.
- Range
Indicator Constraint Handles - Model-bound handles produced by a two-sided indicator declaration.
- Range
Indicator Constraint Ids - IDs produced by a two-sided indicator declaration.
- Reformulation
Error - Why an explicit model reformulation could not be constructed.
- Sense
- The sense of a constraint: less-than-or-equal, greater-than-or-equal, or equality.
- Solver
Error - SosType
- The two standard special ordered set types.
- Termination
Status - Why a solver stopped, independent of whether a usable point was returned.
- UnaryOp
- Unary scalar functions represented by
ExprNode::Unary. - VarBound
Kind - Which side of a variable’s bound participates in an infeasibility.
Traits§
- From
Index Key - Typed projection of an
IndexKey. Implementations panic when the key’s shape does not match the target type, the same contract ascrate::indexed::IndexedVarindexing on a missing key. - HasUniversal
- Implemented by every backend-specific options struct.
Gives the
UniversalOptionsExtblanket impl access to the embeddedUniversalOptions. - Infeasibility
Diagnosis - A
Solverthat can diagnose why a model is infeasible by computing an irreducible infeasible subsystem (Iis). - IntoRhs
- What can appear on the right-hand side of a constraint. Numeric scalars
stay as the canonical
rhs. Expressions get subtracted into the LHS. - Persistent
Solver - A
Solverthat can hand out a stateful handle keeping the built backend model resident across solves. - Relate
- Build a constraint from an expression. Lives on
Expritself. - Solver
- Concrete solver backend.
- SumDomain
- Domain over which the
sum!macro iterates. Lets a single sum accept either aSet(with typed key decoding viaFromIndexKey) or a borrowed slice ofCopykeys, without intermediate conversions. - Universal
Options Ext - Builder setters available on every backend options struct.
Functions§
- display_
index_ key - Public render of an
IndexKey’s textual form, used when deriving auto-generated names for indexed-family constraints. - dot
- Dot product of expressions with scalar coefficients:
sum_{i} c_i * e_i.
Type Aliases§
- Children
- Index
Tuple - Heap-allocated tuple key payload. Immutable after construction.
- Indexed
Param - Indexed family of re-bindable parameters; see
IndexedFamily. - Indexed
Var - Indexed family of decision variables; see
IndexedFamily.