0

I have got a project in Choco solver, but I have a question about the external effects during the search.

I have got a planning graph with (let's say) BoolVars organised in layers and durations assigned to the layers, which mean that some action starts and some ends. The variable selection is static from the end of the plan to the start of the plan (the choice of the actions in layer is arbitrary).

I am researching a solution that uses a simplex algorithm to help with assigning the durations, as between the start and the end of an action A we need to have a duration equal to N. There are some more constraints in between.

The additional constraints are created based on the instantiation of the BoolVars, however they are organized in an external matrix, so when an end action of the action A is added, in the effect an additional row is added to the matrix and current constraints are reformulated. On backtracking we would like to modify the matrix in the reverse way i.e. remove the row and unpost the constraints.

Is there some way to realize this complex behavior in Choco?

Eramol
  • 33
  • 7

1 Answers1

0

Do you know in advance what constraint is triggered if a boolean is set to true?If yes, use reification (create the constraint at the beginning but associate them with boolvars instead of posting them).

For professional support on Choco Solver, you can contact https://www.cosling.com/

  • reification doesn't solve it, unfortunately. I use it extensively through my model, but this is something different. It triggers an external action on instantiation and triggers a reverse action on backtrack. – Eramol Apr 19 '17 at 19:13
  • 1) you should be able to create and post constraints dynamically using solver._post(false,c), so that it is removed upon backtrack (see javadoc). 2) you can also trigger custom action (like color a button in red and put it back to green upon backtrack) using IOperation: - do what you have to do (let say color the stuf in red) - do environment.save( new IOperation(color in ref))... you can use lamda... that code will be called upon backtrack In your case you will add/remove rows instead of colouring, I just wanted to show that you could actually do anything. Am I clear? :-) – Jean-Guillaume Fages Apr 20 '17 at 16:07