Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to modify the data of a two dimension IloNumArray?

    Posted 09/19/08 04:19 PM

    Originally posted by: SystemAdmin


    [T.B. said:]

    In many cases, we will give data to a two dimension array by the following way:
    #include <ilcplex/ilocplex.h>
    ILOSTLBEGIN
    typedef IloArray<IloNumArray> IloNumArray2;
    ………
    int main(void){
    IloEnv env;
    IloNumArray2 cost(env,4);
    cost[0]=IloNumArray(env,8,6,2,6,7,4,2,9,5);
    cost[1]=IloNumArray(env,8,4,9,5,3,8,5,8,2);
    cost[2]=IloNumArray(env,8,5,2,1,9,7,4,3,3);
    cost[3]=IloNumArray(env,8,7,6,7,3,9,2,7,1);
    ……………
    }

    But this time suppose we have a matrix price[4][8], and how can I send the data in the matrix [i]price [/i] to the IloNumArray2 cost?

    This is very important, for very often we have to read data from outer file, such as database, excel, and so on. I have tried the following way, but fail:
    …..
    int main(void){
    IloEnv env;
    IloNumArray2 cost(env,4);
    int price[4][8]={
    {6,2,6,7,4,2,9,5},
    {4,9,5,3,8,5,8,2},
    {5,2,1,9,7,4,3,3},
    {7,6,7,3,9,2,7,1}};
    IloNumArray x(env,8);
    for(int i=0;i<4;i++){<br />  for(int j=0;j<8;j++){<br />  x[j]=price[i][j];
    }
    cost[i]=x;
    }
    …….
    }

    Is there any way to do the job?
    P.S. 1. the cplex version is cplex9.0
        2. the model should be built by row.

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to modify the data of a two dimension IloNumArray?

    Posted 12/04/08 12:27 AM

    Originally posted by: SystemAdmin


    [alain.chabrier said:]

    Hi,

    what about something like :


    for(int i=0;i<4;i++){<br />  cost[i] = ILoNumArray(env, 8);
      for(int j=0;j<8;j++){<br />  cost[i][j]=price[i][j];
    }
    }

    Alain
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to modify the data of a two dimension IloNumArray?

    Posted 12/04/08 12:27 AM

    Originally posted by: SystemAdmin


    [T.B. said:]

    Hi,Alain

    your suggestion fits my question perfectly!
    Thanks a lot!

    T.B.
    #CPLEXOptimizers
    #DecisionOptimization