Modules
Optex: an Elixir library for modeling and solving mixed-integer linear programs, with an in-process HiGHS binding via Rustler.
Affine-plus-quadratic expression a^T x + x^T C x + b, sparse over variable
ids. terms holds the linear part; qterms holds quadratic coefficients
keyed by normalized {lo_id, hi_id} pairs (so x*y and y*x sum into one
cell, and x*x lives at {i, i}). Coefficients are literal: the qterm
coefficient of {i, j} is exactly the coefficient of x_i * x_j as
written. Products of degree greater than two raise Optex.NonlinearError.
A second-order cone in its own id space. type :quad relates one head
to its members: head >= sqrt(sum member^2); type :rquad (rotated)
relates two heads: 2 * h1 * h2 >= sum member^2. Heads are guaranteed to
carry a nonnegative lower bound (the model layer enforces it: the bound
is part of the cone's meaning, and it is what makes the SOC-shaped
quadratic encodings on Gurobi/CPLEX legal). Solved natively by capable
backends (Gurobi, CPLEX, COPT); backends without cone support reject the
model at solve time.
One linear row, normalized: pure a^T x on the left, number on the right.
The modeling DSL: model do ... end with variable/constraint/objective.
Compile-time translation of arithmetic-looking AST into Aff-building code.
Human-readable rendering of an Optex.Model using the user-facing names as
written (y[1], w[{1, :a}]). Answers "what did my model block actually
build?"; for a solver-parseable file see Optex.LP.
An indicator constraint: a linear row that must hold when a binary variable
takes a given value (bin = active_value -> a^T x SENSE rhs). Stored
normalized like Optex.Constraint (pure a^T x on the left). Solved natively
by capable backends; never reformulated.
CPLEX-LP-format emitter for an Optex.Model, using sanitized versions of
the user-facing variable and constraint names, so the file stays readable.
Minimal free-format MPS emitter for a Optex.SolverInput.
The neutral model. Immutable; builder calls return a new struct.
A quadratic constraint x^T C x + a^T x SENSE rhs, stored normalized (the
affine constant folded into the rhs) with literal coefficients. Lives in
its own id space, separate from linear rows. Solved natively by capable
backends: Gurobi (including nonconvex and equality), CPLEX (convex,
<=/>= only); HiGHS rejects.
The result of a solve: a decoded status, the objective value, primal variable values, and, for LPs, dual information.
The behaviour a solver backend implements. This is the only contract between the solver-abstraction layer and a backend; a second solver implements this and touches nothing above it.
COPT (Cardinal Optimizer) backend. Implements the same Optex.Solver
contract as the other backends and accepts the same neutral options; use
it with Optex.optimize(m, solver: Optex.Solver.COPT).
CPLEX backend. Implements the same Optex.Solver contract as the HiGHS
and Gurobi backends and accepts the same neutral options; use it with
Optex.optimize(m, solver: Optex.Solver.CPLEX).
Gurobi backend. Implements the same Optex.Solver contract as
Optex.Solver.HiGHS and accepts the same neutral options; use it with
Optex.optimize(m, solver: Optex.Solver.Gurobi).
HiGHS backend. Maps neutral variable types to HiGHS vartype ints, translates neutral solver options to HiGHS option names, and decodes HiGHS status codes; symbolic :infinity bounds pass through to the NIF, which substitutes HiGHS's own infinity value (see DECISIONS.md).
Column-oriented problem ready for a solver. Variables 0..n-1, constraints 0..m-1. Constraint matrix is CSC: column j occupies row_index/values at col_start[j] .. col_start[j+1]-1. Each constraint is a range: row_lb <= a^T x <= row_ub. Bounds use :infinity/:neg_infinity; the binding substitutes the solver's value.
A special ordered set in its own id space: type is :sos1 (at most one
member nonzero) or :sos2 (at most two, adjacent in weight order);
var_ids and weights are parallel lists, weights distinct because they
define the set's order. Solved natively by capable backends (Gurobi,
CPLEX, COPT); backends without SOS support reject the model at solve
time.
The one-time transform from a neutral Model to column-sparse SolverInput.
A decision variable. Created by the model, carries its own id.