[gecode-users] counting constraint with BoolVarArgs
Philippe
aqwzsxaqwzsx at orange.fr
Tue Aug 6 15:46:02 CEST 2013
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
More information about the users
mailing list