[gecode-users] Element restriction is correctly used in MPG?

Sebastian Albert albert at math.uni-goettingen.de
Sat Feb 17 15:02:38 CET 2018


Hello Alejandro

The comment above these three lines is important to understand what they
are meant to do:
// Just assume that the circle starts forwards

So this is sort of symmetry breaking here. The "element" constraint here
ensures that "p0 is the value whose successor is 0" (i.e. the
position/index of the value "0" in the array "succ"). And then they say
that the successor of 0 must not be less than this p0. So, the three
lines altogether can be summed up as "the successor of 0 must not be
smaller then the predecessor of 0". Obviously, every tour (represented
by the successor relationship) could be "reversed" and yield the same
result (due to symmetry), and the solver shall only consider one out of
each pair of such two "equivalent" solutions, which is w.l.o.g. chosen
to be the one fulfilling this constraint.

Note also that many predefined constraint posting functions in Gecode
are overloaded such that where an IntVar object is allowed, you could
also just use an int (which is semantically equivalent to having a
variable that can only have that one particular value):

http://www.gecode.org/doc/5.1.0/reference/group__TaskModelIntElement.html

Best
Sebastian

On 17.02.2018 13:50, Alejandro.Fernández wrote:
> Hello group.
> 
> I have been studying the TSP example that is in the gecode.org
> <http://gecode.org/> site package and I have the following doubt
> regarding the element function:
> 
> IntVar p0 (* this, 0, n - 1);
> element (* this, succ, p0, 0); // here (1)
> rel (* this, p0, IRT_LE, succ [0]);
> 
> According to 'MPG.pdf' pg. 70 (4.4.12):
> 
> element (home, c, x, y) // (2)
> 
> Says, variable y to be the element of the array c at index x, then how
> can it be possible (1) ???
> 
> regards
> Alex
> 
> 
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
> 



More information about the users mailing list