Hi everyone,
If anyone can give me a solution for these, I would appreciate it a lot.
Here is my code, the problem is in the last constraint
int m = ...;
int n = ...;
int l = ...;
int q = ...;
int e = ...;
range K = 1..m; // Set of Malt
range I = 1..n; // Set of Brewery
range J = 1..l; // Set of Distribution centers
range T = 0..q; // Set of Periods
range C = 1..e; //set of levels of capacity
// Parameters
float c_prime[K][I] = ...; // Transportation cost from malt plant K to brewery I
float c [I][J] = ...; // Transportantion cost from brewery I to distribution center J
float p = ...; // production cost of beer
float r = ...; //revenue per million litres of sold beer
float f [I][C]=...;//opening-closing cost of brewery i at level c
float op [I] =...;//operational cost of brewery i
int u_prime [K] = ...; // Capacity of malt plant K
int u [I][C] = ...; // Capacity of Brewery I at level c
int d [J][T] = ...; // Demand of customer J in period t
float YD = ...; // Domestic yield Malt
float YI = ...; // International yielt Malt
// Variables
dvar float+ Y [K][I][T]; // Amount of Malt from plan K to Brewery I in period t
dvar float+ X [I][J][T]; // Amount of beer from Brewery I to Distribution center J in period t
dvar boolean Z [I][T]; //Binary decision variable, true if brewery i is open at period t, false otherwise.
dvar boolean A [I][C][T]; //Binary decision variable, true if brewery i is open at level C at period t, false otherwise.
execute
{
cplex.tilim = 1800;
}
maximize sum (j in J, i in I, t in T:t>0) ((r-p)*X[i][j][t]) - (sum (k in K,i in I, t in T:t>0)
c_prime[k][i] * Y[k][i][t] + sum (i in I, j in J, t in T:t>0) c[i][j] * X [i][j][t])
- (sum (i in I, t in T:t>0, c in C) f[i][c]*(1-A[i][c][t-1])*A[i][c][t]
+ sum (i in I, t in T:t>0, c in C) op[i]*Z[i][t]);
subject to {
forall (k in K, t in T:t>0){
sum (i in I) Y[k][i][t] <= u_prime [k];
}
forall (i in I, t in T:t>0){
sum (j in J) X[i][j][t] == sum (k in K: k < 3) Y[k][i][t] * YD + sum (k in K: k == 3) Y[k][i][t] * YI ;
sum (j in J) X[i][j][t] <= sum (c in C) A[i][c][t]*u [i][c];
}
forall (i in I, t in T){
sum (c in C) A[i][c][t]<=1;
Z[i][t]== sum (c in C:c>1&&c<5) A[i][c][t];
}
A[1][2][0]==1;
A[2][2][0]==1;
A[3][1][0]==1;
A[4][1][0]==1;
A[5][1][0]==1;
forall (j in J, t in T:t>0){
sum (i in I) X[i][j][t] == d [j][t];
}
forall (i in I, cc in C:cc>0, t in T)
A[i][cc][t] > (sum (ccprime in C:ccprime<cc)A[i][ccprime][t+1]) ;
}
------------------------------
CH
------------------------------
#DecisionOptimization