Parameter#
- class Parameter#
Parameter in an optimization problem.
Parameters are values that are fixed during optimization but may vary between different runs or scenarios. They share the same ID space with decision variables.
Note that this object overloads
==for creating a constraint, not for equality comparison.Examples#
>>> p = Parameter(1, name="penalty") >>> x = DecisionVariable.integer(2) >>> x + p # Returns Linear expression Linear(...)
- __add__(rhs: int | float | DecisionVariable | Parameter | Linear) Linear#
- __add__(rhs: Quadratic) Quadratic
- __add__(rhs: Polynomial) Polynomial
- __copy__() Parameter#
- __eq__(other: ToFunction) Constraint#
Create an equality constraint: self == other → Constraint with EqualToZero
- __ge__(other: ToFunction) Constraint#
Create a greater-than-or-equal constraint: self >= other → Constraint
- __le__(other: ToFunction) Constraint#
Create a less-than-or-equal constraint: self <= other → Constraint
- __mul__(rhs: int | float) Linear#
- __mul__(rhs: DecisionVariable | Parameter | Linear) Quadratic
- __mul__(rhs: Quadratic | Polynomial) Polynomial
- __neg__() Linear#
Negation operator: -p → Linear(-1 * p)
- __new__(id: int, name: Optional[str] = None, subscripts: Sequence[int] = [], parameters: Mapping[str, str] = {}, description: Optional[str] = None) Parameter#
Create a new Parameter.
Args:
id: Unique identifier for the parameter (must be unique within the instance including decision variables)name: Optional name for the parametersubscripts: Optional subscripts for indexingparameters: Optional metadata key-value pairsdescription: Optional human-readable description
- __radd__(lhs: int | float | DecisionVariable | Parameter | Linear) Linear#
- __radd__(lhs: Quadratic) Quadratic
- __radd__(lhs: Polynomial) Polynomial
- __repr__() str#
- __rmul__(lhs: int | float) Linear#
- __rmul__(lhs: DecisionVariable | Parameter | Linear) Quadratic
- __rmul__(lhs: Quadratic | Polynomial) Polynomial
- __rsub__(lhs: int | float | DecisionVariable | Parameter | Linear) Linear#
- __rsub__(lhs: Quadratic) Quadratic
- __rsub__(lhs: Polynomial) Polynomial
- __sub__(rhs: int | float | DecisionVariable | Parameter | Linear) Linear#
- __sub__(rhs: Quadratic) Quadratic
- __sub__(rhs: Polynomial) Polynomial
- from_bytes(bytes: bytes) Parameter#
- to_bytes() bytes#
- property description: str#
Read-only property.
- property id: int#
Read-only property.
- property name: str#
Read-only property.
- property parameters: dict[str, str]#
Read-only property.
- property subscripts: list[int]#
Read-only property.