The inventory constraint makes our model infeasible, we are unable to identify exactly why.

48 views
Skip to first unread message

sindre Eriksen

unread,
Mar 3, 2021, 5:47:37 AM3/3/21
to AMPL Modeling Language
The model works as intended as long as q0, q2 and q3 is commented out. q0 and q3 works as intended as long as q2 is commented out. When q2 is included, it calcluates the initial inventory as intended, but q0 returns either 0 or negative values. That is, it returns the negative values of D, indicating that "I[p,k,t-1] + A[p,k,t]" is not taken into account at all.

This is the code:
reset;
param P;
set J ordered;
set K ordered;
param T;

param VC{J,K,1..T};
param FC{J,K,1..T};
param D{1..P,K, 1..T};
param value {1..P,K};
param Zmax {J,K};
param Zmin{J};
param InventMax {1..P,K};
param Init{1..P,K};

var Y{J,K,1..T} binary;
var Z{1..P,J,K,1..T} >=0;
var I{1..P,K,1..T} >=0;
var A{1..P, K, 1..T} >=0;

maximize TotalCosts: sum{p in 1..P, j in J,k in K, t in 1..T} value[p,k]*Z[p,j,k,t]- sum{j in J, k in K,t in 1..T} (VC[j,k,t]+FC[j,k,t])*Y[j,k,t];#-sum{p in 1..P,t in 1..T,k in K} H[p,k]*I[p,k,t];


#s.t. q0 {p in 1..P,k in K,t in 2..T}:
#    I[p,k,t]=I[p,k,t-1] + A[p,k,t] - D[p,k,t];

#s.t. q2 {p in 1..P,k in K}:
#        I[p,k,1]=Init[p,k] + A[p,k,1] - D[p,k,1];   
       
#s.t. q3 {p in 1..P,k in K, t in 1..T}:
#        I[p,k,t]<=InventMax[p,k];

s.t. con90{p in 1..P, k in K, t in 1..T}: A[p,k,t] = sum{j in J} Z[p,j,k,t];


s.t. q4 {j in J, k in K, t in 1..T}:
        sum{p in 1..P} Z[p,j,k,t] <= Zmax[j,k]*Y[j,k,t];
       
s.t. q5 {j in J, k in K,t in 1..T}:
     sum{p in 1..P} Z[p,j,k,t] >= Zmin[j]*Y[j,k,t];   
     
s.t. q51 {p in 1..P, j in J, k in K,t in 1..T}:
     Z[p,j,k,t] <= D[p,k,t]*Y[j,k,t];        

s.t. q12 {k in K, t in 1..T}:
        sum {j in J} Y[j,k,t] <= 1;
       
s.t. q74 {t in 1..T}:
        sum {k in K} Y["ALPHA",k,t] <= 2;
       
s.t. q89 {t in 1..T}:
        sum {k in K} Y["BETA",k,t] <= 2;
       
s.t. q99 {t in 1..T}:
        sum {k in K} Y["GAMMA",k,t] <= 2;                       
                   

data;
param P := 3;
set J := ALPHA BETA GAMMA;
set K := Aalborg    Aabenraa    Copenhagen    Oslo    Bergen    Stockholm    Gothenburg    Stettin;
param T:= 52;

param value:
        Aalborg     Aabenraa    Copenhagen    Oslo    Bergen    Stockholm    Gothenburg    Stettin:=
1           0        122            126        130        0         131             129           112
2          129        129            133        136        145         138            136            0
3           0        0            151        154        163         156            154            0;

#Variable cost
param VC:=
[ALPHA,*,*] :  
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491    4491
Aabenraa    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888    4888
Copenhagen    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453    4453
Oslo        8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513    8513
Bergen        10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854    10854
Stockholm    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799    13799
Gothenburg    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870    6870
Stettin        8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437    8437


[BETA,*,*] :
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853    3853
Aabenraa    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199    4199
Copenhagen    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821    3821
Oslo        7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361    7361
Bergen        9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402    9402
Stockholm    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971    11971
Gothenburg    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928    5928
Stettin        7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295    7295



[GAMMA,*,*] :
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330    3330
Aabenraa    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631    3631
Copenhagen    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301    3301
Oslo        6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385    6385
Bergen        8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164    8164
Stockholm    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401    10401
Gothenburg    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137    5137
Stettin        6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328    6328;


# Fixed costs
param FC:=

[ALPHA,*,*] :  
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320    1320
Aabenraa    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300    1300
Copenhagen    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100    4100
Oslo        2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100
Bergen        850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850
Stockholm    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000    3000
Gothenburg    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600    2600
Stettin        2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250    2250



[BETA,*,*] :
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130
Aabenraa    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100
Copenhagen    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250
Oslo        1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800
Bergen        850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850
Stockholm    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400
Gothenburg    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100    2100
Stettin        1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650


[GAMMA,*,*] :
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130    1130
Aabenraa    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100    1100
Copenhagen    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250    3250
Oslo        1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800    1800
Bergen        850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850    850
Stockholm    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400    2400
Gothenburg    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900    1900
Stettin        1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650    1650;



# Demand
param D:=
[1,*,*] :  
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
Aabenraa    183    103    342    163    253    230    221    229    153    316    155    262    153    102    132    327    221    635    218    318    292    259    256    373    498    304    427    227    79    210    392    479    214    466    188    379    419    375    260    74    0    712    868    937    0    0    53    343    474    677    355    104
Copenhagen    292    950    705    1210    1449    1575    878    1085    1022    1221    1591    1468    303    473    958    890    2024    2081    1243    1379    1219    2007    2051    1374    1356    2591    1254    2757    447    445    614    1131    1215    1236    995    1044    292    2254    1353    1744    2457    1741    1014    1812    3437    2355    2605    942    1599    1116    2165    151
Oslo        475    430    433    976    626    1171    948    1054    1234    921    837    1270    375    352    1323    1034    820    885    925    1715    1180    981    1941    1043    1096    2567    1622    902    126    286    927    1031    1157    1205    1666    1356    1886    1422    1453    891    1755    1852    1600    2147    1329    1538    1403    580    682    1049    1815    118
Bergen        0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
Stockholm    322    380    475    590    703    602    907    864    715    671    708    491    201    400    1055    740    845    688    1226    1111    275    1020    395    1133    2270    1296    1047    1907    277    452    743    1265    382    567    431    1172    984    843    1251    0    1346    1595    1580    1280    952    1254    594    863    746    718    436    30
Gothenburg    600    530    922    612    847    830    1152    1056    1246    1218    1860    1538    479    550    1252    1475    1438    1274    887    1838    1027    2005    1167    1519    1512    1850    2011    1776    208    267    1205    1794    207    2111    1458    1209    1712    2036    1914    1358    2391    2009    1848    1402    2012    1837    1167    1012    1003    1545    883    213
Stettin        205    207    522    586    719    891    673    810    664    644    849    673    146    349    570    1106    929    595    633    1408    719    1204    1355    590    1102    579    807    1002    775    227    546    1256    634    636    397    961    851    509    1318    1248    1077    952    852    968    1288    2169    0    194    873    1543    885    85


[2,*,*] :  
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        177    295    351    298    427    386    81    354    402    178    0    265    190    158    571    596    529    110    543    845    332    444    522    568    248    0    639    469    214    292    217    187    0    547    577    0    674    363    463    587    310    440    538    399    500    411    416    294    600    368    524    137
Aabenraa    97    118    118    175    216    120    117    116    97    158    158    306    80    177    40    437    149    117    76    339    225    203    216    179    140    308    329    358    216    199    178    230    250    58    182    251    179    77    130    98    133    237    256    258    198    122    135    254    257    192    121    40
Copenhagen    205    187    282    120    218    405    167    0    279    325    47    219    319    214    140    254    334    546    743    147    261    338    306    305    342    292    368    241    315    187    143    284    235    495    117    266    302    421    528    230    497    272    357    347    307    355    308    454    167    250    233    98
Oslo        106    263    195    194    88    85    237    153    108    234    198    265    88    133    283    158    0    107    228    243    109    299    282    281    195    250    263    156    193    237    133    152    240    0    0    0    123    196    216    235    148    150    263    0    359    510    63    148    333    0    154    65
Bergen        240    276    147    148    611    298    529    233    456    395    0    328    124    311    269    260    273    149    350    320    271    530    437    712    558    664    386    175    333    329    389    650    258    344    501    493    408    442    676    379    294    514    563    0    423    269    486    410    486    448    173    785
Stockholm    195    246    198    265    97    382    100    96    430    368    513    202    187    286    265    119    145    321    199    515    254    299    174    556    164    437    445    432    319    213    308    341    310    334    222    299    196    73    501    215    445    362    315    366    433    266    378    912    233    198    121    0
Gothenburg    149    94    216    332    455    123    237    138    276    322    94    165    191    232    23    263    176    163    226    557    289    516    380    360    298    426    434    241    221    212    259    317    204    476    287    367    359    306    531    317    436    486    264    125    667    120    361    535    409    345    234    22
Stettin        0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0


[3,*,*] :
            1    2    3    4    5    6    7    8    9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24    25    26    27    28    29    30    31    32    33    34    35    36    37    38    39    40    41    42    43    44    45    46    47    48    49    50    51    52:=
Aalborg        0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
Aabenraa    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
Copenhagen    181    448    840    682    476    638    402    675    482    475    584    730    172    294    359    404    528    569    267    511    331    579    457    385    320    396    393    351    241    209    245    376    146    202    301    248    519    491    559    1173    377    389    475    0    906    462    452    574    531    82    1024    61
Oslo        133    159    424    508    509    572    469    376    369    459    517    388    237    429    301    208    507    473    242    271    231    269    298    404    263    184    271    259    208    214    368    350    163    131    0    321    347    496    409    314    500    328    0    534    282    641    488    435    459    548    691    102
Bergen        535    557    1340    941    1446    1575    945    1573    1374    641    1800    1420    396    437    1003    1192    991    655    434    1354    613    1237    1393    675    1048    836    1305    484    632    555    853    350    531    792    809    522    1354    684    1163    828    571    1435    960    630    617    632    632    382    1470    1689    847    29
Stockholm    316    399    279    411    216    380    395    427    508    524    549    536    194    138    372    498    447    203    263    200    248    375    318    855    777    121    251    610    345    253    335    395    296    317    261    128    650    225    277    183    0    446    368    442    413    591    319    809    347    476    335    86
Gothenburg    352    480    613    930    964    603    724    710    936    962    860    656    329    160    678    792    1105    950    439    710    569    995    433    805    797    277    668    376    215    125    308    595    193    679    354    162    518    480    779    496    515    515    371    502    461    934    747    697    615    951    925    127
Stettin        0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0;


param Zmax:
      Aalborg     Aabenraa    Copenhagen     Oslo    Bergen     Stockholm     Gothenburg     Stettin:=
ALPHA 2800            2200        4100     4100     3400        2900        4100      600       
BETA  2400            2200        2900     2900     2700        2500        2900      2800       
GAMMA 2300            2000        2300     2300     2300        2300        2300      2300;

param Zmin:=
ALPHA    500
BETA    400
GAMMA    300;

param InventMax:
        Aalborg     Aabenraa    Copenhagen    Oslo    Bergen    Stockholm    Gothenburg    Stettin:=
1           0        1200        2100    1800       0      1600             2100      2700
2          2100        700            1050    1000      900       800            1000        0
3           0         0            1050    1300     1800       700            1000        0;


param Init:
        Aalborg     Aabenraa    Copenhagen    Oslo    Bergen    Stockholm    Gothenburg    Stettin:=
1           0        1026        1292    543          0             1057             1492      1798
2          1736        571            1038    747         830       745            753           0
3           0         0            1022    1014     1793       568            844           0;


option solver gurobi;
solve;

AMPL Google Group

unread,
Mar 4, 2021, 12:34:03 PM3/4/21
to AMPL Modeling Language
I confirmed that your problem is infeasible, and that it becomes feasible when the q0 constraints are dropped.

There is no single easy way to troubleshoot infeasibility. Determining and fixing the cause of infeasibility will probably require some more study of the model. Also, even if the model is correct, there may be no feasible solution for the particular data that is given. Examining the solution after the "solve" does not help, since solvers do not return a valid solution when the problem infeasible. It is possible to suggest some good ways to start looking for the cause of infeasibility, however.

