[gecode-users] Cleaner way for if/then constraint condition

Christian Schulte cschulte at kth.se
Wed Jun 11 10:29:57 CEST 2014


Thanks for the info.

 

The simplest version would be as before by reification: for each array index i but the last one, post:

                rel(*this, (x[i] == 10) >> (x[i+1] == 11));

 

If that turns out to be not efficient enough (most likely that is the case if you have arrays with 20000 elements), then you could implement a simple propagator. This is described in Part P of MPG. You want to make the propagator incremental by reading about Advisors in that part.

 

However, first I would make really sure that your model is correct before indulging in an implementation exercise.

 

Cheers

Christian

 

--

Christian Schulte, Professor of Computer Science, KTH, www.ict.kth.se/~cschulte/

 

From: Richard Portelli [mailto:richard.portell at gmail.com] 
Sent: Tuesday, June 10, 2014 11:11 PM
To: cschulte at kth.se
Subject: Re: [gecode-users] Cleaner way for if/then constraint condition

 

Hello Christian,

Thank you for your quick answer.

The maximum number of numbers I could have in my array would be around 20 000. I, for example, know that there will be some numbers of these array (determined by gecode) that will be equal to a certain value(known before gecode generation). Lets say 10. I don't know where these numbers with value 10 will be. However, I know that the numbers just after these number with 10 values should have the value 10+1.

I hope my explanations are clear enough :)

I really appreciate your help.
Cheers,
Richard

 

2014-06-10 22:25 GMT+02:00 Christian Schulte <cschulte at kth.se>:

Hi,

 

This depends very much on whether you want to express your condition:

-          For each and every element in the array, or

-          Just for a particular element at a certain position in the array which is statically known, or

-          Just for a particular element where the index is not yet know, or

-          How large the array would be in practice, or

-          …

 

Same more info might help.

 

Best

Christian

 

--

Christian Schulte, KTH, web.it.kth.se/~cschulte/

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf Of Richard Portelli
Sent: Tuesday, June 10, 2014 08:21 PM
To: users at gecode.org
Subject: [gecode-users] Cleaner way for if/then constraint condition

 

Hello,

I am looking for the "best" way to implement if/then type of constraint propagation.

An example would be : I have an array of 10 integers with sum =100. If one element is equal to 10, the following one should be 11.

Adding a lot of these constraint is it ressource intensive or not necessary?

Thanks for your help,

Cheers,
Richard

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20140611/3b85d5a7/attachment-0001.html>


More information about the users mailing list