C++ Reference: class GenericLiteralWatcher

This documentation is automatically generated.

This class allows registering Propagator that will be called if a watched Literal or LbVar changes.

TODO(user): Move this to its own file. Add unit tests!
Method
GenericLiteralWatcher

Return type: explicit

Arguments: Model* model

~GenericLiteralWatcher

NotifyThatPropagatorMayNotReachFixedPointInOnePass

Return type: void

Arguments: int id

The default behavior is to assume that a propagator does not need to be called twice in a row. However, propagators on which this is called will be called again if they change one of their own watched variables.

NumPropagators

Return type: int

Returns the number of registered propagators.

Propagate

Return type: bool

Arguments: Trail* trail

On propagate, the registered propagators will be called if they need to until a fixed point is reached. Propagators with low ids will tend to be called first, but it ultimately depends on their "waking" order.

Register

Return type: int

Arguments: PropagatorInterface* propagator

Registers a propagator and returns its unique ids.

RegisterLevelZeroModifiedVariablesCallback

Return type: void

Arguments: const std::function<void(const std::vector<IntegerVariable>&)> cb

Set a callback for new variable bounds at level 0. This will be called (only at level zero) with the list of IntegerVariable with changed lower bounds. Note that it might be called more than once during the same propagation cycle if we fix variables in "stages".

RegisterReversibleClass

Return type: void

Arguments: int id, ReversibleInterface* rev

Registers a reversible class with a given propagator. This class will be changed to the correct state just before the propagator is called. Doing it just before should minimize cache-misses and bundle as much as possible the "backtracking" together. Many propagators only watches a few variables and will not be called at each decision levels.

RegisterReversibleInt

Return type: void

Arguments: int id, int* rev

Registers a reversible int with a given propagator. The int will be changed to its correct value just before Propagate() is called. Note that this will work in O(num_rev_int_of_propagator_id) per call to Propagate() and happens at most once per decision level. As such this is meant for classes that have just a few reversible ints or that will have a similar complexity anyway. Alternatively, one can directly get the underlying RevRepository with a call to model.Get<>(), and use SaveWithStamp() before each modification to have just a slight overhead per int updates. This later option is what is usually done in a CP solver at the cost of a sligthly more complex API.

SetPropagatorPriority

Return type: void

Arguments: int id, int priority

Changes the priority of the propagator with given id. The priority is a non-negative integer. Propagators with a lower priority will always be run before the ones with a higher one. The default priority is one.

Untrail

Return type: void

Arguments: const Trail& trail, int literal_trail_index

WatchIntegerVariable

Return type: void

Arguments: IntegerVariable i, int id, int watch_index = -1

WatchIntegerVariable

Return type: void

Arguments: IntegerValue v, int id

WatchLiteral

Return type: void

Arguments: Literal l, int id, int watch_index = -1

Watches the corresponding quantity. The propagator with given id will be called if it changes. Note that WatchLiteral() only trigger when the literal becomes true. If watch_index is specified, it is associated with the watched literal. Doing this will cause IncrementalPropagate() to be called (see the documentation of this interface for more detail).

WatchLowerBound

Return type: void

Arguments: IntegerVariable var, int id, int watch_index = -1

WatchLowerBound

Return type: void

Arguments: IntegerValue i, int id

No-op overload for "constant" IntegerVariable that are sometimes templated as an IntegerValue.

WatchUpperBound

Return type: void

Arguments: IntegerVariable var, int id, int watch_index = -1

WatchUpperBound

Return type: void

Arguments: IntegerValue i, int id

Send feedback about...