[gecode-users] sqrt function

Christian Schulte cschulte at kth.se
Thu Apr 3 23:15:21 CEST 2008


Hi Jaroslav,

 

I checked: it is a bug in sqrt (it was not incorrect but too weak)! So what
it does for sqrt(25) is that it  believes that it is between 4..5 ;-(

 

Unluckily, both the propagator and its test was buggy and cancelled each
other out;-) That's why this one escaped us.

 

The assertion you see is that you use val() on a variable not yet assigned
due to the bug.

 

I fixed it in the trunk.

 

Thank you!

Christian

 

--

Christian Schulte, www.ict.kth.se/~cschulte/

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Jaroslav Mlejnek
Sent: Thursday, April 03, 2008 7:50 PM
To: users at gecode.org
Subject: [gecode-users] sqrt function

 

Hi!

 

I am using C++ Gecode Library in my school project and I am very satisfied
with it. But I would like to use an arithmetic function "sqrt" and I think
it doesn't work well. In code:

 

 

defining CSP (x is class global, y is constructor local):

 

IntVar x (this, 0, Int::Limits::max), y (this, 0, Int::Limits::max);

rel(this, y, IRT_EQ, 25);

rel(this, x, IRT_EQ, Gecode::sqrt(this, y));

 

 

printing solution (like Gecode examples):

cout << x.val() << endl;

 

 

There is in printing solution method an assert (debug) error instead of
solution number 5. But when I use "similar" function "sqr", it works fine
(or as I expect), so the solution is 625.

 

Is this bug in sqrt function or sqrt function has some special way how to
use it? I am using Gecode since version 1.1.0, my current version is the
newest  2.1.1.

 

Thanks a lot for your answer,

 

Jaroslav Mlejnek

Faculty of Mathematics and Physics

Charles University, Prague

Czech Republic

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20080403/ab6d8adb/attachment.htm>


More information about the gecode-users mailing list