[gecode-users] how to explore domain variables with Gist
Guido Tack
tack at ps.uni-sb.de
Tue May 8 18:55:04 CEST 2007
Hi!
Alberto Delgado wrote:
> I downloaded the source code and compiled gecode gist [...]
> Now i'd like to explore the variables in each nodes, i mean the
> domain of the variables. I tried double-click and it didn't work
> and the menu displayed by right-click doesn't include any action
> related with the variables.
The file qtgist/gist.hh defines a class Gecode::Gist::Inspector. You
have to inherit from this class, and override the virtual function
void inspect(Space* s). The you create an object of your new
inspector and pass it to the explore function. The inspector is then
registered with gist, and double-clicking a node will invoke the
inspect function. You just have to static_cast the Space* into the
specific type of your constraint problem, and output the variables in
any way you like.
A simple example (not tested, but you'll get the idea):
using namespace Gecode;
class A : public Space {
public:
IntVarArray x;
// the rest of your code defining your constraint problem
};
class I : public Gist::Inspector {
public:
virtual void inspect(Space* s) {
A* a = static_cast<A*>(s);
for (int i=0; i<a.x.size(); i++) std::cout << a.x[i] << std::endl;
}
};
int main(void) {
A a = new A();
I i = new I();
explore(a, i);
return 0;
}
Cheers,
Guido
--
Guido Tack
Programming Systems Lab, Saarland University, Germany
http://www.ps.uni-sb.de/~tack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20070508/f5e75fff/attachment.htm>
More information about the gecode-users
mailing list