[gecode-users] Unexpected propagation/search behaviour

Christian Schulte schulte at imit.kth.se
Mon Jan 23 10:40:57 CET 2006


This will actually be most likely the cause for ypur problems. Not only is
it dangerous to not check for the status but actually in your case the very
fact that failure has been dected gets lost!

Christian

--
Christian Schulte, http://www.imit.kth.se/~schulte/ 

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Mikael 'Zayenz' Lagerkvist
Sent: Monday, January 23, 2006 7:35 AM
To: Lars Otten
Cc: users at gecode.org
Subject: Re: [gecode-users] Unexpected propagation/search behaviour


Hi,

On 1/23/06, Lars Otten <ottenl at student.chalmers.se> wrote:
> propagate(Space* home) {
>   for (int i=0; i<n; ++i) {
>     //... do stuff for x and y
>     if (z[i].assigned() && <z[i] not yet treated> ) {
>       //... some preparations, like creating IdxView instances
>       Element::ViewDom<IntView,IntView>::post(home,z,z.size(),x[i],z[i]);
>       Element::ViewDom<IntView,IntView>::post(home,z,z.size(),y[i],z[i]);
>     }
>   }
>   //...
> }

I have one comment on the above code. When calling the post-methods, it is
very important to always check the return-value for possible failure. The
code should look something like the following.

   if (z[i].assigned() && <z[i] not yet treated> ) {
     //... some preparations, like creating IdxView instances
     if(Element::ViewDom<IntView,IntView>::post(home,z,z.size(),x[i],z[i])
== ES_FAILED)
       return ES_FAILED;
     if(Element::ViewDom<IntView,IntView>::post(home,z,z.size(),y[i],z[i])
== ES_FAILED)
       return ES_FAILED;
   }

When a failure is detected, the space may no longer be in a consistent
state. Therefore it is important to stop computing with it.

Cheers,
Mikael

--
Mikael 'Zayenz' Lagerkvist, http://www.imit.kth.se/~zayenz/

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





More information about the gecode-users mailing list