Breaking a repeat loop

213 views
Skip to first unread message

enhany75

unread,
Feb 12, 2009, 1:13:54 PM2/12/09
to AMPL Modeling Language
I am using the break command to terminate a repeat loop. The problem
is that the loop is terminated for some problem instances and not for
others even when the break condition is satisfied (deviation_2 =
Alpha ). I spent too much time to find the reason for that but I
couldn't. Could you please help.

Here is the code:

repeat {
for {j in t1} {let Lj_value[j] := Lj[j];}
for {k in t2} {let Lk_value[k] := Lk[k];}
for {j in t1, k in t2} {let Ljk_value[j, k] := Ljk[j,k];}
solve sub_problem;
if sub_problem.result= "infeasible" then {
let nsoln:= nsoln +1;
for {j in t1} {let Ljinf[nsoln,j] := Lj[j];}
for {k in t2} {let Lkinf[nsoln,k] := Lk[k];}
}
else if sub_problem.result = "solved" then {
let nsoln2:= nsoln2 +1;
for {j in t1} {let Ljm[j, nsoln2] := Lj[j];}
for {k in t2} {let Lkm[k, nsoln2] := Lk[k];}
for {j in t1, k in t2} {let Ljkm[j, k, nsoln2] := Ljk[j,k];}
for {j in t1} {let Lamba[j, nsoln2]:= Lj_values[j].dual;}
for {k in t2} {let Mue[k, nsoln2]:= Lk_values[k].dual;}
for {j in t1, k in t2} {let Gama[j,k,nsoln2]:= Ljk_values[j,k].dual;}
let deviation[nsoln2]:= deviation_2;
display deviation_2;
display Alpha;
if deviation_2 = Alpha then break;
}
if nsoln2 = 0 then {solve master_problem_feasible;
if master_problem_feasible.result= "infeasible" then break;}
else if nsoln2 > 0 then {solve master_problem;
if master_problem.result= "infeasible" then break;}
}

Robert Fourer

unread,
Feb 12, 2009, 4:30:20 PM2/12/09
to am...@googlegroups.com, enhany75

The default setting for AMPL's "display" command is to show numerical values to
6 significant digits. So the first thing I would try is to place the command

option display_precision 0;

at the beginning of the script file. This special setting causes display to
show numerical values with the maximum possible precision. As a result it will
be possible to see whether deviation_2 and Alpha are really the same, or whether
they are merely the same when rounded to 6 places.

Bob Fourer
4...@ampl.com

enhany75

unread,
Feb 13, 2009, 9:48:56 AM2/13/09
to AMPL Modeling Language
It works, Thanks alot
> > }- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages