NamedFunction

class NamedFunction

NamedFunction wrapper for Python

__add__(other: ToFunction) Function

Addition: returns self.function + other

__copy__() NamedFunction
__deepcopy__(_memo: Any) NamedFunction
__eq__(other: ToFunction) Constraint

Create an equality constraint: self.function == other → Constraint with EqualToZero

Returns a Constraint where (self.function - other) == 0. Note: This does NOT return bool, it creates a Constraint object.

__ge__(other: ToFunction) Constraint

Create a greater-than-or-equal constraint: self.function >= other → Constraint with LessThanOrEqualToZero

Returns a Constraint where (other - self.function) <= 0.

__le__(other: ToFunction) Constraint

Create a less-than-or-equal constraint: self.function <= other → Constraint with LessThanOrEqualToZero

Returns a Constraint where (self.function - other) <= 0.

__mul__(other: ToFunction) Function

Multiplication: returns self.function * other

__neg__() Function

Negation: returns -self.function

__new__(id: int, function: ToFunction, name: Optional[str] = None, subscripts: Sequence[int] = [], description: Optional[str] = None, parameters: Mapping[str, str] = {}) NamedFunction

Create a new NamedFunction.

Args:

  • id: The unique identifier for this named function

  • function: The function (int, float, DecisionVariable, Linear, Quadratic, Polynomial, or Function)

  • name: Optional name for the function

  • subscripts: Optional subscripts for indexing

  • description: Optional description

  • parameters: Optional key-value parameters

__radd__(other: ToFunction) Function

Reverse addition: returns other + self.function

__repr__() str
__rmul__(other: ToFunction) Function

Reverse multiplication: returns other * self.function

__rsub__(other: ToFunction) Function

Reverse subtraction: returns other - self.function

__sub__(other: ToFunction) Function

Subtraction: returns self.function - other

evaluate(state: ToState, atol: Optional[float] = None) EvaluatedNamedFunction

Evaluate the named function with the given state.

Args:

  • state: A State object, dict[int, float], or iterable of (int, float) tuples

  • atol: Optional absolute tolerance for evaluation

Returns: EvaluatedNamedFunction containing the evaluated value

from_bytes(bytes: bytes) NamedFunction
partial_evaluate(state: ToState, atol: Optional[float] = None) NamedFunction

Partially evaluate the named function with the given state.

This modifies self in-place and returns self for method chaining.

Args:

  • state: A State object, dict[int, float], or iterable of (int, float) tuples

  • atol: Optional absolute tolerance for evaluation

Returns: Self (modified in-place) for method chaining

to_bytes() bytes
property description: Optional[str]

Read-only property.

property function: Function

Read-only property.

property id: int

Read-only property.

property name: Optional[str]

Read-only property.

property parameters: dict[str, str]

Read-only property.

property subscripts: list[int]

Read-only property.