As an initial step, it is often helpful to use AMPL's expand command to see see whether AMPL generated the constraints that you expected. By itself, expand; shows all of the constraints. If there are many of them, you can use, for example, expand C1; to expand all of the constraints that have a particular name. Also you can write, for instance, expand >listing.txt; or expand C1 >listing.txt; to send all of the output to the file listing.txt.

You can also continue using AMPL's drop and restore commands to narrow your search for the cause of the infeasibility. If you drop some constraints and the resulting problem is still infeasible, then you don't need to consider the dropped constraints in looking for the cause of infeasibility. By trying a series of drops, you may be able to determine that the infeasibility is being caused by only a small subset of the constraints.

To get more help with diagnosing the infeasibility, you can ask any of the popular MIP solvers (CPLEX, Gurobi, Xpress) to compute an irreducible infeasible subset. For more on this topic, search "IIS" at https://groups.google.com/group/ampl, and also see the discussion of "infeasibility diagnosis" in chapter 14 of the AMPL book (https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf#page=25).


--
Robert Fourer
am...@googlegroups.com
{#HS:1442393623-102197#}

sindre Eriksen

unread,
Mar 5, 2021, 5:07:56 AM3/5/21
to AMPL Modeling Language
Thank you for the answer Robert.
We concluded that the infeasibility must lie in "q0", since the model becomes feasible when we drop it. Is this the correct way of thought, or can the infeasibility lie elsewhere?

AMPL Google Group

unread,
Mar 6, 2021, 10:42:43 AM3/6/21
to AMPL Modeling Language
You can conclude that the q0 constraints are helping to make the problem infeasible. But the cause of infeasibility also involves other constraints. You can see that by running the following test, which drops the objective and all of the constraints except q0, then uses the solver to find a solution that is feasible for the q0 constraints:

ampl: drop all;
ampl: restore q0;
ampl: solve;
Gurobi 9.1.1: optimal solution; objective 0
Objective = find a feasible point.


What you want to do is to find a small subset of constraints that are infeasible. This subset will include q0, but also some others. See my previous suggestion for two ways to do this: by using the drop and restore commands, or by using the "irreducible infeasible subset" feature of Gurobi.


--
Robert Fourer
am...@googlegroups.com
{#HS:1442393623-102197#}
On Fri, Mar 5, 2021 at 10:08 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thank you for the answer Robert.
We concluded that the infeasibility must lie in "q0", since the model becomes feasible when we drop it. Is this the correct way of thought, or can the infeasibility lie elsewhere?

On Thu, Mar 4, 2021 at 5:33 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I confirmed that your problem is infeasible, and that it becomes feasible when the q0 constraints are dropped.

There is no single easy way to troubleshoot infeasibility. Determining and fixing the cause of infeasibility will probably require some more study of the model. Also, even if the model is correct, there may be no feasible solution for the particular data that is given. Examining the solution after the "solve" does not help, since solvers do not return a valid solution when the problem infeasible. It is possible to suggest some good ways to start looking for the cause of infeasibility, however.

As an initial step, it is often helpful to use AMPL's expand command to see see whether AMPL generated the constraints that you expected. By itself, expand; shows all of the constraints. If there are many of them, you can use, for example, expand C1; to expand all of the constraints that have a particular name. Also you can write, for instance, expand >listing.txt; or expand C1 >listing.txt; to send all of the output to the file listing.txt.

You can also continue using AMPL's drop and restore commands to narrow your search for the cause of the infeasibility. If you drop some constraints and the resulting problem is still infeasible, then you don't need to consider the dropped constraints in looking for the cause of infeasibility. By trying a series of drops, you may be able to determine that the infeasibility is being caused by only a small subset of the constraints.

To get more help with diagnosing the infeasibility, you can ask any of the popular MIP solvers (CPLEX, Gurobi, Xpress) to compute an irreducible infeasible subset. For more on this topic, search "IIS" at https://groups.google.com/group/ampl, and also see the discussion of "infeasibility diagnosis" in chapter 14 of the AMPL book (https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf#page=25).


--
Robert Fourer
am...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages