Decision Optimization

Decision Optimization

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

 View Only
  • 1.  How to declare a 4D array?

    Posted Mon August 24, 2009 04:58 PM

    Originally posted by: SystemAdmin


    [zhzhang said:]

    How to declare a 4D array in concert?
    My code is:
    IloArray<IloNumVarArray<IloNumVarArray<IloNumVarArray> > > IloNumVarArray4;

    is it right?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to declare a 4D array?

    Posted Wed August 26, 2009 01:59 PM

    Originally posted by: SystemAdmin


    [TheEngineer said:]

    That code is pretty much unreadable for other people and I guess it will not be working.

    For my 3d arrays I use the following snippet:

    typedef IloArray<IloNumVarArray> NumVarMatrix;
    typedef IloArray<NumVarMatrix> NumVarMatrix3d;

    To extend it to 4 dimensions you could use (I did not test it yet):
    typedef IloArray<NumVarMaxtrix3d> NumVarMatrix4d;


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to declare a 4D array?

    Posted Thu April 19, 2012 04:31 AM

    Originally posted by: lriWANGCHEN


    I also want to define a 4d array like y[i][j][s][t] by C++, and the element in the array is 0<=y<=1.

    As you said, I can define the typedef, but how can I give the define the range of the array? I just do it like this, but then?

    NumVarMatrix4d Y(env,n);
    for(int i=0;i<n;i++)
    {
    Y[i]=NumVarMatrix(env,n);
    }

    Thank you.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How to declare a 4D array?

    Posted Thu April 19, 2012 04:34 AM

    Originally posted by: lriWANGCHEN


    as the question above, if I define it like this ,is it right?

    NumVarMatrix4d Y(env,n);
    for(int i=0;i<n;i++)
    {
    Y[i]=NumVarMatrix(env,n);
    for(int j=0;j<n;j++)
    {
    Y[i][j]=IloNumVarArray(env,n,0.0,1.0,ILOFLOAT);
    }
    }

    Thank you very much.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: How to declare a 4D array?

    Posted Fri April 20, 2012 02:19 AM

    Originally posted by: SystemAdmin


    As far I can see you initialize only 3 dimensions. Something like this could work:
    NumVarMatrix4d Y(env,n);
    for(int i=0;i<n;i++)
    {
       Y[i]=NumVarMatrix3d(env,n);
       for(int j=0;j<n;j++)
       {
          Y[i][j] = NumVarMatrix(env, n);
          for (int k = 0; k < n; ++k)
             Y[i][j][k]=IloNumVarArray(env,n,0.0,1.0,ILOFLOAT);
       }
    }
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: How to declare a 4D array?

    Posted Fri April 20, 2012 02:17 AM

    Originally posted by: SystemAdmin


    You cannot specify the length of the arrays in the typedef. The length of the arrays is a runtime property.
    #CPLEXOptimizers
    #DecisionOptimization