Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

c++ cplex IloNumVarArray problem

  • 1.  c++ cplex IloNumVarArray problem

    Posted Thu July 04, 2013 07:54 AM

    Originally posted by: babyvera


    Hi all. I am the beginner of the c++ cplex. I have a qusetion about the IloNumVarArray. I spend 5 days on this question,but failed.

    First  I use  'IloNumVarArray' to set up a array with 5 elements, named f. Then use 'add' to make 5 arrays become a 5*5 matrix named fij. Third I want to row sum. Except use fij[1]+ fij[2]+ fij[3]+ fij[4]+ fij[5] , Are there any other way to solve this problem? Because the model have 1047*1047 matrix,  I will write down  fij[1]+ fij[2]...........fij[1047]. That maybe a hard work.

    Thank you!!!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: c++ cplex IloNumVarArray problem

    Posted Wed July 10, 2013 03:35 AM

    Hi,

    have a look at cplex\examples\src\cpp\ilodiet.cpp for example:

    you will read

    IloExpr expr(env);
          for (j = 0; j < n; j++) {
             expr += Buy[j] * nutrPer[i][j];
          }
          mod.add(nutrMin[i] <= expr <= nutrMax[i]);
          expr.end();

     

    and may adapt this sum to your specific problem

     

    regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: c++ cplex IloNumVarArray problem

    Posted Wed July 10, 2013 09:04 PM

    Originally posted by: babyvera


    Thank you for you help!!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer