[gecode-users] Simple Reified relation
Sameh El-Ansary
samehansary at gmail.com
Wed Jul 26 19:41:31 CEST 2006
Hi,
I am trying to do something very simple in Gecode with reified constraints.
I would like to do the follwoing:
- x ranges from 4 to 6
- b is a boolean variable
- (x=:4) reified in b
- When I assign x to 5, I expect b to be equal to 0, but b still ranges from
0..1 !!
i.e. I am trying to do what I would write in Oz as:
declare
X B
X :: 4#6
B :: 0#1
(X =:4)=B
X=:5
{Show [X B]}
This shows: [5 0]
I wrote that in Gecode by using unmanaged c++ in visual studio 2005 with the
windows binaries provided on the Gecode website as follows:
//--------------------------
class Wires : public Space {
public:
Wires(){
IntVar x(this,4,6);
BoolVar b(this,0,1);
rel(this,x,IRT_EQ,4,b);
rel(this,x,IRT_EQ,5);
cout << "x="<< x << " b= " << b << "\n";
}
Wires(bool share, Wires& e) : Space(share,e) {}
virtual Space* copy(bool share)
{ return new Wires(share,*this);
}
};
//--------------------------
This outputs:
x=5 b= [0..1]
I expected it to be
x=5 b= 0
What am I missing here?
I also believe there is a small typo in the documentation on relations
void Gecode::rel (Space *home, IntVar x, IntRelType r, int c, BoolVar b,
IntConLevel icl=ICL_DEF)
Post propagator for .x ~_r c
I think it was meant to be
Post propagator for .(x ~_r c) <=> b
Or there is something I am really not getting in reifying relations!!
Sameh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20060726/bec09f1f/attachment.htm>
More information about the gecode-users
mailing list