Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Dynamically use 2D variable to create 3D variable

    Posted 05/20/16 10:33 AM

    Originally posted by: hugotorres


    I need to create a variable which has 3 indexes, let's say they're i for resource, j for zone and k for subzone. I have the resources organized in 11x11 matrixes, related to bases vs subzones. Each of this matrixes has the name Zone_X in excel and I need to import each one of them to the variable, to have it in a format described above. Can this be done by defining the range of the zones, and then dynamically allocating the matrixes to the vector? something like:

    z = 2000

    range zones = 1..z.;

    //create a cycle here

    var[zones] = zone_(zones)

     

    Would something like this work? I'm asking to get ahead on my work, since I don't have the excel file ready yet, just want to discuss the best way to do this


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Dynamically use 2D variable to create 3D variable



  • 3.  Re: Dynamically use 2D variable to create 3D variable

    Posted 05/24/16 08:15 AM

    Originally posted by: hugotorres


    Now that I see it, I might have phrased it wrongly. 

    I have a ~8400*11 matrix, and this is what I want to import to CPLEX. This matrix aggregates all data from all zones I have to consider, each zone in a 11x11 matrix.

    What I want to do is to create a cycle where zones[i] corresponds to the matrix starting in the i*11 row and ends on the (i+1)*11 row. Each 11x11 matrix has bases as rows and subzones as columns, so in the end, the matrix zones will be something like zones[i][base][subzone].


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Dynamically use 2D variable to create 3D variable

    Posted 05/25/16 04:41 AM

    Hi,

    do you mean your 2D and 3D array should have the same total number of cells ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Dynamically use 2D variable to create 3D variable

    Posted 05/25/16 08:20 AM

    Originally posted by: hugotorres


    Yes, sort of. I have an example I can use to illustrate this:

     

     

    The 3D array array[x][y][z] should have x as 1,2, etc, the ones on the far left side, and inside each one, the're supposed to have the matrix in front of it, which are [y]*[z]


    #DecisionOptimization


  • 6.  Re: Dynamically use 2D variable to create 3D variable

    Posted 05/26/16 06:09 AM

    Hi,

    what about something like

    int N=11;
    int M=10;

    int A[ij in 1..M*N][k in 1..N]=rand(10);

    int B[i in 1..M][j in 1..N][k in 1..N]=
    A[1+(i-1)*N+(j-1)][k];

    assert sum(ij in 1..M*N,k in 1..N) A[ij][k]==
    sum(i in 1..M,j in 1..N,k in 1..N) B[i][j][k];

    ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer