[gecode-users] sqrt function

Jaroslav Mlejnek mum.jmlejnek at post.cz
Fri Apr 4 00:09:38 CEST 2008


You are welcome :-)

Can you tell me a date when will be new release of Gecode with this function 
fixed? Or can I download fixed files from (for example) some svn? Sqrt 
function is very important in computing my objective function.

Thanks a lot, I have a great regard for your work.

Jarda

----- Original Message ----- 
From: Christian Schulte
To: 'Jaroslav Mlejnek' ; users at gecode.org
Sent: Thursday, April 03, 2008 11:15 PM
Subject: RE: [gecode-users] sqrt function


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
 





More information about the gecode-users mailing list