Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

How to declare 3D array in OPL studio

ALEX FLEISCHER

ALEX FLEISCHERTue November 19, 2019 07:51 AM

ALEX FLEISCHER

ALEX FLEISCHERThu November 28, 2019 02:53 AM

ALEX FLEISCHER

ALEX FLEISCHERThu January 02, 2020 04:22 AM

  • 1.  How to declare 3D array in OPL studio

    Posted Tue November 19, 2019 07:41 AM

    Originally posted by: Mathsg


    How to declare 1*6*6 array in data file? That is

    Int cmf [route][nodes][nodes] = …;

    While route = 1;

    Nodes = 1..6;

    Nodes = 1..6;

     

    How to write it in .data file. Kindly guide me in this regards. thank you 

     

    I have declare like this but it give me an error

    cmf = [ 1 [0 1 2 1 2 3]]
    [ 1 [1 0 1 1 2 2]]
    [ 1 [2 1 0 2 1 1]]
    [ 1 [1 1 2 0 1 2]]
    [ 1 [2 2 1 1 0 1]]
    [ 1 [3 2 1 2 1 2]]]


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to declare 3D array in OPL studio

    Posted Tue November 19, 2019 07:51 AM

    Hi

    .mod

    range route = 1..1;

    range nodes = 1..6;


    int cmf [route][nodes][nodes] =...;

    .dat

    cmf = [[  [0 1 2 1 2 3]
     [1 0 1 1 2 2]
      [2 1 0 2 1 1]
      [1 1 2 0 1 2]
      [2 2 1 1 0 1]
      [3 2 1 2 1 2]] ];

    work fine

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: How to declare 3D array in OPL studio

    Posted Thu November 28, 2019 12:28 AM

    Originally posted by: Mathsg


    Hi Alex,

    Thank you for your help. Now i am interested in 2 and 3 routes. how should i write the hope_count matrix for it?

    .mod

    int nbroutes=2

    range route = 1..nbroutes;

    range nodes = 1..6;


    int cmf [route][nodes][nodes] =...;

    How to write data file for it?

    and also i am interested if nbroutes =3

    Kindly guide me in this regards. thank you so much. i am looking forward to hearing from you


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: How to declare 3D array in OPL studio

    Posted Thu November 28, 2019 02:53 AM

    Hi,

    .mod

    range route = 1..2;

        range nodes = 1..6;


        int cmf [route][nodes][nodes] =...;

    .dat

    cmf = [[  [0 1 2 1 2 3]
     [1 0 1 1 2 2]
      [2 1 0 2 1 1]
      [1 1 2 0 1 2]
      [2 2 1 1 0 1]
      [3 2 1 2 1 2]]
     
      [  [0 1 10 1 2 3]
     [1 0 1 1 2 2]
      [2 1 0 2 1 1]
      [1 1 2 0 1 2]
      [2 2 1 1 0 1]
      [3 2 1 2 1 2]]
      ];

    regards

     

    PS: Many useful links at https://www.linkedin.com/pulse/low-barrier-entry-optimization-through-cplex-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: How to declare 3D array in OPL studio

    Posted Thu November 28, 2019 03:15 AM

    Originally posted by: Mathsg


    Hi alex, 

    thank you so much for your time and consideration. so nice of you. you are doing great job, keep it up


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: How to declare 3D array in OPL studio

    Posted Fri December 27, 2019 09:09 AM

    Originally posted by: Mathsg


    Hi Alex,

    I am interested to write 6*6*4 array in opl cplex.

    I have declared like this

    Int cmf [route][nodes][nodes] = …;

     

    How to write the data file?

    Nodes = 1..6;

    Nodes = 1..6;

    While route = 4;

    I have declared like 

    cmf = [[[[  [0 1 2 1 2 3]
     [1 0 1 1 2 2]
      [2 1 0 2 1 1]
      [1 1 2 0 1 2]
      [2 2 1 1 0 1]
      [3 2 1 2 1 0]]
     
      [ [0 2 3 2 3 4]
      [2 0 3 3 3 3]
      [3 3 0 3 3 2]
      [2 2 3 0 2 3]
      [3 3 3 3 0 2]
      [4 3 2 3 2 0]]] 
      
      [ [0 4 4 4 4 5]
      [4 0 4 4 3 4]
      [4 4 0 3 3 4]
      [4 3 3 0 4 4]
      [4 3 3 4 0 4]
      [4 4 4 4 4 0]]]
     
      [  [0 5 4 5 4 5]
     [5 0 5 5 3 4]
      [4 5 0 3 4 5]
      [5 4 3 0 5 4]
      [4 3 4 4 0 5]
      [5 4 5 4 5 0]] ];

     

    but it give me an error of data array unexpected  for int. Kindly help me. your help will be highly appricated. thank you


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: How to declare 3D array in OPL studio

    Posted Thu January 02, 2020 04:22 AM

    Hi

    .mod

    range nodes = 1..6;

     

    range route = 1..4;

    int cmf [route][nodes][nodes] =...;

    .dat

    cmf = [[  [0 1 2 1 2 3]
     [1 0 1 1 2 2]
      [2 1 0 2 1 1]
      [1 1 2 0 1 2]
      [2 2 1 1 0 1]
      [3 2 1 2 1 0]]
     
      [ [0 2 3 2 3 4]
      [2 0 3 3 3 3]
      [3 3 0 3 3 2]
      [2 2 3 0 2 3]
      [3 3 3 3 0 2]
      [4 3 2 3 2 0]]
     
      [ [0 4 4 4 4 5]
      [4 0 4 4 3 4]
      [4 4 0 3 3 4]
      [4 3 3 0 4 4]
      [4 3 3 4 0 4]
      [4 4 4 4 4 0]]
     
      [  [0 5 4 5 4 5]
     [5 0 5 5 3 4]
      [4 5 0 3 4 5]
      [5 4 3 0 5 4]
      [4 3 4 4 0 5]
      [5 4 5 4 5 0]] ];

    work fine

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer