# Ampl erorr in phase I ITERATION

**URL:** <https://discuss.ampl.com/t/ampl-erorr-in-phase-i-iteration/1180>\
**Category:** New to AMPL\
**Created:** [August 17, 2024, 11:58am UTC](https://discuss.ampl.com/t/ampl-erorr-in-phase-i-iteration/1180 "2024-08-17T11:58:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibronuhu3434](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/ibronuhu3434/32/813_2.png) [@ibronuhu3434](https://discuss.ampl.com/u/ibronuhu3434)\
**Post date:** [August 17, 2024, 11:58am UTC](https://discuss.ampl.com/t/ampl-erorr-in-phase-i-iteration/1180/1 "2024-08-17T11:58:50Z")

</div>

hello, am having problems with my phase I iteration if someone could help me,here are my model, data and run

```auto
### SUBPROBLEM ###

set COLL; # collecton points
set DIS; # disposal sites
set CON; # conveyance

param supply {COLL,CON}>= 0; # amount available at collections
param demand {DIS,CON} >= 0; # amount required at disposals
  
   check {k in CON}:
   sum {i in COLL} supply[i,k] = sum {j in DIS} demand[j,k];
   
param price_convex;# dual price on convexity constr
param price{COLL,DIS} <= 0.000001; # dual price on transport limit
param cost {COLL, DIS, CON} >= 0; # transport cost per unit
var Trans{COLL,DIS,CON} >= 0; # unit to be transported

minimize Artif_Reduce_cost:
            sum{i in COLL,j in DIS,k in CON}(cost[i,j,k]-price[i,j])*Trans[i,j,k]-price_convex;
minimize Reduce_cost:
           sum{i in COLL,j in DIS,k in CON}(cost[i,j,k]-price[i,j])*Trans[i,j,k]-price_convex;
subject to Supply {i in COLL,k in CON}:
              sum{j in DIS}Trans[i,j,k]= supply[i,k];
subject to Demand {j in DIS,k in CON}:
              sum{i in COLL} Trans[i,j,k]=demand[j,k];

### MASTER PROBLEM ###

param limit{COLL,DIS} >= 0; # max transported on each link
param nPROP integer >= 0;
param Prop_Transport{COLL,DIS,1..nPROP} >= -0.000001;
param Prop_Cost{1..nPROP} >= 0; # for each proposal from subproblem:
                                      # amount it transports over each link,and its cost
var Wieght{1..nPROP} >= 0;
var Excess>= 0;
minimize Artificial: Excess;
minimize Total_Cost:
        sum{k in 1..nPROP}Prop_Cost[k]*Wieght[k];
subject to Multi{i in COLL,j in DIS}:
                                  sum{k in 1..nPROP}Prop_Transport[i,j,k]*Wieght[k]-Excess<= limit[i,j];
subject to convex:sum{k in 1..nPROP}Wieght[k] = 1;

### PHASE III PROBLEM ###

param opt_transport{COLL,DIS} >= -0.000001;

minimize Opt_cost:
          sum{i in COLL,j in DIS,k in CON}cost[i,j,k]*Trans[i,j,k];
subject to Opt_Multi{i in COLL,j in DIS}:
          sum{k in CON}Trans[i,j,k] = opt_transport[i,j];

```

```auto
data;

set COLL:= C1 C2 C3 C4 C5 C6 C7 C8 C9 C10;
set DIS:= D1 D2;
set CON:= t1 t2 t3 t4 t5;

param supply (tr): C1 C2 C3 C4 C5 C6 C7 C8 C9 C10:=

t1 20 10 15 30 40 50 60 70 80 90
t2 10 20 30 40 50 60 70 50 60 30
t3 30 40 50 20 10 70 80 90 100 102
t4 50 60 70 20 30 30 40 50 60 90
t5 70 80 90 20 30 40 50 60 70 80;

param demand (tr):
        D1 D2 :=
 
t1 30 50
t2 40 60
t3 60 70 
t4 80 90
t5 20 30;

param limit default 625;

param cost:=

[*,*,t1]: D1 D2 :=

C1 200 300
C2 300 400

[*,*,t2]: D1 D2 :=

C3 100 200
C4 300 400

[*,*,t3]: D1 D2:=

C5 500 200
C6 400 300

[*,*,t4]: D1 D2 :=

C7 400 500
C8 700 600

[*,*,t5]: D1 D2 :=

C9 200 100
C10 300 400;

```

```auto
ampl: model lan.mod;
ampl: data lan3.dat;

ampl: let nPROP:=0;
ampl: let price_convex:=1;
ampl: let {i in COLL, j in DIS}price[i,j]:=0;

ampl: option solver minos;
ampl: option omit_zero_rows 1;
ampl: option display_1col 10;
ampl: option display_eps .000001;

ampl: problem master: Artificial, Wieght, Excess, Multi, convex;
ampl: problem sub: Artif_Reduce_cost, Trans, Supply, Demand;

ampl: repeat {printf "\nPHASE I -- ITERATION %d\n\n", nPROP + 1;
repeat { ? ampl: solve sub;
repeat { ? ampl: printf "\n";
repeat { ? ampl: display Trans;
repeat { ? ampl: if Artif_Reduce_cost >=- 0.00001 then {printf "\n ***NO FEASIBLE SOLUTION*** \n";

if ... then { ? ampl: break;
if ... then { ? ampl: }
if ... then {...} ? ampl: else { let nPROP:=nPROP+1;
else { ? ampl: let {i in COLL, j in DIS}Prop_Transport[i,j,nPROP]:= sum{k in CON}Trans[i,j,k];
else { ? ampl: let Prop_Cost[nPROP]:=sum{i in COLL, j in DIS, k in CON}cost[i,j,k]*Trans[i,j,k];
else { ? ampl: };

repeat { ? ampl: solve master;
repeat { ? ampl: printf"\n";
repeat { ? ampl: display Wieght;
repeat { ? ampl: display Multi.dual;
repeat { ? ampl: display{i in COLL, j in DIS}limit[i,j]-sum{k in 1..nPROP}Prop_Transport[i,j,k]*Wieght[k];
repeat { ? ampl: if Excess <= 0.00001 then break;

if ... then {...} ? ampl: else {
else { ? ampl: let {i in COLL, j in DIS}price[i,j]:=Multi[i,j].dual;
else { ? ampl: let price_convex:= convex.dual;
else { ? ampl: };

repeat { ? ampl: };

PHASE I -- ITERATION 1

check['t1'] at line 10 of lan.mod fails:
check{k in CON} : sum{i in COLL} supply[i,k] == sum{j in DIS} demand[j,k];

check['t2'] at line 10 of lan.mod fails.
check['t3'] at line 10 of lan.mod fails.
check['t4'] at line 10 of lan.mod fails.
check['t5'] at line 10 of lan.mod fails.

Error executing "solve" command:
error processing objective Artif_Reduce_cost:
no value for cost['C1','D1','t2']

ampl:

```

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [August 19, 2024, 7:16pm UTC](https://discuss.ampl.com/t/ampl-erorr-in-phase-i-iteration/1180/2 "2024-08-19T19:16:33Z")

</div>

Your model has a “check” statement:

```auto
check {k in CON}:
   sum {i in COLL} supply[i,k] = sum {j in DIS} demand[j,k];

```

When you get this error message,

```auto
check['t1'] at line 10 of lan.mod fails:
check{k in CON} : sum{i in COLL} supply[i,k] == sum{j in DIS} demand[j,k];

```

it means that, for your data, the check is failing, because `sum{i in COLL}` `supply[i,'t1']` does not equal `sum{j in DIS}` `demand[j,'t1']`. Subsequent error messages say that there is the same error for `'t2'`, `'t3'`, etc. You should either remove the “check” statement, or fix the data so that the check conditions are satisfied.

You are also seeing this error:

```auto
Error executing "solve" command:
error processing objective Artif_Reduce_cost:
no value for cost['C1','D1','t2']

```

This is because objective `objective Artif_Reduce_cost` refers to `cost['C1','D1','t2']`, but there is no value for `cost['C1','D1','t2']` in your data.

To avoid having to type all of the AMPL commands many times, you should put them into a file like `lan.run` attached. Then you only have to type `include` `lan.run` to execute all of the commands. (I see only “PHASE I” mentioned, so maybe this is only the first part of the file.)

[lan.run](https://discuss.ampl.com/uploads/short-url/bziivERzd3VKhAhl6oiEUHoj8xx.run) (1.1 KB)
