Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Post-processing arc solution order

    Posted 05/01/17 01:11 PM

    Originally posted by: ALessin


    I am trying to display a flow solution using post-processing commands, but I can't figure out how to display the solution arcs in the correct order. For example, the flow solution vector begins as follows:

    <from node,to node,Flow[a]>

    <0,1,1>
    <1,10,1>
    <2,11,1>
    <10,2,1>
    <11,20,1>
    <20,30,1> ...,

    and my solution is displaying as: 

    BreachSolution = [ 0 1 10 11 2 20 30  ....

    when I would like it to display correctly as:

    BreachSolution = [ 0 1 10 2 11 20 30 ....

    Do you know how I could implement this using the appropriate post-processing commands? Thank you.

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Post-processing arc solution order

    Posted 05/02/17 03:53 AM

    Hi,

    if you add

    tuple arcsolution
    {
     key int fromnode;
     int tonode;
    }

    {arcsolution} ArcsSolution={<a.fromnode,a.tonode> | a in Arcs : y[a] > 0};
    {arcsolution} ArcsSolution2={};

    range r=0..card(ArcsSolution)-2;
    int sol[0..card(ArcsSolution)-1];

    execute
    {
    sol[0]==0;
    var t=Opl.first(ArcsSolution);

    for(var i in r)
    {
        ArcsSolution2.add(t);
        t=ArcsSolution.find(t.tonode);
        writeln(t.tonode);
        sol[i+1]=t.tonode;
    }
    write("\nBreachSolution2 = ",sol); //Displays the path solution vector to be used for plotting purposes in MATLAB

    }

     

    you will get

    BreachSolution2 =  [0 10 2 11 20 30 21 31 22 32 41 50 59 69 78 87 96 106 115 124 116 125 134 143
         133 142 132 141 131 140 130 139 148 156 163]

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Post-processing arc solution order

    Posted 05/02/17 10:14 AM

    Originally posted by: ALessin


    Thank you very much, Alex. I tried following a similar piece of code in the netflow example, but I couldn't get it to work properly. The only issue here is that the solution is missing the first "tonode" value of "1," in this case. I changed

    writeln(t.tonode);
    sol[i+1]=t.tonode;

    to:

    writeln(t.fromnode); 
    sol[i+1]=t.fromnode; 

    and now get: BreachSolution2 =  [0 1 10 2 11 20 30 21 31 22 32 41 50 59 69 78 87 96 106 115 124 116 125 134
         143 133 142 132 141 131 140 130 139 148 156].

    This solution now leaves out the last "tonode" value, but that is fine since it's just an artificial terminus node.

    Thanks again for your assistance!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Post-processing arc solution order