concepts.dsl.constraint#
Data structures for Constraint Satisfaction Problems (CSPs).
In general, a CSP can be represented as a tuple of variables, domains (for each variable), and constraints.
Here, we only consider constraints of the following form: function(*arguments) == rv
. Internally:
- Each variable can either be a determined
TensorValue
or anOptimisticValue
(i.e., undetermined value). For
TensorValue
, the representation contains its data type and the actual value. ForOptimisticValue
, the representation contains its data type and a single integer, representing the index of the variable.
- Each variable can either be a determined
- Each constraint is represented as a
Constraint
object, which contains the function, arguments, and the return value. - The function is represented as a string (only for equality constraints), or BoolOpType (and, or, not), or QuantificationOpType (forall, exists),
or
Function
objects. Both arguments and return values can beDeterminedValue
orOptimisticValue
.
- Each constraint is represented as a
- The index of optimistic values starts from -2147483647 (i.e.,
OPTIM_MAGIC_NUMBER
). Therefore, they can be directly stored in tensors without any conversion, which is helpful for implementing CSP-based expression executors. There are a few helper functions to convert between optimistic values and their indices.
- The index of optimistic values starts from -2147483647 (i.e.,
Module attributes
A mapping from variable indices to assignment values. |
Functions
|
Convert a value to OptimisticValue or a (determined) TensorValue. |
|
Get the value of a variable based on the assignment dictionary. |
Check if a value is an optimistic identifier. |
|
If v is an optimistic value, return a string representation of the optimistic identifier, otherwise return str(v). |
|
Get the optimistic identifier from an optimistic value. |
|
|
Print an assignment dictionary. |
Classes
An assignment of a variable. |
|
See class Assignment. |
|
A constraint is basically a equality expression: |
|
A constraint satisfaction problem. |
|
A special constraint for equality constraints. |
|
An optimistic value object holds a pair of data type and an optimistic identifier. |
|
SimulationConstraint is a special kind of constraint that asserts the return value of the function is the grounding of a predicate after executing action |