[gecode-users] 'Shared' IdxView in an element constraint

Christian Schulte cschulte at kth.se
Thu May 8 17:32:24 CEST 2008


Hmmm, as you used the word already... "Absurd" is not that far away, maybe
let's call it "daring": each element propagator destructively updates its
IdxView data structure, so they just can't be shared. 

Actually, the same is true for element with integers: the data structure on
which propagation is performed cannot be shared, however the array of
integers from which the datastructure is created can be shared.

In principle it would be possible to design a propagator that shares the
array but it would not buy you much in memory reduction. 

Cheers
Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/


-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of David Rijsman
Sent: Thursday, May 08, 2008 4:47 PM
To: users at gecode.org
Subject: [gecode-users] 'Shared' IdxView in an element constraint

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,Geco
de::Int::IntView,Gecode::Int::IntView>::post(this,aview,A.size(),Y1,Z1)));
GECODE_ES_FAIL(this,(Gecode::Int::Element::ViewDom<Gecode::Int::IntView,Geco
de::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

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





More information about the gecode-users mailing list