[gecode-users] Getting just assigned variable from ViewArray in a propagator
Yunus Acikoz
yunusacikoz at gmail.com
Fri Mar 18 10:47:08 CET 2016
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/6909f9b6/attachment.html>
More information about the users
mailing list