Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Callback multiple definition error

    Posted Wed March 05, 2014 05:30 AM

    Originally posted by: Mimmo88


    Hello,
     
    I need to solve two models in the same application and each model has its ILOLAZYCONSTRAINTCALLBACK implementation.
    When I compile the code, the linker throws this exception:
    main.cpp:(.text+0x0): multiple definition of `MCFCallback(IloEnv, ...
    I have already implemented two classes that inherit IloCplex::LazyConstraintCallbackI and, in the main(), I have written the code regarding the separation procedures.
    What can I do?
     

     

    Thanks in advance
    Domenico

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Callback multiple definition error

    Posted Wed March 05, 2014 08:19 AM

    Did you use the same name for the two different callback classes?

    This errors messages looks like a genuine C++ programming error, not like something specific to CPLEX. Somehow you managed to define the MCFCallback function (or constructor) twice.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Callback multiple definition error

    Posted Wed March 05, 2014 08:41 AM

    Originally posted by: Mimmo88


    //UpperBoundLazyConstraintCallback.h
    
    class UpperBoundLazyConstraintCallbackI : public IloCplex::LazyConstraintCallbackI {
    ...
    };
    
    IloCplex::Callback UpperBoundLazyConstraintCallback(IloEnv env, IloNumVarArray z, IloNumVarArray w, const std::map<char, int> params) {
        return (IloCplex::Callback(new (env) UpperBoundLazyConstraintCallbackI(env, z, w, params)));
    }
    ...
    
    //MCFCallback.h
    class MCFCallbackI : public IloCplex::LazyConstraintCallbackI {
    ...
    };
    
    IloCplex::Callback MCFCallback(IloEnv env, const std::set<teseo::Arc<unsigned int>*> edges, IloNumVarArray x_ij, IloNumVarArray x_ji, const std::map<int, int> x_ij_map, const std::map<int, int> x_ji_map) {
        return (IloCplex::Callback(new (env) MCFCallbackI(env, edges, x_ij, x_ji, x_ij_map, x_ji_map)));
    }
    ...
    

    I use different names.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Callback multiple definition error

    Posted Wed March 05, 2014 08:50 AM

    Do you include MCFCallback.h from more than one file? If yes, do you use proper include guards in MCFCallback.h?


    #CPLEXOptimizers
    #DecisionOptimization