Demon

During constraint propagation, some events (i.e. changes in CSint variables domains) will occur on CSint variables. These events are categorized into four exclusive types:

Known:

the domain has been reduced to one value (the CSint variable is instantiated);

Ex.: cs_EQ(vint, 0); /* raise a Known evnent */

NewMin:

the minimum value of the domain has been changed (became strictly greater);

Ex.: cs_GT(vint, 0);

NewMax:

the maximum value of the domain has been changed (became strictly lower);

Ex: cs_LT(vint, 0);

Neq:

one value has been removed from the domain;

Ex: cs_NEQ(vint, 0);

These events are exclusive, that is:

  • a known event will not raise neither a newMin, newMax, nor a neq event;

  • newMin nor newMax events will not raise any neq event;

For example,

CSint *vint = cs_createCSint(0, 10);
cs_GE(vint, 10);

will raise a known event (vint will be instantiated to 10) but not a newMin event.

CSint *vint = cs_createCSint(0, 10);
cs_NEQ(vint, 0);

will raise a newMin event (vint will be strictly greater than 1), but not a neq event.

IZBOOL cs_eventAllKnown(CSint **array, int size, IZBOOL (*allKnown)(CSint **array, int size, void *extra), void *extra)

The function allKnown() will be called when all the CSint variables referenced by array are instantiated (i.e. known).

In the case where all the CSint variables referenced by array are instantiated when cs_eventAllknown() is called, it returns the result of the allKnown() call, otherwise it returns TRUE.

The extra argument is a pointer to a void variable that can be used freely.

Each time allKnown() is called, this extra value is passed.

IZBOOL cs_eventKnown(CSint **array, int size, IZBOOL (*known)(int val, int index, CSint **array, int size, void *extra), void *extra)

The function known() will be called when an array [ index ] CSint variable is instantiated.

The extra argument is a pointer to a void variable that can be used freely.

Each time known() is called, this *extra value is passed.

void cs_eventNewMin(CSint **array, int size, IZBOOL (*newMin)(CSint *vint, int index, int oldMin, CSint **array, int size, void *extra), void *extra)

The function newMin() will be called each time when the minimum value of array [ index ] CSint variable is increased.

The extra argument is a pointer to a void variable that can be used freely.

Each time newMin() is called, this extra value is passed.

void cs_eventNewMax(CSint **array, int size, IZBOOL (*newMax)(CSint *vint, int index, int oldMax, CSint **array, int size, void *extra), void *extra)

The function newMax() will be called each time when the maximum value of array [ index ] CSint variable is decreased.

The extra argument is a pointer to a void variable that can be used freely.

Each time newMax() is called, this extra value is passed.

void cs_eventNeq(CSint **array, int size, IZBOOL (*neq)(CSint *vint, int index, int neqValue, CSint **array, int size, void *extra), void *extra)

The function neq() will be called each time when a value is removed from the array [ index ] CSint variable.

The extra argument is a pointer to a void variable that can be used freely.

Each time neq() is called, this extra value is passed.

void cs_backtrack(CSint *vint, int i, void (*backtrack)(CSint *vint, int i))

The function backtrack() is called when context is restored.

vint and i given to cs_backtrack are passed to backtrack().

void cs_backtrackExt(CSint *vint, void *ext, void (*backtrack)(CSint *vint, void *ext))

The function backtrack() is called when context is restored.

vint and ext given to cs_backtrack are passed to backtrackExt().

void cs_eventConflict(CSint **array, int size, void (*conflict)(CSint *vint, int index, const CSvalueSelection *vs, CSint **array, int size, void *extra), void *extra)

The function conflict() is called when constraint propagation from a variable in the array is failed.

The extra argument is a pointer to a void variable that can be used freely.

Following parameters are passed to conflict().

  • vint, index : Pointer to a variable and index of a variable in the array.

  • vs : Opration on a variable

Other parameters are same as passed to cs_eventConflict().