Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

How to declare a tuple with two indices?

  • 1.  How to declare a tuple with two indices?

    Posted 01/25/19 11:10 AM

    Originally posted by: ChWeil


    Hi guys, 

    I have a tuple in my model that looks as follows:

     

    machines=2

    durations=5

    tuple Maint_var { int S; int F;}

    (Maint_var} mvar [machines][durations] = ...;

    In the data file I wrote:

    mvar=#[ [ [<672000,700000>, <872000,1001000>,<1172000,1302000><2072000,2150000><2820000,2900000><3052000,3550000><4072000,4100000>],

    [<...,..>,<..,..>,<...,..>,<..,..>,<...,..>,<..,..>],[<...,..>,<..,..>,<...,..>,<..,..>,<...,..>,<..,..>],[<...,..>,<..,..>,<...,..>,<..,..>,<...,..>,<..,..>],[<...,..>,<..,..>,<...,..>,<..,..>,<...,..>,<..,..>] ],

    [ [<...,..>....],[<...,..>,..],[<...,..>...],[<...,..>....],[<...,..>,...] ] ]#;

    So there are two machines with each five durations which include six tuple pairs each. 

    Unfortunately, I get a wrong parsing message in the data file. 

    The tuple could also be read out of an excel file, but I haven't found a valid formulation for this so far.

    Can anyone help me with it? 

     

    Best regards 

    CW

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to declare a tuple with two indices?

    Posted 01/25/19 11:32 AM

    Hi

    .mod

    range machines=1..2;

    range durations=1..5;

    tuple Maint_var { int S; int F;};

    Maint_var mvar [machines][durations] = ...;

    execute
    {
    writeln(mvar);
    }

    .dat

    mvar=[[<1,2>][<1,3>]];

    works fine and gives

     

    [[ <1 2>  <0 0>  <0 0>  <0 0>  <0 0>]
             [ <1 3>  <0 0>  <0 0>  <0 0>  <0 0>]]

    regards

     

    https://www.linkedin.com/pulse/puzzles-having-fun-useful-mathematics-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: How to declare a tuple with two indices?

    Posted 01/25/19 11:52 AM

    Originally posted by: ChWeil


    Thank you for your quick response. 

     

    Unfortunately, it does not work for me, because within the durations six different tuples must be included. If I formulate it like this, I get an error for the last tuple as it thinks the amount of tuples are the range of durations. 

     

    And if I write {Maint_var} without {}, I get an error in my next tuple which is written as 

     sorted {Step} Steps [machines][durations] = {100; mv.S | mv in mvar [m][d]} ...

     

    Do you have any idea how to solve it?

     

    Best regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: How to declare a tuple with two indices?

    Posted 01/25/19 11:58 AM

    Hi,

    if you need sets instead of tuples then you can write

    .mod

    range machines=1..2;

    range durations=1..5;

    tuple Maint_var { int S; int F;};

    {Maint_var} mvar [machines][durations] = ...;

    execute
    {
    writeln(mvar);
    }

    .dat

     

    mvar=[[{<1,2>,<1,4>}][{<1,3>}]];

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: How to declare a tuple with two indices?

    Posted 01/25/19 12:25 PM

    Originally posted by: ChWeil


    Ah perfect. It worked. 

     

    Thanks a lot!

     

    Best regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer