Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  [cplex in java] 3D matrix with bounds

    Posted 01/16/12 04:35 AM

    Originally posted by: lokoloko


    Hi,

    How can I write in java using library cplex.jar matrix u[7][2][2] with bounds 0<=u=<1?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: [cplex in java] 3D matrix with bounds

    Posted 01/16/12 04:48 AM

    Originally posted by: SystemAdmin


    Just create a standard 3D array of IloNumVar and fill each slot in that array individually. Or use the IloCplex.numVarArray() functions that returns a one-dimensional array to keep your code a little shorter:
    IloCplex cplex = new IloCplex();
    final int dim1 = 7;
    final int dim2 = 2;
    final int dim3 = 2;
    final double lb = 0;
    final double ub = 1;
     
    IloNumVar[][][] array3d = new IloNumVar[dim1][][];
    for (int i = 0; i < array3d.length; ++i) {
       array3d[i] = new IloNumVar[dim2][];
       for (int j = 0; j < array3d[i].length; ++j)
          array3d[i][j] = cplex.numVarArray(dim3, lb, ub);
    }
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: [cplex in java] 3D matrix with bounds

    Posted 01/16/12 05:27 AM

    Originally posted by: lokoloko


    OK. Another qustion. I have got constraint like that:
    sum after d
    
    u[d][i][j]<=1. If cplex.jar has function to do that or rather do that in 3 loops:
    for(int d=0;d<....)
    {
        for(int i=0;...)
        {
           for(int j=0;...)
           {
              u[d]+=u[d][i][j]
           }
        }
    }
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: [cplex in java] 3D matrix with bounds

    Posted 01/17/12 11:07 AM

    Originally posted by: SystemAdmin


    Maybe have a look at the reference manual here?
    The CPLEX Java API does not provide a function to sum over a three dimensional array. So you will have to use the loops you indicated.
    #CPLEXOptimizers
    #DecisionOptimization