Hi Philippe, counting ones in BoolVar arrays is the same as the sum over the array, so just use linear with BoolVar arguments.
Cheers, Guido On 06/08/2013, at 11:46 PM, Philippe <aqwzsxaqw...@orange.fr> wrote: > Hello Everybody, > > I need to count the number of 'true' values stored in a BoolVarArray > (accessed through a Matrix<BoolVarArgs>). However, the counting constraint > (as described page 63 of gecode 4.2.0 manual) only takes integer variables. > Thus, the following pseudo-code doesn't work : > > BoolVarArray _FPR(*this, _Na, _Ne); > IntVarArray _NFPR(*this, _Na); > Matrix<BoolVarArgs> fpr(_FPR, _Na, _Ne); > > for(int i = 0 ; i < _Na ; ++i) > { > // after count's call, > // _NFPR[i] = number of 'true' in fpr.row(i) > count(*this, fpr.row(i), true, IRT_EQ, _NFPR[i]); > } > > > 1) What is the reason to forbide BoolVar in count ? > > 2) Is it legal (don't think so) to write : > > Matrix<IntVarArgs> fpr(_FPR, _Na, _Ne); > > for(int i = 0 ; i < _Na ; ++i) > count(*this, fpr.row(i), 1, IRT_EQ, _NFPR[i]); > > 3) Or do I need to replace fpr's definition by : > > Matrix<IntVarArgs> fpr(_FPR, _Na, _Ne); > > 4) Or, do I need to use channeling ? > But i don't find the way to express it > It seems that the tips page 67 is not relevant here. > help please ! > > 5) Or something else ? > > Thanks for any help, > Philippe > > > > _______________________________________________ > 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