Hi!

While working on a course assignment I realized (after some struggling) that summing over a matrix slice does not perform as expected:

=== snippet ==
BoolVarArray x(home, n*n, 0, 1);
Matrix<BoolVarArray> m(x, n, n);

rel(home, sum(m.slice(i, i+1, i, i+1)) > 0); // forces m(i,i) > 0 !!
BoolVarArgs s;
s << m(i,i) << m(i+1,i) << m(i,i+1) << m(i+1,i+1);
rel(home, sum(s) > 0); // forces the sum over the 4 variables > 0 (as I wanted)

== end of snippet ==

The sum(m.slice(...)) only seems to sum the first element in the slice?!
Quite surprising and unnatural to me. Am I doing something wrong here?
(I get no compiler warnings or errors..)

The following post discusses a similar subject concerning IntVar's..
http://www.gecode.org/pipermail/users/2013-August/004086.html

All the best,
Tomas

_______________________________________________
Gecode users mailing list
users@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to