Originally posted by: CDN3_Daniel_Cramer
After hours, I implemented the example in the help file...
mod
{string
} products = ...;
{
int
} time = ...;
int NBdiscount = ...;
float discount[products][1..NBdiscount] = ...;
float breakpoint[products][1..NBdiscount-1] = ...;
float d[products][time] = ...;
float s[products] = ...;
float h[products] = ...;
float g[products] = ...;
float Wert[k in products] = sum(t in time) d[k][t]; dvar int+ q[products][time]; dvar int+ y[products][time]; dvar
boolean gamma[products][time]; dexpr
float Lagerkosten = sum(k in products, t in time) (h[k] * y[k][t]); dexpr
float Versandkosten = sum(k in products, t in time) (s[k] * gamma[k][t]); dexpr
float Bestellpreis = sum(t in time, k in products) piecewise (i in 1..NBdiscount-1)
{ discount[k][i] -> breakpoint[k][i]; discount[k][NBdiscount]
} (5,4) q[k][t]; minimize Lagerkosten + Versandkosten + Bestellpreis; subject to
{ forall(k in products, t in time) q[k][t] <= Wert[k] * gamma[k][t]; forall(k in products, t in time : t > 0) y[k][t-1] + q[k][t] - y[k][t] == d[k][t]; forall (k in products) y[k][0] == d[k][0]; forall (k in products) q[k][0] == 0;
};
dat
products =
{
"12"
}; time =
{0 1 2 3 4 5 6 7 8 9 10 11
}; NBdiscount = 7; discount = #[
"12" : #[1:0 2:4 3:0 4:-0.5 5:0 6:-0.75 7:0]#]#; breakpoint = #[
"12" : #[1:0 2:0 3:100 4:100 5:500 6:500]#]#; g = [2,]; s = [1]; h = [0.05]; d = #[
"12" : #[0:0 1:0 2:0 3:0 4:500 5:0 6:0 7:0 8:100 9:0 10:0 11:0]# ]#;
q is a dvar int+ and should be multiplied with the value in the discontinous piecewise-function.
OPL chooses the right value from the .dat - but it isn't multiplied with q...
Any tips?
#DecisionOptimization#OPLusingCPLEXOptimizer