Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  how to declare and initialize binary parameter and variables in OPL

    Posted 06/11/12 04:42 PM

    Originally posted by: SystemAdmin


    Hi,

    I have a following problem in my model. Kindly refer my attachment which will give a better understanding of my below description. I have a parameter Paths which is a binary type. It's notation is,

    Paths{i,s,d,l}

    i - index of path
    s - source node
    d - destination node
    l - link occurs in that path

    In my data model, I have represented as,

    Paths{1,2,9,*} 2 1 3 1 4 1 5 1 6 1

    Here in the above example, for index i(i.e., value 1), source node 2 and destination node 9, the links such as 2,3,4,5,6 forms a path, and in between the links i placed boolean value 1 to represent a boolean parameter, it will checks if the link is available or not and then returns the boolean value. Here, those links mentioned will return 1 since it contains the links in that path. The basic idea is if this parameter contains the links then this parameter Paths should return boolean value in my constraints section which I have used in my model.

    I would like to represent this approach in data model and OPL model. I am struck and dont have any clue. Kindly help me as soon as possible.

    I kindly request someone to help me as soon as possible. I already posted in other thread long time back but I dint get any reply so far. But I have explained a little bit deep to understand my problem anyways.

    Thanks!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: how to declare and initialize binary parameter and variables in OPL

    Posted 06/13/12 03:43 AM
    Hi,

    could the following help you?

    .mod

    tuple link
    {
      int node;
      int paramnode;
    }  
    tuple path
    {
     int index;
     int source;
     int destination;
     {int} links; 
     {int} linksWithParamTrue;
    }  
     
    {path} paths=...;
    


    .dat
    paths={<1,2,9,{2,3,4,5,6},{2,3,4,5,6}>};
    


    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: how to declare and initialize binary parameter and variables in OPL

    Posted 06/13/12 06:21 PM

    Originally posted by: SystemAdmin


    Hi,

    Thanks for the reply. Here I have few more questions based on my model.
    Why tuple has been used for links as well from the example you gave?
    How to declare a variable as Binary?
    I have a condition like this shown below, Will it work?

    float LinkPowerl in Links = (Capacityl in Links<1000) ? 60 : (Capacityl in Links<2000) ? 100 : (Capacityl in Links<4000) ? 140 : (Capacityl in Links<10000) ? 174 : 0 ;
    If you check my .dat file which I have attached in this thread in the previous posts, there is a parameter Capacity and Pairs are used. How can I use in OPL .dat file to represent the same?
    Kindly help me to model....

    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: how to declare and initialize binary parameter and variables in OPL

    Posted 06/14/12 11:56 AM
    Hi

    tuple link is useless

    
    tuple path 
    { 
    
    int index; 
    
    int source; 
    
    int destination; 
    {
    
    int
    } links; 
    {
    
    int
    } linksWithParamTrue; 
    }   
    {path
    } paths=...;
    


    works fine.

    To declare a binary decision variable:

    
    dvar 
    
    boolean bVar;
    


    For your LinkPower question, you can write:

    .mod
    
    
    {
    
    int
    } links=...;   
    
    int Capacity[links]=...;   
    
    float LinkPower[l in links] = (Capacity[l] <1000) ? 60 : (Capacity[l] <2000) ? 100 : (Capacity[l] <4000) ? 140 : (Capacity[l] <10000) ? 174 : 0;
    


    .dat
    
    links=
    {1
    };   Capacity=[1000];
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: how to declare and initialize binary parameter and variables in OPL

    Posted 06/14/12 12:22 PM

    Originally posted by: SystemAdmin


    Hi,

    Thanks for the help. Also I have asked about parameter *Pairs*?. The idea of this parameter is to map the bi-directional links in my model. If you check my .dat file provided in the previous posts, I have actually mapped link{1} to link{2} and so on for remaining links. How can I declare and initialize in .mod and .dat file in OPL?
    I have a parameter Demand in my data model file. It is represented as D{s,t}. It has a value for each s and t which is formed as array. How can I formulate this .mod and .dat file in OPL?
    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: how to declare and initialize binary parameter and variables in OPL

    Posted 06/15/12 03:31 AM
    Hi,

    there is a nice example of 2 dimensions array in the documentation at

    IDE and OPL > Optimization Programming Language (OPL) > Language Reference Manual > OPL, the modeling language > Data sources > Data initialization

    /* .mod file */
    int a[1..2][1..3] = ...;
    /* .dat file */
    a = [
    [10, 20, 30],
    [40, 50, 60]
    ];
    


    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer