Topic
7 replies Latest Post - ‏2013-01-25T08:07:14Z by SystemAdmin
mrmag
mrmag
29 Posts
ACCEPTED ANSWER

Pinned topic MIPInfoCallback extra information

‏2013-01-09T15:29:45Z |
Hello!

I want to get intermediate information about the best integer solution found (if an optimal is not found because of the time limit) during the search of CPLEX. For that purpose I created the following callback function:

ILOMIPINFOCALLBACK2(loggingCallback,
IloCplex, cplex,
IloNum, timeStart
)
{
if ( hasIncumbent() ) {
cout << getIncumbentObjValue() << endl;
cout << getNnodes() << endl;
cout << cplex.getCplexTime() – timeStart << endl;
cout << getNcuts(IloCplex::CutClique)+ getNcuts(IloCplex::CutCover) << endl;
}
}
// ...
cplex.use(loggingCallback(env, cplex, cplex.getCplexTime()));

Everything works find except the function getNcuts(). The program terminates with the following exception:

>> Concert exception caught: CPLEX Error 1003: Bad argument to Callable Library function.

Is there any method to get the number of cuts which were applied during the search up to the moment the current integer solution was found?
Updated on 2013-01-25T08:07:14Z at 2013-01-25T08:07:14Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7944 Posts
    ACCEPTED ANSWER

    Re: MIPInfoCallback extra information

    ‏2013-01-09T15:45:29Z  in response to mrmag
    What version of CPLEX do you use? I tried 12.5 and 12.4.0.1 here and with both of them your code did work without trouble.
    • mrmag
      mrmag
      29 Posts
      ACCEPTED ANSWER

      Re: MIPInfoCallback extra information

      ‏2013-01-10T08:44:34Z  in response to SystemAdmin
      Hello Daniel,

      I use CPLEX 12.4 and it definitively shows that error message. I will try to update my CPLEX.
      • SystemAdmin
        SystemAdmin
        7944 Posts
        ACCEPTED ANSWER

        Re: MIPInfoCallback extra information

        ‏2013-01-10T10:41:52Z  in response to mrmag
        Very weird. Even with 12.4.0.0 I cannot reproduce your problem.
        Can you please double check that you did post all the relevant code?
        I have attached the program that I used for testing. Maybe you can check whether it works for you?
        • mrmag
          mrmag
          29 Posts
          ACCEPTED ANSWER

          Re: MIPInfoCallback extra information

          ‏2013-01-18T10:26:07Z  in response to SystemAdmin
          Hello Daniel,

          I updated the CPLEX to version 12.5 and the error disappeared. That’s fine now. Thank you.

          The idea of the code was the following. Every time CPLEX finds a better feasible integer solution I save the time, number of nodes and cuts which were generated in order to get this solution. For that purpose I designed the following code (also attached to the message):

          ILOMIPINFOCALLBACK7
          (loggingCallback,
          IloCplex, cplex,
          IloNum, timeStart,
          IloNum &, outObjValue,
          IloInt &, outNnodes,
          IloNum &, outTime,
          IloInt &, outNcuts,
          IloInt &, outUserCuts
          )
          {
          try
          {
          if ( hasIncumbent() && getIncumbentObjValue() < outObjValue ) {
          outObjValue=getIncumbentObjValue();
          outNnodes=getNnodes();
          outTime=cplex.getCplexTime() - timeStart;
          outNcuts=cplex.getNcuts(IloCplex::CutClique);
          outUserCuts=getNcuts(IloCplex::CutUser);
          }
          }
          catch (IloException& e) {
          std::cerr << "Concert exception caught: " << e << std::endl;
          }
          catch (std::string exs) {
          std::cerr << exs << std::endl;
          }
          }

          which runs with the following exception:

          >> Concert exception caught: CPLEX Error 1217: No solution exists.

          But there are solutions. Is there any proper way to solve that problem?
          • SystemAdmin
            SystemAdmin
            7944 Posts
            ACCEPTED ANSWER

            Re: MIPInfoCallback extra information

            ‏2013-01-18T15:22:01Z  in response to mrmag
            That looks like a bug. Unfortunately, I cannot reproduce that here (using CPLEX 12.5.0.0 and your code). Can you tell which of the functions in the callback throws the exception?
            • mrmag
              mrmag
              29 Posts
              ACCEPTED ANSWER

              Re: MIPInfoCallback extra information

              ‏2013-01-22T10:37:27Z  in response to SystemAdmin
              Hello Daniel,

              the function which throws the exception is getNcuts(). I found out that the user must not call cplex.getNcuts(), but the one in the ILOMIPINFOCALL invironment. It still throws the exception with parameters like CutUser and so on. But it does not throw the exception with the common cuts like CutClique. So, it is okay now and the question is answered. Thank you for help.
              • SystemAdmin
                SystemAdmin
                7944 Posts
                ACCEPTED ANSWER

                Re: MIPInfoCallback extra information

                ‏2013-01-25T08:07:14Z  in response to mrmag
                You are right. Querying the number of user cuts is not supported from the MIP info callback. I will investigate and either file a bug report or a user wish for that.