Expand description
§oximo-macros
Internal procedural macros backing oximo’s modeling surface:
variable!, constraint!, soc_constraint!, objective!, sum!, set!,
and param!.
This crate is an implementation detail, do not depend on it directly.
The macros are re-exported through oximo-core and oximo::prelude, which is the
supported entry point:
use oximo::prelude::*;The macros expand to the typed builder API in oximo-core (Model, Set,
Expr, sum_over, …). See the oximo crate docs for the macro grammar and examples.
Sums inside constraint!, soc_constraint!, and objective! inherit the model’s
expression context and return 0 for empty domains or filters. For standalone
sums, use sum!(model, body for i in domain) to supply that context explicitly.
Nested sums inherit it, and selected terms are checked for model ownership.
Standalone unanchored sums still require at least one term.
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.