[gecode-users] usage of abs() constraint

Stanimir Dragiev stanio at cs.tu-berlin.de
Mon Oct 15 21:53:08 CEST 2007


Hello to all on the list!

I was pretty frustrated, that I couldn't get following to work:
---- code ---
//init var_a, var_b
IntVar abs_diff(space, 0, MAX_DIFF);
IntVar signed_diff = post(space, var_a -  var_b);
abs( space, signed_diff, abs_diff);
---- end ---

But I found an example  in the gecode example models using abs, and I turned
it into:

---- code ---
//init var_a, var_b
IntVar abs_diff(space, 0, MAX_DIFF);
abs_diff =  post(space,
		abs(space,
			minus(space, var_a, var_b, 
			ICL_DOM), 
		ICL_DOM), 
	ICL_DOM);
---- end ---


The latter one does what I expect, while the first leaves abs_diff with it's
original bounds: 0 to MAX_DIFF.

Now I'm a little more frustrated than before, since I don't understand what is
going on :o)

Is it not expected, that both behave the same way?

--
cheers
stanio





More information about the gecode-users mailing list