let error

22 views
Skip to first unread message

sahebe...@gmail.com

unread,
May 25, 2017, 4:27:30 PM5/25/17
to AMPL Modeling Language
Hi all,
What is the problem of this error?? please help me
I want to calculate of points average as follows:

for {i in VS}{
if (card (minn[i])>=1) then let S_minn[i]:={j in VCH : distance1[i,j] == min{ii in VS} distance1 [ii,j]};
let avg_x[i]:= (sum {Z in S_minn[i]} X_CH[Z]) / card(S_minn[i]);
let avg_y[i]:= (sum {Z in S_minn[i]} Y_CH[Z]) / card(S_minn[i]);}

S_minn[i] set:
set S_minn[1] := 1 9 10;
set S_minn[2] := 4 7 8;
set S_minn[3] := 2 3 6;
set S_minn[5] := 5;

But I do not why I received this error: Error at _cmdno 147 executing "let" command ,   can't compute 0/0 === >>>>>>>>  I never have zero value !!!

WBR

Robert Fourer

unread,
May 26, 2017, 1:08:22 PM5/26/17
to am...@googlegroups.com
Try adding some display statements like this:

display X_CH, Y_CH;
for {i in VS}{
if (card (minn[i])>=1) then let S_minn[i]:={j in VCH : distance1[i,j] == min{ii in VS} distance1 [ii,j]};
display S_minn[i];
let avg_x[i]:= (sum {Z in S_minn[i]} X_CH[Z]) / card(S_minn[i]);
let avg_y[i]:= (sum {Z in S_minn[i]} Y_CH[Z]) / card(S_minn[i]);
}

Probably you will see that S_minn[i] is empty for some i. In that case both the numerator (a sum over S_minn[i]) and the denominator are zero, which would be the cause of the error message.

If this explanation does not resolve the problem, then post all of the output from the AMPL run, including the display output and the complete error message. Also it may be helpful to attach your files.

Bob Fourer
am...@googleroups.com

=======

sahebe...@gmail.com

unread,
May 27, 2017, 4:41:39 PM5/27/17
to AMPL Modeling Language, 4...@ampl.com
Thanks for your answer but I have another question. How I can load a text file in AMPL ?
For example a file as follows:
 
      66.521174       0.254121
      57.580723      46.890115
      94.202156      81.408574
      36.352463      88.061383
       0.308876      67.185992
      75.559834      10.397898
      45.010262      42.761774

Robert Fourer

unread,
May 28, 2017, 12:02:54 AM5/28/17
to am...@googlegroups.com

sahebe...@gmail.com

unread,
May 28, 2017, 12:13:47 PM5/28/17
to AMPL Modeling Language
Thanks a lottt
Reply all
Reply to author
Forward
0 new messages