concepts.dsl.constraint.Constraint#
- class Constraint[source]#
Bases:
object
A constraint is basically a equality expression:
function(*arguments) == rv
.Methods
Return the string representation of the constraint.
from_function
(function, args, rv)Create a constraint given a function, arguments, and return value.
replace_constants
(assignments)set_group
(group)Set the group of the constraint.
Attributes
Magic name for equality constraints.
Check if the constraint is an equality constraint.
Return True if the constraint is a group constraint.
Check if the constraint is in a group.
either a string (currently only for equality constraints), or a BoolOpType or QuantificationOpType (for Boolean expressions), or a Function object.
The arguments to the function.
The expected return value of the function.
An optional note for the constraint.
The group of the constraint.
The timestamp of the constraint.
- __init__(function, arguments, rv, note=None, group=None, timestamp=0)[source]#
Initialize a constraint. Each constraint takes the form of:
function(*arguments) == rv
- Parameters:
function (str | BoolOpType | QuantificationOpType | Function | SimulationFluentConstraintFunction) – the function name, or a BoolOpType or QuantifierType, or a Function object.
arguments (Sequence[TensorValue | StateObjectReference | OptimisticValue]) – the arguments of the function.
rv (TensorValue | OptimisticValue) – the expected return value of the function.
note (Any) – an optional note for the constraint.
group (GroupConstraint | None)
timestamp (int)
- __new__(**kwargs)#
- classmethod from_function(function, args, rv)[source]#
Create a constraint given a function, arguments, and return value.
- Parameters:
function (Function) – the function object.
args (Sequence[bool | int | Tensor | TensorValue | Any]) – the arguments of the function. The arguments can be bool, int, or torch.Tensor.
rv (bool | int | Tensor | TensorValue | Any) – the return value of the function. The return value can be bool, int, or torch.Tensor.
- Returns:
The created constraint.
- Return type:
- replace_constants(assignments)[source]#
- Parameters:
assignments (Dict[int, TensorValue])
- Return type:
- set_group(group)[source]#
Set the group of the constraint.
- Parameters:
group (GroupConstraint)
- EQUAL = '__EQ__'#
Magic name for equality constraints.
- arguments: Tuple[TensorValue | StateObjectReference | OptimisticValue, ...]#
The arguments to the function.
- function: str | BoolOpType | QuantificationOpType | Function | SimulationFluentConstraintFunction#
either a string (currently only for equality constraints), or a BoolOpType or QuantificationOpType (for Boolean expressions), or a Function object.
- Type:
The function identifier
- group: GroupConstraint | None#
The group of the constraint. None if the constraint is not in a group.
- rv: TensorValue | OptimisticValue#
The expected return value of the function.