Sqrt(0) problem

144 views
Skip to first unread message

Marqoos

unread,
Nov 16, 2005, 11:56:23 AM11/16/05
to AMPL Modeling Language
Hi. I'm begginer with AMPL. My problem is rather simple, number of
constraines and variables is about 10-12. The problem is, that I must
use sqrt function in constraines, but in first iteration it is sqrt(0).
Ampl solver can not obtaine derivitaive in this point (I guess so), I
get the communicate about failure error, and get no results. Is there
any possibility of avoiding this problem?
Regards.

Marqoos

trah...@gmail.com

unread,
Nov 17, 2005, 11:56:17 AM11/17/05
to AMPL Modeling Language
I tried AMPL to find sqrt(0) and it works fine.
param z;
let z:=sqrt(0);
display z;

AMPL displays z = 0.

Robert Fourer

unread,
Nov 17, 2005, 12:44:37 PM11/17/05
to Marqoos, AMPL Modeling Language

> From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of
> Marqoos
> Sent: Wednesday, November 16, 2005 10:56 AM
> To: AMPL Modeling Language
> Subject: [AMPL] Sqrt(0) problem
Try setting the initial values of your variables to something other than zero.
Initial values are discussed in section 18.4 of the AMPL book (2nd edition).

Bob Fourer
4...@ampl.com




Marqoos

unread,
Nov 17, 2005, 1:06:30 PM11/17/05
to AMPL Modeling Language
There is no need to evalueate derivate from parameters so for
parameters it always warks fine. Try something like this.

var y;
var x;

maximize hej:
y;

subject to up_and_down_and_left:
y <= sqrt(abs(x));

subject to right:
x <= 4;

solve;

display y;

Marqoos

unread,
Nov 17, 2005, 1:10:31 PM11/17/05
to AMPL Modeling Language
Thak you Robert I'll try, but AMPL book is in our university library
but it took ten days to get it (recall procedure). So usuwally I can
find some solutions faster. The efect is that I haven"t red it until
know. Maybe this time I will start the recall procedure.

Marqoos

unread,
Nov 25, 2005, 11:26:56 AM11/25/05
to AMPL Modeling Language
I thin i found much better way of this regularisation. I just added
"small number" to expresion under square root. 10e-8 fo example. And
now everything works fine, even if expresion tends to zero.

Reply all
Reply to author
Forward
0 new messages