Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

using two dimensional array

  • 1.  using two dimensional array

    Posted Thu June 19, 2014 06:48 AM

    Originally posted by: saeeds


    Hi,

    I am going to use lagrangian relaxation for my model. I looked at the example which exists in CPLEX (location-transportation problem) and tried to write my codes according to it. For defining slacks, the example uses the following lines:

     var slack = new Array(thisOplModel.nbCities);
      var temp = new Array(thisOplModel.nbCities);
      var mult = new Array(thisOplModel.nbCities);
      var UB = 0;
      for (var i in thisOplModel.cities) {
        slack[i] = 0.0;
        UB += maxArray(thisOplModel.ship_cost[i]);
        temp[i] = 0.0;
        mult[i] = 0.0;
      } 

    Here, these arrays are one dimensional, but in my problem, I need to define slack, temp, and mult variable as two dimensional arrays. How should I define these variables as two dimensional? (for example slack[i][j], ...)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: using two dimensional array

    Posted Sat June 21, 2014 07:28 AM

    Hi

    let me give you an example

    execute
    {

    var x = new Array(10);
      for (var i = 0; i < 10; i++) {
        x[i] = new Array(10);
      }
      x[1][4] = 5;;
      writeln(x[1][4]);
    }


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: using two dimensional array

    Posted Sun June 22, 2014 12:21 PM

    Originally posted by: saeeds


    It works,

    thanks man! :)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer