OneHotConstraint

OneHotConstraint#

class OneHotConstraint#

A one-hot constraint: exactly one variable must be 1, the rest must be 0.

This is a structural constraint — no explicit function is stored. The implicit constraint is sum(x_i) = 1 where all x_i are binary.

__copy__() OneHotConstraint#
__deepcopy__(_memo: Any) OneHotConstraint#
__new__(variables: Sequence[int], name: Optional[str] = None, subscripts: Sequence[int] = [], description: Optional[str] = None, parameters: Mapping[str, str] = {}) OneHotConstraint#

Create a new one-hot constraint.

Args:

  • variables: List of binary decision variable IDs (exactly one must be 1)

  • name / subscripts / description / parameters: Optional metadata. Drained into the host's SoA store on insertion.

__repr__() str#
set_description(description: str) OneHotConstraint#

Set the description. Returns self for method chaining (snapshot mutation).

set_name(name: str) OneHotConstraint#

Set the name. Returns self for method chaining (snapshot mutation).

set_parameters(parameters: Mapping[str, str]) OneHotConstraint#

Replace all parameters. Returns self for method chaining (snapshot mutation).

set_subscripts(subscripts: Sequence[int]) OneHotConstraint#

Set the subscripts. Returns self for method chaining (snapshot mutation).

property description: Optional[str]#

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.

property variables: list[int]#

Read-only property.