Hi,
> For the first question, one thing you must remember is to delete the
> original instance of the problem also. An easy way to write a loop
> that goes through all solutions is for example:
> MyProblem *root = new MyProblem();
> DFS<MyProblem> dfs(root);
> delete root;
> while (MyProblem *sol = dfs.next()) {
> // do something...
> delete sol;
> }
Just a technical note - this is quite error-prone, because throwing
exception or returning in "do something..." results in memory leaks.
A better way of doing this would be using auto_ptr (or shared_ptr), like
this:
typedef auto_ptr<MyProblem> APMyProblem;
APMyProblem root(new MyProblem());
DFS<MyProblem> dfs(root.get());
root.reset();
while(true) {
APMyProblem sol(dfs.next());
if ( !sol.get() )
break;
MyProblem& solution=*sol;
// do something...
}
Cheers,
Filip
_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users