Propagators (aka constraints)¶
NuCS comes with some highly-optimized propagators.
Propagator functions¶
Each propagator XXX defines three functions:
compute_domains_XXX(domains: NDArray, parameters: NDArray) -> intget_triggers_XXX(n: int, variable: int, parameters: NDArray) -> intget_complexity_XXX(size: int, parameters: NDArray) -> int
compute_domains function¶
This function takes as its first argument the domains of the variables of the propagator and updates them.
It is expected to implement bound consistency and to be idempotent (a second consecutive run should not update the domains).
It returns a status:
PROP_INCONSISTENCY,PROP_CONSISTENCYorPROP_ENTAILMENT.
get_triggers function¶
This function returns an event mask.
get_complexity function¶
This function returns the amortized complexity of the propagator’s compute_domains method.
These complexities are used to sort the propagators and ensure that the cheapest propagators are evaluated first.
Custom propagators¶
NuCS makes it possible to define and use custom propagators.
A propagator needs to be registered before it is used.
The following code registers the AND propagator.
1ALG_AND = register_propagator(get_triggers_and, get_complexity_and, compute_domains_and)