Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  a problem to implement a callback class

    Posted 03/05/09 04:15 AM

    Originally posted by: SystemAdmin


    [zhzhang said:]

    Based on Example: Controlling Cuts iloadmipex5.cpp, I implement my CutCallback class as follows:

    class polycutI:public IloCplex::CutCallbackI{
            IloIntArray      cita;
            IloNumVarArray x;
            IloNumVar        z;
    public:
            IloCplex::CallbackI* duplicateCallback() const{
                    return (new(getEnv()) polycutI(*this));
            }
           
            polycutI(IloIntArray cita1,IloNumVarArray x1,IloNumVar z1):cita(cita1), x(x1), z(z1){}
            void main();
    };

    IloCplex::Callback polycut(IloEnv env,
                                    IloIntArray cita1,
                                    IloNumVarArray x1,
                                    IloNumVar      z1)
    {
            return (IloCplex::Callback(new (env) polycutI(cita1,x1,z1)));
    }

    void polycutI::main()
    {...}

    However, it cannot be compiled correctly. Error message:
    g++ -c -g -fpic -fexceptions -DNDEBUG -DIL_STD -I/usr/local/cplex110/include -I/usr/local/concert25/include test.cpp
    test.cpp: In constructor `polycutI::polycutI(IloIntArray, IloNumVarArray, IloNumVar)':
    test.cpp:31: error: no matching function for call to `IloCplex::CutCallbackI::CutCallbackI()'
    test.cpp:28: note: candidates are: IloCplex::CutCallbackI::CutCallbackI(const IloCplex::CutCallbackI&)
    /usr/local/cplex110/include/ilcplex/ilocplexi.h:2175: note:                IloCplex::CutCallbackI::CutCallbackI(IloEnv)


    I don't know how to revise my code because it is almost same as the example.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: a problem to implement a callback class

    Posted 11/08/09 11:51 PM

    Originally posted by: SystemAdmin


    [MMorin01 said:]

    Hello,
    You have probably found a solution now, but I will make a guess just in case:

    You need to call the constructor of the base class... So you have to replace the following line
      polycutI(IloIntArray cita1,IloNumVarArray x1,IloNumVar z1):cita(cita1), x(x1), z(z1){}
    by something like that
      polycutI(IloEnv env, IloIntArray cita1,IloNumVarArray x1,IloNumVar z1):CutCallBackI(env), cita(cita1), x(x1), z(z1){}

    It might be totally wrong... but it's my guess. The fact is that there is no default constructor for the class CutCallBackI.

    M.
    #CPLEXOptimizers
    #DecisionOptimization