Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to create a 3 dimension array in C#

    Posted 06/27/11 12:32 PM

    Originally posted by: SystemAdmin


    Trying to create a 3d variable but keep getting errors when invoking the numarrray method, my code is:

    int pc, mc, plc;

    INumVar][[] vProd = new INumVarpc][[];

    for (i = 0; i < pc; i++)
    {
    for (j = 0; j < mc; j++)
    {
    vProd[i][j] = cplex.NumVarArray(plc,0.0,System.Double.MaxValue);
    }
    }

    Any suggestions will be greatfull.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to create a 3 dimension array in C#

    Posted 06/27/11 12:37 PM

    Originally posted by: SystemAdmin


    Maybe it is just bad formatting but it looks to me as if you did not initialize the second dimension of your array. Does this work
    int pc, mc, plc;
     
    INumVar[][][] vProd = new INumVar[pc][][];
     
    for (i = 0; i < pc; i++)
    {
        vProd[i] = new INumVar[mc][]; // This line is not in your original code.
        for (j = 0; j < mc; j++)
        {
            vProd[i][j] = cplex.NumVarArray(plc,0.0,System.Double.MaxValue);
        }
    }
    

    #CPLEXOptimizers
    #DecisionOptimization