[gecode-users] Getting just assigned variable from ViewArray in a propagator

Christian Schulte cschulte at kth.se
Fri Mar 18 14:53:44 CET 2016


Hi, I would go for the advisors. It is reasonably straightforward and the most efficient.

 

Cheers

Christian

 

--

Christian Schulte, www.gecode.org/~schulte

Professor of Computer Science, KTH,  <mailto:cschulte at kth.se> cschulte at kth.se

Expert Researcher, SICS,  <mailto:cschulte at sics.se> cschulte at sics.se

 

From: Yunus Acikoz [mailto:yunusacikoz at gmail.com] 
Sent: Friday, March 18, 2016 12:21
To: cschulte at kth.se
Cc: users at gecode.org
Subject: Re: [gecode-users] Getting just assigned variable from ViewArray in a propagator

 

Hi Christian,

 

Thanks for the quick reply.

 

Bitset suggestion in the first option seems easier to implement.

But considering that each ViewArray holds around 15000+ Views, would it be better to use Advisors performance wise?

 

Best regards

Yunus

 

On Fri, Mar 18, 2016 at 12:44 PM, Christian Schulte <cschulte at kth.se> wrote:

Hi Yunus,

 

There are two options here:

1.       You track inside your propagator for which assigned variable you have already created a propagator. One easy trick is (it depends on your propagator whether this is in fact possible) to remove assigned views from your array. Another option would be to use a bitset or something like that.

2.       You can track which views get assigned by using advisors. Please check MPG for the details.

 

Best

Christian

 

--

Christian Schulte, www.gecode.org/~schulte

Professor of Computer Science, KTH, cschulte at kth.se

Expert Researcher, SICS, cschulte at sics.se

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf Of Yunus Acikoz
Sent: Friday, March 18, 2016 10:47
To: users at gecode.org
Subject: [gecode-users] Getting just assigned variable from ViewArray in a propagator

 

Hi everyone,

 

I have a tunneling constraint propagator that has 4 ViewArrays and scheduled to run on their assignment events: 

 

    Gecode::ViewArray<Gecode::Int::IntView> successors_;

  Gecode::ViewArray<Gecode::Int::IntView> predecessors_;

  Gecode::ViewArray<Gecode::Int::IntView> vehicles_;

  Gecode::ViewArray<Gecode::Int::BoolView> cancels_;

 

  successors_.subscribe(home, *this, Gecode::Int::PC_INT_VAL);

  predecessors_.subscribe(home, *this, Gecode::Int::PC_INT_VAL);

  vehicles_.subscribe(home, *this, Gecode::Int::PC_INT_VAL);

 

I want to post additional constraints whenever a value gets fixed over those arrays.

 

for (int i = 0; i < successors_.size(); ++i) {

    if (vehicles_[i].assigned()) {

        int val = vehicles_[i].val();

        // post constraint...

        // eg.

        Gecode::element(home, vehicles_, successors_[i], val);   

    }

    if (successors_[i].assigned()) {

        int val = successors_[i].val();

        // post another constraint ...       

    }

}

 

For example assume that we first assign the vehicle[2] to some value and propagate accordingly.

Then if we assign vehicle[7] how can we prevent doing same action for vehicle[2].

 

Does it post the same constraints for all the previously assigned variables, again and again.... ?

 

Is there a way to get the recently assigned variable that cause thıs propagator to run?

Cheers,
Yunus
 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20160318/3aa794dd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4623 bytes
Desc: not available
URL: <http://www.gecode.org/pipermail/users/attachments/20160318/3aa794dd/attachment-0001.bin>


More information about the users mailing list