Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  help: index problem

    Posted 03/12/12 01:28 PM

    Originally posted by: kutikz


    i have a route matrix which represent the route for each period to deliver such amount of items, 0 represent the depot, and 1,2,3,4 represent the node of the customers. i have 4 period and 4 customer. and distanceCost is a matrix which represents the cost for doing a delivery including from depot to another customer.

    route=[[0,2,1,4,0,3,0,0],
                    [0,2,4,0,1,0,0,0],
                    [0,2,0,3,0,4,0,0],
                    [0,1,2,0,3,0,4,0]];
    distanceCost=[[0, 14, 25, 36, 35],
                            [14, 0, 19, 28, 32],
                            [25, 19, 0, 11, 13],
                            [36, 28, 11, 0, 14],
                            [35, 32, 13, 14, 0]];
    


    my question is i want to calculate the totalcost for the whole rote, which meand sum of the cost for each period,
    totalcost==distanceCost[0][2] + distanceCost[2][1] + distanceCost[1][4] + distanceCost[4][0]+...distanceCost[0][0]+ 
               distanceCost[0][2]+distanceCost[2][4]...+ distanceCost[0][0]+
               distanceCost[0][2]+ ...+ distanceCost[0][0]+ 
               distanceCost[0][1]+ ... + distanceCost[4][0] ;
    


    im getting confused on how to input the index for calculating the totalcost, because i need the element from the route matrix and use it as the index for the distanceCost.
    please help me
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: help: index problem

    Posted 03/17/12 02:37 PM

    Originally posted by: davidoff


    Hello

    I attached a code sample related to your data.

    Note that my answer is not a decision model ! It's just how to calculate the total cost , but I guess you would like to model a routing problem where route could be a sequence of unknwon decisions (e.g a decision variable). In this case, it would have to be modeled through OPL (with CP or CPLEX)

    Regards

    David
    #DecisionOptimization
    #OPLusingCPLEXOptimizer