Originally posted by: SystemAdmin
Hi,
I've been trying to implement a model in CPLEX for a while now. But it seems I just can't get the indices right...
I get the error msg that "range is not available for scripting". Whatever that means...
Basically what I want to model is this: There is a variable called "stages" It has the index j and j runs from 1 to the number of stages (in my case that's 3, I defined it as Nbstages). In one of the constraints I need to access j-1, so I only want to have this constraint for j in 2..Nbstages (as j is only defined from 1 to Nbstages and j-1 would be 0 for j=1).
I would be very very grateful for some help on this topic. This is the code I came up with:
int Nbstages = ...;
range stages = 1..Nbstages;
int LeadTime
stages=...;
int MaxServiceTime
stages=...;
float safetyfactor
stages=...;
float StandardDeviation
stages=...;
int MeanDmd
stages=...;
float StageCost
stages=...;
float HoldingCostRate
stages=...;
float HoldingCost
stages=...;;
dvar int+ OutboundServiceTime
stages;
dvar int+ InboundServiceTime
stages;
minimize
sum (j in stages)
(HoldingCost[j]*(MeanDmd[j]*(InboundServiceTime[j]+LeadTime[j]-OutboundServiceTime[j]))
+(safetyfactor[j]*StandardDeviation[j]*/*sqrt*/(InboundServiceTime[j]+LeadTime[j]-OutboundServiceTime[j])));
subject to {
forall (j in stages)
OutboundServiceTime [j]-InboundServiceTime[j] <= LeadTime[j];
forall (j in stages)
InboundServiceTime [j]-OutboundServiceTime
j-1 >= 0;
//forall (j in stages)
OutboundServiceTime[0]==0;
forall (j in stages)
OutboundServiceTime [j]<= MaxServiceTime [j];
forall (j in stages)
InboundServiceTime [j]>=0;
forall (j in stages)
OutboundServiceTime [j]>=0;
};
Thanks a lot,
Carolin
#DecisionOptimization#OPLusingCPLEXOptimizer