Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Problem with index ranges in CPLEX

    Posted Mon July 23, 2012 05:09 PM

    Originally posted by: SystemAdmin


    Hi:

    I've been trying to implement an inventory optimization model in CPLEX. Unfortunately I have problems with the index ranges... The model contains two sets of indexes (stages and periods) and I have to sum up over both of them.
    Also, I sometimes want to include variables in the index ranges. So for example I might want to sum up over all periods starting with the current period and ending with the period that equals the transportation lead time of the stage. I don't really know how to do this in OPL as I don't know the right syntax. I've been trying to find out how this works for a while but I don't really find anything in the documentation or elsewhere.

    I hope you can help me. I would be so grateful!

    Thanks,
    Carolin
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Problem with index ranges in CPLEX

    Posted Mon July 23, 2012 05:10 PM

    Originally posted by: SystemAdmin


    data file
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Problem with index ranges in CPLEX

    Posted Wed July 25, 2012 03:14 AM
    Hi,

    first of all, in the OPL language the equality constraint is not = but ==.

    I changed a little your code in order to run it.
    This can be a start for you in order to change it to what you need.

    Regards

    
    using CP;   
    
    int Nbstages =...; range stages = 1..Nbstages; 
    
    int Nbperiods =...; range periods = 1..Nbperiods+1; 
    
    int holdingcost [stages]=...; 
    
    int backordercost=...; 
    
    int WIPtransportleadtime [stages]=...; 
    
    int Demand [periods]=...; dvar int+ qtyordered [stages] [periods]; dvar int+ qtybackordered [stages] [periods]; dvar int+ WIPintransit [stages] [periods]; dvar int+ WIPwaiting [stages] [periods]; dvar int+ initialinventory [stages] [periods]; dvar int+ finalinventory [stages] [periods]; dvar int+ basestock [stages]; minimize sum (j in stages:j!=1) ((holdingcost[j]* sum (t in 1..Nbperiods+1)finalinventory [j][t]))+ backordercost* sum(t in 1..Nbperiods+1)(qtybackordered[1][t]); subject to 
    { forall (j in stages:j!=1) forall (t in periods:t==1) initialinventory [j] [t]>=0; forall (j in stages:j!=1) forall (t in 2..WIPtransportleadtime[j]: t in periods) initialinventory [j][t] == finalinventory[j][t-1]; forall (j in stages:j!=1) forall (t in 2..Nbperiods+1: (t in periods) && (t>=WIPtransportleadtime[j]+1)) ((t>=WIPintransit[j][t]+1) => (initialinventory [j][t] == finalinventory [j][t-1]+WIPintransit[j][t-WIPtransportleadtime[j]])); forall (j in stages:j==1) forall (t in 1..Nbperiods+1) initialinventory [j][t]==Demand [t]; forall (j in stages) forall (t in 1..Nbperiods+1) finalinventory [j][t] == initialinventory [j][t]-qtyordered[j][t]; forall (j in stages) forall (t in 1..Nbperiods+1) qtyordered [j][t]<=initialinventory [j][t]; forall (j in stages) forall (t in periods:t==1) qtyordered [j][t]<=Demand [t]; forall (j in stages) forall(t in periods:t==1) qtybackordered [j][t]==Demand[t]-qtyordered[j][t];   forall (j in stages) forall(t in 2..Nbperiods+1) qtyordered [j][t]<=Demand[t]+qtybackordered[j][t-1];   forall (j in stages) forall(t in 2..Nbperiods+1) qtybackordered[j][t]==Demand[t]+qtybackordered[j][t-1]-qtyordered[j][t]; forall (j in stages:j!=Nbstages) forall (t in periods) WIPintransit [j][t]==qtyordered[j][t];   
    } ;
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer