[gecode-users] Unexpected propagation/search behaviour
Christian Schulte
schulte at imit.kth.se
Wed Jan 25 11:59:15 CET 2006
Hi Lars,
even after looking more carefully to your code I can't see the reason.
Please try to simplify. I would assume that Gecode is not guilty ;-)
Also, which version of Gecode do you use? (I saw that you hacked it somehow
with a rand function?)
Cheers
Christian
--
Christian Schulte, http://www.imit.kth.se/~schulte/
-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Lars Otten
Sent: Monday, January 23, 2006 5:07 PM
To: users at gecode.org
Subject: Re: [gecode-users] Unexpected propagation/search behaviour
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);
}
More information about the gecode-users
mailing list