[gecode-users] how to constaint sum of sum with linear constraint

manel askri askri.manel1 at gmail.com
Mon Nov 18 22:26:24 CET 2013


hi everyone!

I want to post a constraint that is the sum of a sum like this
*sum(sum (res [ i ] * X.row (i)))=Z, **with 0 < i <n*

 but in the documentation MPG I just found the linear constraint that are
used to constraint the sum not the sum of sum  :

let me explain:

I have a matrix : vector < vector <int> > res , and a Boolean matrix X
defined as follows: Matrix <BoolVarArray> X (a, m, n);

in the following code I had to do this sum :

*sum (res [ i ] * X.row (i)) with 0 < i <n* / / here i can not pay this sum
for a table because the  2 matrix does not have the same type and i didnt
find any prototype of the linear constraint that can do this.

Then I had to make this sum :

*the sum of the previous sum= Z*

so I used this constraint but it appeared that it is false because it does
not give me the desired solution :
*linear ( * this , res [ i ] X.row ( i ) IRT_EQ , Z) ;*

I know that this constraint only to : *sum (res [ i ] * X.row (i)) = Z* ,
where 0 < i < n; an dits wrong.

you have an idea on correcting this error could you help me please

thank you very much for your help

Manel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20131118/b2e03ef7/attachment.html>


More information about the users mailing list