Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  for and if in CPLEX

    Posted 04/12/16 03:36 PM

    Originally posted by: Crubal


    Hi, I have a following question:

    Given 

    int Resources = ...;

    range Interchanges = 1..Resources;

     

     tuple flow    {int i; int j;}
     setof(flow) Flows  = {<i,j> | ordered i,j in Interchanges};
     float distance_flow[Flows] = ...;

     

    I would like to define a 0/1 parameter path_flow according to whether distance_flow[<i,j>] is greater than R(known) or not. 

    I tried the following code, but it has bugs.

     

     execute {
        for (ordered i,j in Interchanges) {if (distance_flow[<i,j>]<= R) 
        {
        path_flow[<i,j>] == 1};
        else 0;
        }     
     }

     

    Could you help me with that?

     

    Thanks!


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: for and if in CPLEX

    Posted 04/12/16 04:13 PM

    Note that there is a separate forum dedicated to OPL. OPL related questions should be asked there.

    In your case I think you don't need an execute block. You can just say:

    int path_flow[f in Flows] = distance_flow[f] <= R ? 1 : 0;

    to define that parameter (note that in your code 'Flows' is exactly the same as 'ordered i,j in Interchanges').


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: for and if in CPLEX

    Posted 04/12/16 04:20 PM

    Originally posted by: Crubal


    I see, thanks Daniel!


    #CPLEXOptimizers
    #DecisionOptimization