param n; param m; param scen; param p {i in 1..n, j in 1..m} := floor( Uniform(1,100) ); param P = max( max {v in 1..m} ( sum {k in 1..n} ( p[k,v] ) + min {k in 1..n} ( sum {q in 1..v-1} p[k,q] ) + min {k in 1..n} ( sum {q in v+1..m} p[k,q] ) ), max {k in 1..n} ( sum {v in 1..m} p[k,v] ) ); param TF {i in 1..4} := if ( i=1 or i=2 ) then 0.2 else 0.4; param DR {i in 1..4} := if ( i=1 or i=3 ) then 0.6 else 1.2; param dmin := P * ( 1 - TF[scen] - DR[scen] / 2 ); param dmax := P * ( 1 - TF[scen] + DR[scen] / 2 ); param d {i in 1..n} := floor( dmin + Uniform01() * ( dmax + 1 - dmin ) ); var x {i in 1..n, j in 1..n} binary; var E {j in 1..n} >= 0; var T {j in 1..n} >= 0; var D {j in 1..n, k in 1..m} >= 0; minimize Obj: sum {j in 1..n} ( E[j] + T[j] ); subject to R1 {j in 1..n}: T[j] >= D[j,m] - sum{i in 1..n} ( x[i,j] * d[i] ); R2 {j in 1..n}: E[j] >= sum{i in 1..n} ( x[i,j] * d[i] ) - D[j,m]; R3 {j in 1..n}: D[j,1] >= sum {i in 1..n} ( x[i,j] * p[i,1] ); R4 {j in 1..n, k in 2..m}: D[j,k] >= D[j,k-1] + sum {i in 1..n} ( x[i,j] * p[i,k] ); R5 {j in 2..n, k in 1..m}: D[j,k] >= D[j-1,k] + sum {i in 1..n} ( x[i,j] * p[i,k] ); R6 {j in 2..n, k in 1..m-1}: D[j,k] >= D[j-1,k+1]; R7 {j in 1..n}: sum {i in 1..n} x[i,j] = 1; R8 {i in 1..n}: sum {j in 1..n} x[i,j] = 1;