Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  how to read multidimensional array from excel

    Posted 07/23/19 04:17 PM

    Originally posted by: Sultan_Niz7755


    Hello, everybody, 
    I turn to you regarding the question "how do you read 3 dimensional data from Excel? I looked at IBM's sample and other samples you have discussed, but that didn't really help much. Since I am supposed to use Sample Average Approximation here, the new dimension is added as S. Then there are 3 scenarios. That means I have to copy the Processing Times, which consists of 10 rows and 5 columns, 3 times among each other, that's what I did, but what keeps me is the question how to read from Excel.

     

    Regards,

    Sherzod
     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: how to read multidimensional array from excel



  • 3.  Re: how to read multidimensional array from excel

    Posted 07/25/19 06:35 AM

    Originally posted by: Sultan_Niz7755


    Hello, Alex,

    Thank you so much for your feedback. I looked at the links on the left and modified my model accordingly. But I got error:The array data element "p" of type int with 3 dimensions is not supported for worksheets. Could you help me?   

    int N = ...;
    int j = ...;
    int Level = ...;
    range S = 1..Level;

    // If the data elements are in a 2 dimensional array
    int nb2[1..N*Level, 1..j] = ...;
    int nbArray2[m in 1..N, p in 1..j,l in 1..Level] = nb2[l+Level*(m-1),p];

    // declare data
      range Patient = 1..N;
      range Task = 1..j;
      int P = ...; // Number of Porters
      range Porter = 1..P;
      int R = ...; // Number of Operating rooms
      range Room = 1..R;
      int B = ...; // Number of recovery beds
      range Bed = 1..B;
      int Period = ...;
      range H = 0..Period-1; // discrete Time horizon of H Periods, The discrete Time unit is set equal to 10 Minutes
      
       // declare parameter
      int p[Patient,Task,S] = ...;//  processing times of the task j relared to patient i
      dvar int+ c[Patient, Task,S];
      dvar boolean delta[Patient, Task, H,S];// it indicates whether task (i,j) active or not
      dvar int+ s[Patient, Task,S]; //decision variable, starting time of the task j related to patient i

      
      //OF
      minimize sum(i in Patient,l in S) c[i,4,l] / 3;
      
       subject to {
      
      forall (i in Patient,l in S) s[i, 1,l] + p[i, 1, l] <= s[i, 2, l];    // constraint 1
      forall (i in Patient,l in S) s[i, 2, l] + p[i, 2, l] == s[i, 3, l];    // constraint 2
      forall (i in Patient,l in S) s[i, 2, l] + p[i, 2, l] == s[i, 5, l];    // constraint 3
      forall (i in Patient,l in S) s[i, 3, l] + p[i, 3, l] <= s[i, 4, l];    // constraint 4
      forall (i in Patient, j in Task,l in S) s[i,j,l] + p[i,j,l]==c[i,j,l];// cons 5
      forall (i in Patient, j in Task, t in H,l in S) delta[i, j, t,l] == ((s[i, j,l] <= t)  && (s[i, j,l] + p[i, j,l] - 1) >= t); // cons 6
      forall (t in H, pi in Porter,l in S)  sum(i in Patient) (delta[i, 1, t,l] + delta[i, 4, t,l]) <= pi; // cons7
      forall (t in H, r in Room,l in S)  sum(i in Patient) (delta[i, 2, t,l] + delta[i, 5, t,l]) <= r; // cons8
      forall (t in H, b in Bed,l in S)  sum(i in Patient) (delta[i, 3, t,l]) <= b; //cons9
      
       }
        

    execute {
       writeln(nbArray2);
    };

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: how to read multidimensional array from excel

    Posted 07/25/19 10:04 AM

    Hi,

    you cannot read directly a 3D array through sheetRead.

    You need to read one or many 2D arrays and then do the conversion

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer