Simply create a new IntArgs and IntVarArgs with the right size and put all the coefficients and variables that you need to sum up into those arrays. Then you only need to post one linear.
Cheers, Guido On 19 Nov 2013, at 8:26 am, manel askri <askri.man...@gmail.com> wrote: > > 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 > > > > _______________________________________________ > Gecode users mailing list > users@gecode.org > https://www.gecode.org/mailman/listinfo/gecode-users
_______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users