Prioritizing a group of variables during search

52 views
Skip to first unread message

Pierre-Louis Sauvage

unread,
Apr 28, 2021, 2:50:13 PM4/28/21
to choco-solver
Hi,

I'm having a small issue during solving: I want to set up a search strategy which will prioritize decisions on a selected group of variables (ie. setting this group at the top of the decision tree to make the search faster) but I can't seem to find a pre-built way to. 

Does it exist? 

I've tried using "inputOrderLBSearch" but I get some strange behavior (it seems some constraints are not taken into account properly).

If the above search strategy is the correct one to use, do I need to specify a default strategy for all the other variables?

Example of pseudo-code if the groups were reduced to a single variable :

IntVar A; //primary variable
IntVar Ax;
model.element(A, list, Ax);

IntVar B; //less important variable
IntVar Bx;
model.element(B, list, Bx);

... Various constraints between Ax and Bx ...

Solver solver = model.getSolver();
solver.setSearch(inputOrderLBSearch(A));

Thanks for your help! Regards,
Pierre-Louis Sauvage

cpru...@gmail.com

unread,
Apr 29, 2021, 8:05:15 AM4/29/21
to choco-solver
Hi,

Element constraints are not posted to the model.
Can you post them and have a try ?

Hope that helps,
CP

Pierre-Louis Sauvage

unread,
Apr 29, 2021, 8:38:42 AM4/29/21
to choco-solver
Hi,
All constraints are posted correctly, and when I try to solve without specifying a search strategy it works as expected.
However, when I set the search like above, constraints are no longer verified correctly.
I'm sure I set the search strategy wrong but I don't know how to correct it.

cpru...@gmail.com

unread,
Apr 29, 2021, 11:40:58 AM4/29/21
to choco-solver
> If the above search strategy is the correct one to use, do I need to specify a default strategy for all the other variables?

I should have read this more carefully.
When you define a search strategy, it is suppose to be complete, that is, all variables are fixed once the strategy ends.
In your case, when the strategy on A ends, some variables are not fixed, so you need to define a second strategy for those variables.

Pierre-Louis Sauvage

unread,
Apr 29, 2021, 12:49:30 PM4/29/21
to choco-solver
Alright thank you.
Is there a pre-built way to do so, or do I need to collect the rest of the variables in an array?
By the way, if I want to apply the "default" strategy for these other variables (which should work fine), what is the method's name that I should use?
Thanks for the help!

cpru...@gmail.com

unread,
Apr 30, 2021, 7:57:40 AM4/30/21
to choco-solver
You can declare a second strategy over all variables, that will do the job.
Indeed, A will be automatically skipped since they will be fixed when the second strategy will be applied. 
Reply all
Reply to author
Forward
0 new messages