Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Define sets according to certain conditions

    Posted 04/16/16 04:23 PM

    Originally posted by: Crubal


    Hi,

     

    I am defining the sets when building the mathematical model:

    set1: a station (built) k is built on a path from nodes i to j; such that d(i, k) <= safety_distance /2 ;

    set2: a station (built) k is built on a path from nodes i to j; such that d(k, j) <= safety_distance /2 ;

    Where i, j are interchanges

     

    I have the initial code:

    // Define Stations and related parameter

     int Resources = ...; 
     range Stations = 1..Resources;

     range Interchanges = 1..Resources;

     

    // 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] = ...;

     float Safety_distance;

     

    // Binary variable is defined this way whether a station is built or not 

     dvar int Build[Stations];

     

    setof(flow) set1 = [<i,j> in Flows, k in Build[Stations] | distance_flow[<i,k>] <= 0.5 * Safety_distance];

    In the last line, it has errors, and actually I don't know how to define this type of sets. 

     

     

     Besides, I am not sure how to define a binary variable: Cover[<i,j> in Flows]

     Where Cover[<i,j> in Flows] = 1 means in round trip (i, j), the flow is covered by a fueling station (Build[Stations] = 1); and 0 otherwise. 

     

     In my way, I just write : dvar int Cover[<i,j> in Flows]; 

     

    Thank you for your help!

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Define sets according to certain conditions

    Posted 04/18/16 03:13 AM

    Hi,

    you can't define a set that will change according to a decision variable.

    What you should do instead of writing s1= is to write something like

    dvar boolean FlowsInSet1[Flows];

    and then you will add constraints about what FlowsInSet1 means.

    For Cover, you could declare

    dvar boolean Cover[<i,j> in Flows] ;

    and then add constraints like

    subject to
     {
    forall(<i,j> in Flows) Cover[<i,j>]==
    (1<=Build[i]+Build[j]);
    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Define sets according to certain conditions

    Posted 04/22/16 03:15 PM

    Originally posted by: Crubal


    Thanks Alex,

     

    I am sorry for the late response, but it is useful! 

    May I ask if I code like 

     {
    forall(<i,j> in Flows) Cover[<i,j>]==
    (1<=Build[i]+Build[j]);
    }

     

    How can I add safety_distance into the model? Since the constraint is valid only when the distance between i and j is lower than 0.5 * safety_distance.

     

    Thank you!

     

    Crubal


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Define sets according to certain conditions

    Posted 11/12/19 03:43 AM

    Originally posted by: NALK


    Dear ALEX,

     

    I have a confusion about  how to define a set of arrays that is related to a decision variable , 

    range q=1..N;

    {string} Group={"S1","S2"}  

    tuple element_Group {  int id;}

    {element_Group} Group[q]=...;   ///  how to link data from excel or any other file to this array without using data file 

     

    for all j in q,   I need to say  also  for all   m in set of j ( {}_j,  ),   can we do that using OPL;

    Thanks a lot 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Define sets according to certain conditions

    Posted 11/12/19 04:59 AM

    hi

    how to link data from excel or any other file to this array without using data file 

    ==> you could use SheetRead, see the example oil

    for all j in q,   I need to say  also  for all   m in set of j ( {}_j,  ),   can we do that using OPL;

    ==> yes

    forall(j in q) forall(m in myset[j])

    regards

     

    https://www.linkedin.com/pulse/ibm-think-lia-loptimisation-et-moi-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Define sets according to certain conditions

    Posted 11/12/19 05:40 AM

    Originally posted by: NALK


    Thank you ALEX , it is really helpful,

     

    I have one more question  ,    forall( j in q)   forall(m in setof(j))   is that true that m moves in the setof(j) even its of different dimensions like that setof(j)=[ {1},{2,1000}];

    for j=1,  m takes 1 as a value,

     

    for j=2, m takes 2 and 1000 as values

     

    is that true?

     

    Thanks a lot again,

     

    regarding the forum also, it will be deleted on Jan,2020 ,  is there any alternative plan for that,

     

    Thanks

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Define sets according to certain conditions

    Posted 11/12/19 05:48 AM