Originally posted by: lost_in_OPL
hi,
i am studying business in Germany and i need to program a lot sizing model. Unfortunately it is not working the way i was hoping. For some reason I always get negative costs, and nothing is produced eventhough there is a restriction that should make sure that something is produced.
The model is the proportional lotsizing and scheduling model (see attachment)
// Number of products
{string} PROD=...;
//Number of periods
int T=...;
range Periods=1..T;
//inventory holding cost
float h
PROD=...;
//production cost
float tb
PROD=...;
//setup time
float tr
PROD=...;
//demand
float d
PRODPeriods=...;
//setup cost
float s
PROD=...;
//capacity
float b=...;
//Production
dvar float+ X
PRODPeriods;
//Inventory
dvar float I
PRODhttp://0..T;
//binary setup variable
dvar int+ Use
PRODhttp://0..Tin 0..1;
//binary setup state variable
dvar int+ Z
PRODhttp://0..T in 0..1;
//objective
minimize
sum(j in PROD, t in Periods) (h[j]*I[j][t])+
sum(j in PROD, t in Periods) (s[j]*Use[j][t]);
subject to {
//inventory balance
forall (j in PROD, t in Periods){
I[j]
t-1 + X[j][t] - I[j][t] == d[j][t];
};
// capacity
forall (t in Periods){
sum(j in PROD) (tb[j] * X[j][t] + tr[j] * Use[j][t]) <= b;
};
// setup
forall (j in PROD, t in Periods){
X[j][t] <= 99999 * (Z[j][t] + Z[j]
t-1);
};
// max one setup state at the end of each period
forall (t in Periods){
sum (j in PROD) Z[j][t] <= 1;
};
//setup
forall (j in PROD, t in Periods){
Use [j][t] >= Z[j][t] - Z[j]
t-1;
};
// initial variables
forall (j in PROD) {
Use [j][0] == 0;
Z[j][0] == 0;
I[j][0]==0;
};
};
I never worked with OPL before and right now i am totally lost. I randomly change something in the model hoping that it will work at some point.
It would be really great if someone could help me.
Thank you!
Claudia
#DecisionOptimization#OPLusingCPLEXOptimizer