[gecode-users] getting all solutions + interrupting gecode

Marco Correia marco.v.correia at gmail.com
Fri Dec 5 13:11:46 CET 2008


hi!

Q1:

I have a problem for which I want to get all solutions. I have departed from 
one of the examples, but now I'm subclassing from the object Space directly. 
I have the feeling I'm not doing things right:

class MyProblem : public Space 
{ /* ... */}

int
main(int argc, char* argv[]) 
{
   MyProblem* t = new MyProblem(args);
   d = new DFS<MyProblem>(t);
   while (t != NULL)
   {
   	//t = d->next();	// with only this, it does not seem to release memory
	TestLinear* n = d->next();
        delete t;	// hum....
        t = n;
   }
   return 0;
}

Q2:

I'm registering a signal before the 'new MyProblem' line, to make gecode quit 
when I press Ctrl+C and show me the search statistics:

signal(SIGINT, atExit);

In the function atExit I use the methods from t and d (which I make global 
variables) to get the statistics. The last line of this function is a system 
call to exit(0).

It seems to work sometimes, but other times it just crashes on the exit(0). 
Obviously I'm forgeting something, so I guess the solution to this is simple. 
Otherwise I can provide more details.


Thanks!
Marco

-- 
Marco Correia <mvc at netcabo.pt>




More information about the gecode-users mailing list