[gecode-users] NaryUnion, infinite loop
Jean-Noël Monette
jean-noel.monette at it.uu.se
Thu Mar 29 10:56:00 CEST 2012
Hello,
Here is a new problem I came across with NaryUnion. As suggested by
Christian, I created a fresh region for every new NaryUnion, however I
ran into an infinite loop. Below is a minimal example. I located the
infinite loop inside the "two(I& i, J& j)" method of NaryUnion, and the
reason seems to be that, after the call to "RangeList* t = range(j)" in
the "else if" block (I unfortunately cannot give you line numbers as I
messed around with print statements), "i.c" and "t" point to the very
same RangeList (while they should not). I'm not expert enough to go
deeper/further...
Notice that this appears only when region2 is created in a block (in
real code, it would be inside a "for" or a "if"), however there is no
influence if it is actually used or not.
I guess it is again related to the Region implementation that is going
to change, but I think it is worth mentioning it anyway.
Jean-Noël
#include "gecode/driver.hh"
#include "gecode/iter.hh"
using namespace Gecode;
class MySpace:public Space {
public:
virtual Space* copy(bool share){return this;}
};
int main(int argc, char* argv[]){
MySpace home;
Iter::Ranges::Singleton dom0(3,3);
Iter::Ranges::Singleton dom1(1,1);
Region region1(home);
Iter::Ranges::NaryUnion u0;
{
Region region2(home);
u0 = Iter::Ranges::NaryUnion(region2,dom0);//or using region1
}
Iter::Ranges::NaryUnion u1(region1,u0,dom1); //loops forever
/*or
* Region region3(home);
* Iter::Ranges::NaryUnion u1(region3,u0,dom1);
*/
return 0;
}
More information about the users
mailing list