[gecode-users] posting LinExpr

Stanimir Dragiev stanio at cs.tu-berlin.de
Thu Feb 14 11:59:37 CET 2008


Hello,

I have some irritating experience with posting a LinExpr

=== Short:
The returned by LinExpr::post variable has different bounds
than expected.



=== Long:

1.  Background

I have a functon like this:

=-=-=-=-=-=Begin
IntVar
Constraints::get_variable_difference(Solver *space, IntVar& var1, int var2 ){

        return abs(space, post(space, var1 - var2, ICL_DOM), ICL_DOM);
}
=-=-=-=-=-=End

The variables returned by it are intended  to be stored in
an IntVarArray and then  I can obtain a variable holding the
total difference like this:
=-=-=-=-=-=Begin
linear(space, all_diffs,  IRT_EQ, total_diff) )
=-=-=-=-=-=End

And I can *after that* constrain the total_diff 
in the constrain() function (for BAB search).

So I consider this whole process to be kind of query, not
modifying the meaningful vars in the space, i.e. I
do not expect the added variables to impact solvability of
the space. (total_diff has initially the domain [0, int_max]
and the sum over all_diffs is not more than 1000)

The problem is that while filling the all_diffs array, after
some iterations, the space is reported to have status
SS_FAILED. Precisely, it gets failed, after the first
invocation of get_variable_difference() with var2!=0.

2. Problem

In a debugger session I found out, that the invocation:
=-=-=-=-=-=Begin
get_variable_difference(space, var1, 64 );
=-=-=-=-=-=End
where the domain of var1 is {0, 64}, the posting 
post(space, var1 - var2, ICL_DOM) returns an IntVar with
domain [64, 128], while I expect [-64, 0].

(Other invocation with var1={64} and var2=64 resulted in
{128}, while expecting {0} )

I took a look at  the definition of LinExpr::post in
http://www.gecode.org/gecode-doc-search-1.3.1/lin-expr_8cc-source.html#l00074
and I noticed, that the doubles min and max are both
initialized to sign*-c, which in my case means min=max=-(-64)=64 .
Adding the bounds of my var1 to this really results in the
returned variables. Is this correct?
The following Int::Linear::post in line 94 could explain the
failing of the space, since it is in my opinion really not
satisfiable. 

Do you see some problem with the code?
There might be some issue with domain consistency and posting
linear expressions?


Thanks a lot for your suggestions.


cheers
stanio




More information about the gecode-users mailing list