Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  leadtime

    Posted 07/18/17 05:25 AM

    Originally posted by: xspeng


    Actually I am programming ainventory planning model with lateral transfer  and transportation lead times. 
    I have defined:
    float LeadTime2[Plants][DCs] = ...;
    float LeadTime3[DCs][DCs] = ..
    dvar float+ OrderQuantity2[Products][Plants][DCs][Periods];
    dvar float+ OrderQuantity3[Products][DCs][DCs][Periods];
    dvar float+ OrderQuantity4[Products][DCs][Retailers][Periods];
    dvar float+ Inv2[Products][DCs][DemandScenarios][0..NbPeriods];
    I have some constraints as follows:
    forall(i in Products, j in Plants, k,m in DCs: k != m, r in Retailers, t in Periods)
    ctDCFlowblance:
    Inv2[i][k][t] == Inv2[i][k][t-1] +
    sum(m in DCs)
    OrderQuantity3[i][m][k][t-LeadTime3[m][k]]]  +
    sum(j in Plants)
    OrderQuantity2[i][j][k][t- LeadTime2[j][k]] -
     sum(m in DCs)
    OrderQuantity3[i][k][m][t] -
    sum( r in Retailers)
    OrderQuantity4[i][k][r][t];
    but i get some errors
    Can you give me some advice to deal with it
    Thank you so much for your help in advance!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: leadtime

    Posted 07/18/17 05:39 AM

    Hi,

    can you also attach your .dat ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: leadtime

    Posted 07/18/17 06:42 AM

    Originally posted by: xspeng


    I haven't created the data file

    I want to use randomly generated data,so the leadtime is different between different nodes


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: leadtime

    Posted 07/18/17 07:19 AM

    Hi,

    range Plants=1..2;
    range DCs=1..3;
    range Products=1..4;
    int NbPeriods=6;
    range Periods=1..NbPeriods;
    range Retailers=1..3;
    range DemandScenarios=1..7;

    int LeadTime2[p in Plants][d in DCs] = rand(10);
    int LeadTime3[p in DCs][d in DCs] = rand(5);


    dvar float+ OrderQuantity2[Products][Plants][DCs][Periods];
    dvar float+ OrderQuantity3[Products][DCs][DCs][Periods];
    dvar float+ OrderQuantity4[Products][DCs][Retailers][Periods];
    dvar float+ Inv2[Products][DCs][DemandScenarios][0..NbPeriods];

    subject to
    {
    forall(i in Products, k in DCs,
    t in Periods
    )
    ctDCFlowblance:
    Inv2[i][k][1][t] == Inv2[i][k][1][t-1]
    +
    sum(m in DCs:(t-LeadTime3[m][k] in Periods))
    OrderQuantity3[i][m][k][t-LeadTime3[m][k]] +
    sum(j in Plants:(t-LeadTime2[j][k] in Periods))
    OrderQuantity2[i][j][k][t- LeadTime2[j][k]] -
     sum(m in DCs)
    OrderQuantity3[i][k][m][t] -
    sum( r in Retailers)
    OrderQuantity4[i][k][r][t]
    ;
    }

    works

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: leadtime

    Posted 07/18/17 10:16 AM

    Originally posted by: xspeng


    Thank you so much for your response

     I had followed your advice but the problem remains

    I attach my .mod

    Again thank you so much for your attention

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: leadtime

    Posted 07/18/17 12:23 PM

    Hi,

    I removed your errors in

    range Plants=1..2;
    range DCs=1..3;
    range Products=1..4;
    int NbPeriods=6;
    range Periods=1..NbPeriods;
    range Retailers=1..3;
    range DemandScenarios=1..7;

    int LeadTime2[p in Plants][d in DCs] = rand(10);
    int LeadTime3[p in DCs][d in DCs] = rand(5);

    float ConsumptionSpace[Products];
    float Capacity[Products][Plants];
    float Space1[Plants] ;
    float Space2[d in DCs] = rand(10);
    //float Demand[Products][Retailers][Periods] = ...;
    float SetupCost[Products][Plants] ;
    float VariableCost[Products][Plants];
    float OrderCost1[Products][Plants][Plants] ;
    float OrderCost2[Products][Plants][DCs] ;
    float OrderCost3[Products][DCs][DCs] ;
    float OrderCost4[Products][DCs][Retailers] ;
    float TransportationCost1[Products][Plants][Plants] ;
    float TransportationCost2[Products][Plants][DCs] ;
    float TransportationCost3[Products][DCs][DCs] ;
    float TransportationCost4[Products][DCs][Retailers] ;
    int LeadTime1[p in Plants][k in Plants] = rand(10);

    float Inventory[Products] ;
    float InvCost1[Products][Plants] ;
    float InvCost2[Products][DCs] ;

    dvar boolean Setup[Products][Plants][Periods];
    dvar boolean Order1[Products][Plants][Plants][Periods];
    dvar boolean Order2[Products][Plants][DCs][Periods];
    dvar boolean Order3[Products][DCs][DCs][Periods];
    dvar boolean Order4[Products][DCs][Retailers][Periods];
    dvar float+ ProductionQuantity[Products][Plants][Periods];
    dvar float+ OrderQuantity1[Products][Plants][Plants][Periods];
    dvar float+ OrderQuantity2[Products][Plants][DCs][Periods];
    dvar float+ OrderQuantity3[Products][DCs][DCs][Periods];
    dvar float+ OrderQuantity4[Products][DCs][Retailers][Periods];
    dvar float+ Inv1[Products][Plants][0..NbPeriods];
    dvar float+ Inv2[Products][DCs][0..NbPeriods];


    minimize
    sum( i in Products, j in Plants, t in Periods )
          (SetupCost[i][j] * Setup[i][j][t] + VariableCost[i][j] * ProductionQuantity[i][j][t]) +
    sum( i in Products, j,n in Plants:j != n, t in Periods)
    OrderCost1[i][j][n] * Order1[i][j][n][t] +
    sum( i in Products, j in Plants, k in DCs, t in Periods)
    OrderCost2[i][j][k] * Order2[i][j][k][t] +
    sum( i in Products, k,m in DCs:k != m, t in Periods)
    OrderCost3[i][k][m] * Order3[i][k][m][t] +
    sum( i in Products, k in DCs, r in Retailers,t in Periods)
    OrderCost4[i][k][r] * Order4[i][k][r][t] +
    sum( i in Products, j in Plants, t in Periods )
         InvCost1[i][j] * Inv1[i][j][t] +
    sum( i in Products, k in DCs,  t in Periods )
         InvCost2[i][k] * Inv2[i][k][t] +
    sum( i in Products, j,n in Plants:j != n, t in Periods)
    TransportationCost1[i][j][n] * OrderQuantity1[i][j][n][t] +
    sum( i in Products, j in Plants, k in DCs, t in Periods )
    TransportationCost2[i][j][k] * OrderQuantity2[i][j][k][t] +
    sum( i in Products, k,m in DCs: k != m, t in Periods)
    TransportationCost3[i][k][m] * OrderQuantity3[i][k][m][t] +
    sum( i in Products, k in DCs, r in Retailers, t in Periods )
    TransportationCost4[i][k][r] * OrderQuantity4[i][k][r][t] ;


    subject to {
    forall(i in Products, j in Plants, t in Periods)
    ctCapacity:
    ProductionQuantity[i][j][t] <= Setup[i][j][t] *Capacity[i][j];
    forall(j in Plants, t in Periods)
    ctPlantSpace:
    sum(i in Products)
    ConsumptionSpace[i] * Inv1[i][j][t] <= Space1[j];
    forall(k in DCs, t in Periods)
    ctDCSpace:
    sum(i in Products)
    ConsumptionSpace[i] * Inv2[i][k][t] <= Space2[k];
    forall(j in Plants, t in Periods)
    ctPlantspace1:
    sum(i in Products)
    ProductionQuantity[i][j][t] * ConsumptionSpace[i] +
    sum(i in Products, n in Plants:(t-LeadTime1[n][j] in Periods))
    OrderQuantity1[i][n][j][t-LeadTime1[n][j]] * ConsumptionSpace[i] <=  Space1[j] - Inv1[1][j][t-1] * ConsumptionSpace[1];
    forall(k in DCs, t in Periods)
    ctDCspace1:
    sum(i in Products, j in Plants:(t-LeadTime2[j][k] in Periods))
    OrderQuantity2[i][j][k][t- LeadTime2[j][k]] * ConsumptionSpace[i] +
    sum(i in Products, m in DCs:(t-LeadTime3[m][k] in Periods))
    OrderQuantity3[i][m][k][t-LeadTime3[m][k]] * ConsumptionSpace[i] <=  Space2[k] - Inv2[1][k][t-1] * ConsumptionSpace[1];
    forall(i in Products, j in Plants, k in DCs, t in Periods)
    ctPlantFlowBlance:
    Inv1[i][j][t] == ProductionQuantity[i][j][t] + Inv1[i][j][t-1] +
    sum(n in Plants:(t-LeadTime1[n][j] in Periods))
    OrderQuantity1[i][n][j][t-LeadTime1[n][j]] -
     sum(k in DCs)
    OrderQuantity2[i][j][k][t] -
    sum(n in Plants)
     OrderQuantity1[i][j][n][t];

    forall(i in Products, j in Plants, t in Periods)
     ctInventory1:
        Inventory[i] == Inv1[i][j][0];
    forall(i in Products, k in DCs, t in Periods)
     ctInventory2:
        Inventory[i] == Inv2[i][k][0];
         }   

     

    and you could start from there

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: leadtime

    Posted 07/20/17 08:19 AM

    Originally posted by: xspeng


     I am sorry,the problem remains


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: leadtime

    Posted 07/20/17 08:22 AM

    Hi,

    are you able to generate and share a .dat file ?

    If yes then you could attach your .mod and .dat

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: leadtime

    Posted 07/21/17 05:32 AM

    Originally posted by: xspeng


    I have attached my .mod and .dat

    I hope you can help to solve the problems

    Thank you so much for your help in advance!

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: leadtime

    Posted 07/21/17 07:05 AM

    Hi,

    I repaired some errors:

    1) I added some ftoi to convert float into int

    2) You forgot some dimension in some constraints

    So now you still have to do some work.

    For example you need to fix

    Demand from SheetRead(sheetInput,"data!E1:E1000");

    You should first read a tuple set and then convert that into a 4D array, see http://www-01.ibm.com/support/docview.wss?rs=0&context=SSCMS55&uid=swg21401340&loc=en_US&cs=utf-8&cc=us&lang=all

    regards

    PS: Some useful links at https://www.ibm.com/developerworks/community/forums/html/topic?id=0d0b2396-3b48-4638-b032-3b9ea74f1a11&ps=25


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: leadtime

    Posted 07/25/17 08:29 AM

    Originally posted by: xspeng


    I had a look at http://www-01.ibm.com/support/docview.wss?rs=0&context=SSCMS55&uid=swg21401340&loc=en_US&cs=utf-8&cc=us&lang=all

    But I still don't quite understand.

    Can you give an example of how to handle the second problem in my .mod and .dat?

    For example how to  fix

     Demand from SheetRead(sheetInput,"data!E1:E1000");

    what should i write my code in my .mod and .dat?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: leadtime