Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Reading OPL data file in CPLEX

    Posted Wed June 03, 2020 03:55 PM
    Hi there,

    I am trying to work in CPLEX with the data of the following data file sprint01.dat
    I only know the basics in OPL and therefore don't know how to use the sets and parameters as given in the .dat file in my OPL model.
    Normally I am used to the data given as Arrays:

    {string} Shift =  {"N", "E", "D", "L"}; 

    So how do I make use of the following data in my model:

    /*shifts*/
    set Shift :=
        N E D L
        ;


    or the given Array:

    int demand [Nurse] [Day] [Shift] = …;

    So how do I make use of the following data in my model:


    /*demand for nurses per day and shift*/
    param r :
          L   D   E   N :=
    1     2     1     2     1     /* 01/01/2010 - */
    2     1     1     1     1     /* 02/01/2010 - */
    3     1     1     1     1     /* 03/01/2010 - */
    4     2     1     2     1     /* 04/01/2010 - Monday*/
    5     2     1     2     1     /* 05/01/2010 - */
    6     2     1     2     1     /* 06/01/2010 - */
    7     2     1     2     1     /* 07/01/2010 - */
    8     2     1     2     1     /* 08/01/2010 - */
    9     1     1     1     1     /* 09/01/2010 - */
    10     1     1     1     1     /* 10/01/2010 - */
    11     2     1     2     1     /* 11/01/2010 - Monday*/
    12     2     1     2     1     /* 12/01/2010 - */
    13     2     1     2     1     /* 13/01/2010 - */
    14     2     1     2     1     /* 14/01/2010 - */
    15     2     1     2     1     /* 15/01/2010 - */
    16     1     1     1     1     /* 16/01/2010 - */
    17     1     1     1     1     /* 17/01/2010 - */
    18     2     1     2     1     /* 18/01/2010 - Monday*/
    19     2     1     2     1     /* 19/01/2010 - */
    20     2     1     2     1     /* 20/01/2010 - */
    21     2     1     2     1     /* 21/01/2010 - */
    22     2     1     2     1     /* 22/01/2010 - */
    23     1     1     1     1     /* 23/01/2010 - */
    24     1     1     1     1     /* 24/01/2010 - */
    25     2     1     2     1     /* 25/01/2010 - Monday*/
    26     2     1     2     1     /* 26/01/2010 - */
    27     2     1     2     1     /* 27/01/2010 - */
    28     2     1     2     1     /* 28/01/2010 - */
        ;


    Thanks in Advance!

    ------------------------------
    Jennifer Engelmann
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Reading OPL data file in CPLEX

    Posted Thu June 04, 2020 01:25 AM
    May I ask what is the tool for which you created your original data file?

    Anyway, most of your data can be translated to OPL in a straightforward way. For sparse sets as nx you will have to use tuples for indexing and take a short detour in the definition. A set like D can be defined in OPL as well but in that case you are probbably better off using a range.

    Here is a literal translation of some of your data:
    {string} S = ...;
    int isNightS[S] = ...;
    {string} C = ...;
    int nWE[C] = ...;
    {string} N = ...;
    {string} NS[N] = ...;
    tuple NX {
    key string nurse;
    key string shift;
    key int day;
    int count;
    }
    {NX} nx_data = ...;
    int nx[i in nx_data] = i.count;
    {int} D = ...;
    int r[D][S] = ...;
    This works with the attached .dat file.

    Before continuing with that, I suggest to double check whether you want to rearrange your data in a way that better fits what OPL can do. At first glance it seems like OPL is more powerful than the data language you use in your original .dat file, so rearranging data may allow easier .dat files.

    In general, you probably have to work through some of the more advanced OPL examples that ship with CPLEX to get used to OPL data structures etc.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Reading OPL data file in CPLEX

    Posted Thu June 04, 2020 07:48 AM
    Thanks a lot for your help!
     
    I didn't create the data file, because I found the data files of the instances as given on http://www.goal.ufop.br/nrp/ 
    I need to run severel instances of the NRPS Competition in my model for my Bachelor Thesis. Since I am a "only" a Business student, the Informatik part is quite complicated to understand. Reading the text files would be more complicated for me.I tried to inform myself about that but could not find any answers to reading a data file as given in the example in the attached file.

    How were you able to convert the data file? I would like to do that to several instances (about 30).

    "At first glance it seems like OPL is more powerful than the data language you use in your original .dat file, so rearranging data may allow easier .dat files."
    Do you mean rearranging the order of the sets for example or what exactly do you mean by that?

    Kind regards


    ------------------------------
    Jennifer Engelmann
    ------------------------------