[gecode-users] Help to express a constraint

Philippe aqwzsxaqwzsx at orange.fr
Mon Jun 2 22:34:32 CEST 2014


Hello Christian,

Thanks for your answer. 
1) I realized during the WE that i don't really understand the difference
between an "rel" and a "expr" (not from a pure C++ point of view).

2) The example that i have provided point on some confusion :
I have written status(t,m) which is correct but 
status(succ(t,m)) is incorrect, the correct form is status(succ(t,m),m).
Thus,  element(Status, Succ(t,m)) is syntactically correct but wrong.

3) I've found a similar solution than yours (after hard work!). With however
a big difference (probably because i'm perverted by years of imperative
programming) : 
I have written :

if (Status(t, m) != 3)
{
  BoolVar not_inprogress = 
  expr(*this, element(Status.row(m), Succ(t,m)) != 3);
  BoolVar toa_of_succ = 
  expr(*this, element(Time.row(m), Succ(t, m)) > ETOA[m] + 10);
  rel(*this, not_inprogress >> toa_of_succ);
}

Thus, the (Status(t, m) != 3) is not part of the constraint, what are the
implications of doing this ? (that's more a constraint programming question
than a question related to gecode, i admit).


4) Is it a good point to be able to express things like that (and i could
may be try to propose some patches) :

Example 1 :
==========

expr1.1 : expr(*this, element(Status.row(m), Succ(t,m)) != 3) 

compile, but :

expr1.2 : expr(*this, Status(Succ(t,m), m) != 3);

don't, however, the first form seems to me more elegant.

Example 2 :
===========

expr2.1 :
IntVar task(*this, t, t);
expr(*this, Succ(t,m) != task);

compile, but :

expr2.2 : expr(*this, Succ(t,m) != t) 

don't. Here again, the second form seems more elegant.

Best,
Philippe





More information about the users mailing list