Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Define a set

    Posted Tue April 26, 2016 11:41 AM

    Originally posted by: Crubal


    Hi,

     

    During writing the code, I want to define sets (described in the attachment); where I have the initial code:

    int Resources = ...; // Number of Stations to select;
     range Stations = 1..Resources;
     float charge_stations[Stations];
      
     range Interchanges = 1..Resources; // Number of Interchanges to be covered;

     // Define Traffic Flow sets, distance and related binary variable
     tuple flow    {int i; int j;}
     setof(flow) Flows  = {<i,j> | ordered i,j in Interchanges};
     float distance_flow[Flows] = ...;
     
     
     tuple stations {
     float charge_stations; 
     }
     
     tuple traffic_flow {
     float distance_flow; 
     }

     float Budget;
     float Safety_distance;

     dvar int Build[Stations];
     dvar boolean FlowsInSet1[Flows];
     dvar boolean Cover[<i,j> in Flows];

     

     

    Thanks a lot!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Define a set

    Posted Mon May 09, 2016 01:22 PM

    Originally posted by: Crubal


    After someone's help, 

    setof(flow) Flows_1 = {<i,j>| <i,j> in Flows: distance_flow[<i,j>] <= Safety_distance * 0.25};  is generated. 

     

    However, I would like to add a station k where k is built in <i,j> (on the route of i and j). Can I define:

    setof(flow) Flows_11 = {<i,k>| <i,k> in Flows_1: distance_flow[<i,k>]<= Safety_distance * 0.25};

     

    Or how to combine the two conditions together?

     

    Thanks!

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Define a set

    Posted Wed May 11, 2016 09:01 AM

    Hi,

    you could try to use arrays of sets:

    range Flows=1..5;
     float Safety_distance=5;
     
     tuple flow
     {
     int o;
     int d;
     }
     
     {flow} s={<i,j> | i,j in Flows: i!=j};
     
     float distance_flow[i in s]=pow(i.d-i.o,2);

     setof(flow) Flows_1 = {i| i in s: distance_flow[i] <= Safety_distance * 0.25};
     
     
     setof(flow) Flows_11[i in Flows_1] = {<i.o,k>| <i.o,k> in Flows_1: distance_flow[<i.o,k>]<= Safety_distance * 0.25};
     execute
     {
     writeln(Flows_1);
     writeln(Flows_11);
     }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Define a set

    Posted Wed May 11, 2016 10:00 AM

    Originally posted by: Crubal


    Thank you Alex,

     

    Can I ask 

    float distance_flow[i in s]=pow(i.d-i.o,2);

     

    setof(flow) Flows_11[i in Flows_1] = {<i.o,k>| <i.o,k> in Flows_1: distance_flow[<i.o,k>]<= Safety_distance * 0.25};

     

    What do they mean?

     

    Thanks!

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Define a set

    Posted Wed May 11, 2016 10:26 AM

    Hi,

    maybe you could spend some time having a look at our documentation and http://www-01.ibm.com/support/docview.wss?uid=swg21647915

    float distance_flow[i in s]=pow(i.d-i.o,2);

    means that the distance is computed as the square of the difference between origin o and destination d

    setof(flow) Flows_11[i in Flows_1] = {<i.o,k>| <i.o,k> in Flows_1: distance_flow[<i.o,k>]<= Safety_distance * 0.25};

    is for each element i in Flows_1 the set of all arcs <o,k> starting at i such as the distance flow of <o,k> is less than 0.25 times the safety distance

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Define a set

    Posted Wed May 11, 2016 10:28 AM

    Originally posted by: Crubal


    Hi Alex,

     

    Thank you! I will take a look at the documentation, and I really appreciate your help!

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer