quicopt.ir¶
ir ¶
quicopt.ir — the structured Program IR.
Front-end-agnostic data: a front-end (quicopt.pyomo, quicopt.mathopt) builds a Program;
quicopt.wire serializes it to the versioned wire bytes. The IR/wire is the
service's contract — these types track it, they never fork it. Index tuple entries
are int (a concrete coordinate) or str (a bound index symbol); the IR never
uses a bare string for data, so the mapping is total.
Domain ¶
Bases: IntEnum
The domain a variable ranges over. Values are the wire enum codes.
Expression ¶
Base of the expression grammar.
Param
dataclass
¶
Bases: Expression
A reference to a parameter-table entry — data bound at instance time, by
name and an index tuple (() for a scalar).
Var
dataclass
¶
Apply
dataclass
¶
SetRef
dataclass
¶
A reference to an index set: args=() is the flat set; args=("i",)
references the set indexed by enclosing bound indices.
Reduce
dataclass
¶
Reduce(
op: str,
idx: str,
over: SetRef,
body: Expression,
cond: "Expression | None" = None,
)
Bases: Expression
A fold of body over idx ranging across over — e.g. a Σ or Π —
keeping a term only where cond is non-zero (None ⇒ keep every term).
Indicator
dataclass
¶
Indicator(bin: Var, inner: object)
bin active (= 1) implies the body satisfies the inner ConSet.
VarDecl
dataclass
¶
VarDecl(
name: str,
axes: list,
domain: Domain,
lower: object,
upper: object,
start: float,
)
A variable declaration: name over the product of the index sets in
axes ([] ⇒ scalar), ranging over domain, with lower/upper
bounds and an initial start. A bound is a float, or the str name of a
Param table when it varies by index.
IndexSet
dataclass
¶
A named index set with concrete elements (each int or str).
Constraint
dataclass
¶
Constraint(f: Expression, set: object, over: list = list())
A constraint row: the expression f lies in the ConSet set, for every
binding in over ([(dummy, SetRef)]; empty ⇒ a single scalar row).
Program
dataclass
¶
Program(
sets: list = list(),
indexed_sets: dict = dict(),
params: dict = dict(),
vars: list = list(),
objective: Expression = None,
sense: str = "min",
constraints: list = list(),
fix: dict = dict(),
)
A complete optimization model: index sets and data tables, variable
declarations, the objective and its sense, the constraint rows, and any
per-index variable pins (fix).