[gecode-users] Unexpected propagation/search behaviour
Lars Otten
ottenl at student.chalmers.se
Mon Jan 23 17:07:21 CET 2006
Attached you find all code related to my propagator, below are the essential
parts of the main program. I hope that is sufficient...
Any ideas will be greatly appreciated!
/Lars
/*
* tailassi.cc (excerpts)
*/
using namespace std;
class Activity;
vector<Activity> activities;
class Tail : public Example {
protected:
// predecessor, successor and vehicle variables
IntVarArray suc, pre, veh;
public:
using Space::nextRand; // int (*nextRand) (const int&)
/// Actual model
Tail(const Options& opt);
/// Constructor for cloning \a s
Tail(bool share, Tail& s) : Example(share,s) {
nextRand = s.nextRand;
pre.update(this, share, s.pre);
suc.update(this, share, s.suc);
veh.update(this, share, s.veh);
}
/// Print solution
virtual void print(void);
/// Copy during cloning
virtual Space* copy(bool share) {
return new Tail(share,*this);
}
};
int nextRandom(const int& max);
int main(int argc, char** argv) {
Options opt("Tail assignment");
opt.iterations = 20000;
opt.parse(argc,argv);
parseData(opt.file); // parses the datafile
opt.fptr = &nextRandom;
srand(opt.seed);
Example::run<Tail,DFS>(opt);
return 0;
}
Tail::Tail(const Options& opt) :
suc(this,noOfAct),
pre(this,noOfAct),
veh(this,noOfAct)
{
//... Variable initialisation
distinct(this,suc);
// check for overlaps in case of restricted acitivities
for (int i=0; i<noOfAct; ++i) {
if (activities[i].restricted) {
const set<int>& s = activities[i].overlappingActs;
if (s.size() != 0) {
IntVarArray arr(this,s.size() + 1);
int j=0;
for (set<int>::iterator it = s.begin(); it != s.end(); ++it) {
arr[j++] = veh[*it];
}
arr[j] = veh[i]; // add current act. no to set
distinct(this,arr);
}
}
}
inverse(this,suc,pre);
tunneling(this,suc,pre,veh, &fwOverlap);
branch(this, suc, BVAR_DEGREE_MIN, BVAL_MAX);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tunneling.cc
Type: text/x-c++src
Size: 425 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20060123/22cdfe70/attachment.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tunneling.hh
Type: text/x-c++hdr
Size: 1419 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20060123/22cdfe70/attachment.hh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tunneling.cc
Type: text/x-c++src
Size: 1755 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20060123/22cdfe70/attachment-0001.cc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tunneling.icc
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20060123/22cdfe70/attachment.asc>
More information about the gecode-users
mailing list