[gecode-users] 'Shared' IdxView in an element constraint
David Rijsman
davidrijsman at gmail.com
Thu May 8 16:47:15 CEST 2008
I have a use case where I have to post an element constraint several
times on the same variable array but using different variables for the
'index' and rhs. For example
A = {A1,A2,A3}
A[Y1] = Z1
A[Y2] = Z2
...
What I would like todo is to share the variable array among the
element constraints and I thought I could do that by posting the
element constraint myself:
Gecode::Int::Element::IdxView<Gecode::Int::IntView>* aview =
Gecode::Int::Element::IdxView<Gecode::Int::IntView>::init(this,A);
GECODE_ES_FAIL(this,(Gecode::Int::Element::ViewDom<Gecode::Int::IntView,Gecode::Int::IntView,Gecode::Int::IntView>::post(this,aview,A.size(),Y1,Z1)));
GECODE_ES_FAIL(this,(Gecode::Int::Element::ViewDom<Gecode::Int::IntView,Gecode::Int::IntView,Gecode::Int::IntView>::post(this,aview,A.size(),Y2,Z2)));
...
This will crash although by looking at the code I conclude this should
work, am I missing something or doing something completely absurd?
By the way it workd fine if I use a sharedarray of integers and post
GECODE_ES_FAIL(this,(Gecode::Int::Element::Int<Gecode::Int::IntView,Gecode::Int::IntView>::post(this,shared_integers,Y1,Z1)));
GECODE_ES_FAIL(this,(Gecode::Int::Element::Int<Gecode::Int::IntView,Gecode::Int::IntView>::post(this,shared_integers,Y2,Z2)));
thanks,
David
More information about the gecode-users
mailing list