[gecode-users] Restart search engine, adding a new constraint

Amina Kemmar kemmar.amina at gmail.com
Thu Jun 6 10:00:58 CEST 2013


On 06/01/2013 06:40 PM, Guido Tack wrote:
> I guess the problem is that you only want to see x,y but you need to search on z,k first? That's a bit more tricky.
> You can use a restart search engine, which restarts after each solution. Then for each solution you add the negation of the solution as a constraint in the root, e.g. (not (x==1 and y==1)). I'm not sure how well this scales if you have many solutions, but it could be worth a try.
>
> Cheers,
> Guido
>
> On 31/05/2013, at 12:04, Christian Schulte <cschulte at kth.se> wrote:
>
>> Hi,
>>
>> I am not sure whether I understand your question correctly. But you can
>> exchange the order of the search engine (that is, in my previous reply swap
>> e1 and e2).
>>
>> Best
>> Christian
>>
>> --
>> Christian Schulte, Professor of Computer Science, KTH,
>> www.ict.kth.se/~cschulte/
>>
>>
>> -----Original Message-----
>> From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
>> Of Amina Kemmar
>> Sent: Friday, May 31, 2013 10:00 AM
>> To: users at gecode.org
>> Subject: [gecode-users] Display the values of a set of variable without
>> duplicates
>>
>> Hello,
>>
>> I already asked for the following problem:
>>
>> According to the variables defined in our model (x,y,z,k), I obtained the
>> following solutions :
>>   1,1,2,3
>>   1,1,5,6
>>   1,1,7,9
>>   1.1,8,8
>> I am interested to the values of the two variable x and y, so I want to
>> avoid the enumeration of the three last solution in order to display just
>> the first solution.
>>
>> I got the following response:
>>
>> One way to do it is as follows:
>>   - You create a space s that only has a brancher for x and y
>>   - You create a search engine e1 for s and find a solution, say s1
>>   - You post a brancher in s1 for z and k.
>>   - You create a search engine e2 for s and find just a single solution!
>>   - You can then also get more solutions from e1 and repeat the previous two
>> steps.
>>
>> Thank you for the solution, it works very well, but I have an other problem
>> which is the enumeration order of the variables x, y, z and k. I must begin
>> the branching from the variables  z and k, then x, y (In this way, Gecode
>> enumerates quickly the solutions but for the first order "x,y,z,k", it takes
>> about 30 minutes to enumerate the first solution).
>> Is there an other solution?
>>
>> Thank you.
>> -----
>> Amina
>>
>>
>> _______________________________________________
>> Gecode users mailing list
>> users at gecode.org
>> https://www.gecode.org/mailman/listinfo/gecode-users
>>
>>
>> _______________________________________________
>> Gecode users mailing list
>> users at gecode.org
>> https://www.gecode.org/mailman/listinfo/gecode-users
Hi,

Thank you Guido for the response, this is exactly what I want to do, but 
I red the documentation (section 9.4) , and I added the following code 
to restart the search:

MyExample* s1 = new MyExample(opt);
Search::Options o;
Search::Cuttof* c = Search::Cuttof::constant(2);
o.cuttof = c;
RBS<DFS,MyExample> e3(s1, o);

I get some errors : ‘Cuttof’ is not a member of ‘Gecode::Search’

My second question is how to add a new constraint, after the restart search?

Thank you for your help.
cheers.

I get



More information about the users mailing list