Is it possible to register a listener to nice propagation structure
e.g. to efficiently refresh a specific listener UI showing the progress towards a solution
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Check the object invariants.core.computation.Event.
Here is how to use it on a variable defined as the cardinality of some IntSetVar:
valk:IntVar=Cardinality(h)Event(k,{println("Variable K has changed: "+k)})
This is the way to update a graphical display of the problem during the search.
Events can even modify some variables of the problem, but this must be declared to ensure that propagation is performed as a single wave. the correct way to do it is by setting the third parameter of the Event to an iterable that contains all the variables controled by the model that the event will modify. This is done as follows:
valk:IntVar=Cardinality(h)vall:IntVar=newIntVar(...)Event(k,{println("Variable K has changed, updating l"+k)l:=k},List(l))
Events are always called when the variable changes when a complete propagation is performed. However, they are generally not called during a partial propagation except if they control some variable contributing to the target of the partial propagation, as declared by theirr controling capabilities on other variables of the model.
If you want more freedom, you can always implement an invariant, see invariants.core.computation.Invariant
Last edit: Renaud De Landtsheer 2012-05-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to register a listener to nice propagation structure
e.g. to efficiently refresh a specific listener UI showing the progress towards a solution
Check the object invariants.core.computation.Event.
Here is how to use it on a variable defined as the cardinality of some IntSetVar:
This is the way to update a graphical display of the problem during the search.
Events can even modify some variables of the problem, but this must be declared to ensure that propagation is performed as a single wave. the correct way to do it is by setting the third parameter of the Event to an iterable that contains all the variables controled by the model that the event will modify. This is done as follows:
Events are always called when the variable changes when a complete propagation is performed. However, they are generally not called during a partial propagation except if they control some variable contributing to the target of the partial propagation, as declared by theirr controling capabilities on other variables of the model.
If you want more freedom, you can always implement an invariant, see invariants.core.computation.Invariant
Last edit: Renaud De Landtsheer 2012-05-20