Hi Andrea,

 

This is due to recomputation. Please check Tip 8.4 whether this explains the 
behaviour.

 

Cheers

Christian

 

--

Christian Schulte, Professor of Computer Science, KTH, www.gecode.org/~schulte/

 

From: users-boun...@gecode.org [mailto:users-boun...@gecode.org] On Behalf Of 
Andrea Peano
Sent: Tuesday, September 23, 2014 1:23 PM
To: users@gecode.org
Subject: [gecode-users] Strange branching behaviour when using FunctionBrancher

 

Hello,

 

I've implemented a search strategy by splitting the search into three levels. I 
think the code may explain better this strategy.

 

 

void MyModel::post(Space& home)

{

static_cast<MyModel&>(home).second_level();

}

 

void MyModel::second_level()

{

status();

 

//do something with the partial solution
//print "second level"

branch(*this, BoolBranchDirection, INT_VAL_MIN());

branch(*this, post2);

}

 

void MyModel::post2(Space& home)

{

static_cast<MyModel&>(home).third_level();

}

 

void MyModel::third_level()

{

if(BoolBranchDirection.val()==0)
{
//print third level left
//left branch behaviour (install further branches)
}
else
{
//print third level right
//right branch behaviour (install further branches)
}

}

 

Imagine now we are fixing the partial solution before the "post" calling, so 
the solver goes only once into the "post" function (and it's confirmed by GIST).

 

The strange fact is that "second_level" is called more than once! Instead I 
expect one call for "second_level" and two calls for "third_level", which 
executes two different paths of the code.

 

These are the prints I read:

second level

third level left

second level

third level right

second level

third level right

 

But I expected:

second level

third level left

third level right

 

Can you clarify this behaviour please?

 

Furthermore, I experienced that I need to call "status()" within the second 
level, to ground some variables I expected to be already ground. Is this normal?

 

I'm using Gecode 4.2.1

 

Thanks,

Andrea

 

 

-- 

 

Andrea Peano - PhD student

Department of Engineering - University of Ferrara

Tel: +39 0532 97 4827

_______________________________________________
Gecode users mailing list
users@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to