#mod
reset;
param T > 0, integer;
set IND := 1..T;
set END := 0..T+1;
param a >= 0;
param b >= a;
param c <= a;
param r >= 0;
param s >= 0;
param d {IND} >= 0;
var X {IND} >= 0, <= r;
var Y {IND} >= 0, <= s;
var Z {END} >= 0;
minimize COST: sum {i in IND} (a * X[i] + b * Y[i] + c * Z[i]);
subject to BAL {i in END}: Z[i-1]+X[i]+Y[i] = d[i]+Z[i];
subject to INIT0: Z[0] = 0;
subject to INITE: Z[4] = 0;
#Data
param T := 5;
param a := 5;
param b := 10;
param c := 1
param r := 100;
param s := 200;
param d := 1 85 2 120 3 150 4 90 5 120 6 80;
Find the error and fix it
Note: You gave T=5 but d in set IND which has T elements but d has 12 values so I think it should be T=12 and at the place of Z[4] it should be Z[13]. If you put question also here, then I can understand easily. By the way, I have corrected it by assuming above things. Please comment your question if you have any query.
.mod file:
param T;
set IND := 1..T;
set END := 0..T+1;
param a;
param b;
param c;
param r;
param s;
param d {IND} >= 0;
var X {IND} >= 0, <= r;
var Y {IND} >= 0, <= s;
var Z {END} >= 0;
minimize COST: sum {i in IND} (a * X[i] + b * Y[i] + c * Z[i]);
subject to BAL {i in END: 1<=i<=12 }: Z[i-1]+X[i]+Y[i] = d[i]+Z[i];
subject to INIT0: Z[0] = 0;
subject to INITE: Z[13] = 0;
.dat file:
param T := 12;
param a := 5;
param b := 10;
param c := 1;
param r := 100;
param s := 200;
param d :=
1 1
2 85
3 2
4 120
5 3
6 150
7 4
8 90
9 5
10 120
11 6
12 80;
Get Answers For Free
Most questions answered within 1 hours.