Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Question about how to sum IloNumArray

    Posted 12/30/15 06:45 AM

    Originally posted by: Selectedbetter


    Hello everyone,  we need some help about how to sum a const IloNumArray3, the question is:

    At the first, we have "const IloIntVarArray3 x" in the void();

    Let the x[i][j][k] represent the IloIntVarArray3 x. 

    Then, we want to sum all k in a  given i and j, that is sum (x[i][j]), but we don't know how to do with.

    We have tried like:

    IloExpr expr(env);

    for(k=0;k<n;++k)

     {
        expr+=x[i][j][k];                    
      }          

    but we got an error says"IloExpr& IloNumExpr::operator+=const IloIntVar arg: mixing mismatch Environments" .

    Wish all of you a happy new year!

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Question about how to sum IloNumArray

    Posted 12/31/15 03:46 AM

    Hi,

    you wrote

    IloExpr expr(env);

    I wonder why you do not use the IloEnv you used previously for x

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Question about how to sum IloNumArray

    Posted 12/31/15 07:54 PM

    Originally posted by: Selectedbetter


    Dear AlexFleischer

    Thank you for answering our question!

     

    Under the void(); we have gotten the env like:

    IloEnv env = cplex.getEnv();

    so, when we need sum x[i][j], we just write 

    IloExpr expr(env);

    Do you mean the environment of x shoule be defined? But we think the environment have already declared in the void().

    Actually, We want to know how to sum the x[i][j] up if we don't use the "expr".

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Question about how to sum IloNumArray

    Posted 01/04/16 01:35 AM

    What do you mean by 'in the void()'? Is this a function? Is this a callback's main() function?

    Can you try this:

    IloExpr expr(x.getEnv());
    for (k = 0; k < n; k++)
       expr += x[i][j][k];
    

    That should avoid the error about mixing environments.


    #CPLEXOptimizers
    #DecisionOptimization