Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Linker errors

    Posted 08/28/10 12:47 PM

    Originally posted by: kc78


    Hi

    I'm using the CPLEX callable library and i am trying to compile some code with cplex. Even though i have another version of the program that compiled successfully with exactly the same definitions of the function, now i'm getting this linker error whilst the rest of the code utilising other CPX functions are ok:
    SolverInterface.obj : error LNK2019: unresolved external symbol _CPXgetmipx@20 referenced in function "struct OptSolutionData * __cdecl CPLEXRunSolver(int)" (?CPLEXRunSolver@@YAPAUOptSolutionData@@H@Z)

    SolverInterface.obj : error LNK2019: unresolved external symbol _CPXgetmipobjval@12 referenced in function "struct OptSolutionData * __cdecl CPLEXRunSolver(int)" (?CPLEXRunSolver@@YAPAUOptSolutionData@@H@Z)

    ..\WinNetGen\WinNetGen.exe : fatal error LNK1120: 2 unresolved externals

    The part of the code is :

    if (ProbType == MILP || ProbType == MIQP) {
    Status = CPXgetmipobjval(CPLEXenv, CPLEXModel, &(NewSolution->Objective));
    Status = CPXgetmipx(CPLEXenv, CPLEXModel, x, 0, NumberColumns-1);

    where Status is an int checking the status of the problem returned by solver and if i comment them out, the program is able to compile but i cannot retrieve the objective and solution values.

    What could be wrong or is there another way to retrieve the objective and solution data?

    Thank you
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Linker errors

    Posted 08/28/10 01:39 PM

    Originally posted by: SystemAdmin


    Might have something to do with the fact that those functions don't exist. :-) There's a CPXgetobjval and a CPXgetx, but I don't see a CPXgetmipobjval or CPXgetmipx in the docs.

    /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)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Linker errors

    Posted 08/28/10 02:48 PM

    Originally posted by: kc78


    Hi Paul

    I checked the CPLEX 12.1 callable library manual and it seems to have been deprecated...but in the cplex.h file:

    /* Accessing MIP Results */

    #define CPXgetmipobjval(env, lp, objval_p) \
    CPXgetobjval(env, lp, objval_p)
    #define CPXgetmipx(env, lp, x, begin, end) \
    CPXgetx(env, lp, x, begin, end)
    #define CPXgetmipslack(env, lp, slack, begin, end) \
    CPXgetslack(env, lp, slack, begin, end)
    #define CPXgetmipqconstrslack(env, lp, qcslack, begin, end) \
    CPXgetqconstrslack(env, lp, qcslack, begin, end)

    I'll try using the CPXgetobjval to see if it works!

    Thanks alot!
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Linker errors

    Posted 08/28/10 04:40 PM

    Originally posted by: SystemAdmin


    Hmm. Looks like someone made a valiant but unsuccessful effort to avoid breaking old code that used the deprecated methods. I've not used C++ in many years, but as I understand it, the #define commands should have caused the correct methods to be substituted at the time the code was compiled. The compiler apparently thought your syntax was correct (I wondered about that), but the linker seems to have been looking for the '...mip...' versions. Is it possible that macro substitution is turned off by some sneaky compiler switch? Otherwise, it looks like it's either a compiler bug or a compiler incompatibility. (Different behaviors by different compilers was one of those things that drove me screaming from C++ to Java.)

    /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)
    #CPLEXOptimizers
    #DecisionOptimization