Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Please help me check errors when creating a 2-d constant array.

    Posted 08/02/12 05:33 PM

    Originally posted by: SystemAdmin


    Hi all,
    I need to create a 2-d array for storing only float calculated constants. I tried to create it in two ways as follows:

    1)
    
    IloArray<IloNumArray> uSum0(env, h); 
    
    for (
    
    int i = 0; i < h; i++) 
    { uSum0[i] = IloNumArray(env, l);
    


    This way works fine!!

    2)
    
    IloArray<IloArray<IloNum>> uSum(env, h); 
    
    for (
    
    int i = 0; i < h; i++) 
    { uSum[i] = IloArray<IloNum> (env, l); 
    
    for (
    
    int s = 0; s < l; s++) 
    { uSum[i][s] = IloNum(env); 
    } 
    }
    


    But this way gave me error: error C2440: '<function-style-cast>' : cannot convert from 'IloEnv' to 'IloNum' during compilation.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Please help me check errors when creating a 2-d constant array.

    Posted 08/03/12 06:22 PM

    Originally posted by: SystemAdmin


    I'm not positive (I work with Java, not C++), but I'm pretty sure that IloNum is just an alias for double, does not have a constructor, and is not tied to an environment. So I think the compiler is looking at "IloNum(env)" as an attempt to cast env to an IloNum.

    You might want to look at one or two of the C++ examples that ship with CPLEX to see how IloNum is used in practice. When I was <nightmare>coding in C++</nightmare>, I don't think I ever used IloNum; I just used ordinary doubles.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Please help me check errors when creating a 2-d constant array.

    Posted 09/19/12 04:08 AM

    Originally posted by: SystemAdmin


    Paul is right. The statement
    
    IloNum(env)
    

    is the problem. IloNum is a primitive type (in fact it is double). Such types do not have a constructor that takes an IloEnv argument. They have a constructor but the only argument the constructor takes is a number.
    So you should rewrite this as
    
    uSum[i][s] = IloNum(0);
    

    or just
    
    uSum[i][s] = 0;
    

    #DecisionOptimization
    #MathematicalProgramming-General