Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloExprArray cannot work in C++

    Posted 12/10/13 06:08 PM

    Originally posted by: Broncho


    Dear all,

    In my codes, Matrix is an int type matrix. P is a variable array. I would like to give constraints for my LP problem. So, I define an IloExprArray to record the sum of Matrix*P for each row. But when I run the codes, it is blocked at the line of temp[j]+=Matrix[j][i]*P[i];. I also try to print  "temp", nothing can be printed. No problems can be found in Matrix and P because I can print them. I think I may not use IloExprArray correctly. But when I read the references, it looks OK. I don't know the reason why "temp" cannot work. Please help me. Thanks!

    IloExprArray temp(env, 70);
     
    for(j=0;j<70;j++)
    {
     
    cout<<temp[j]<<endl;
    for(i=0;i<60;i++)
    {
     
    temp[j]+=Matrix[j][i]*P[i];
     
    }
     
    }

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: IloExprArray cannot work in C++

    Posted 12/11/13 03:21 AM

    I think you missed this detail in the reference documentation of IloExprArray(IloEnv, IloInt):

    This constructor creates an array of n elements. Initially, the n elements are empty handles.

    So you should do

    temp[j] = IloExpr(env);

    before you access temp[j] for the first time.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: IloExprArray cannot work in C++

    Posted 12/11/13 06:50 AM

    Originally posted by: Broncho


    Thanks! It works!


    #CPLEXOptimizers
    #DecisionOptimization