0

I have a technical question regarding the Choco 4 CP solver.

I would like to call a method (lets call it f()) whenever some Boolean variables in my model are assigned or unassigned during search. The purpose of f() is to update a data structure which is used extensively by propagators.

My first attempt was to implement a custom IVariableMonitor but the method onUpdate(Variable v, IEventType iEventType) is invoked only when a variable gets assigned to 0/1 but not unassigned.

I also tried to use search monitors but no success for now.

Is there a way to perform this task?

Thanks!

1 Answers1

1

I have figured out how to solve this issue.

What I actually needed is a data structure that supports an automatic undo operation. That is, modified when a variable is assigned and reverted automatically if the corresponding variable that triggered the modification gets unassigned.

Luckily, choco provides such backtrackable data structures (see org.chocosolver.util.objects). As far as I understand, the state of a backtrackable data structure is associated with a decision level. When the solver backtracks any modification above the current decision level is reverted.