I am using CPLEX 12.9 to solve a mixed integer linear programming problem. Some of my constraints are enforced through a legacy LazyConstraintCallback. Heuristic solutions are inserted through a legacy HeuristicCallback. My implementation is in C++.

To insert a heuristic solution, I use the following function:

public void setSolution(const IloIntVarArray vars, const IloNumArray vals)

For each variable in the array vars, this method uses the value in the corresponding element of the array vals to define a heuristic solution to be considered as a new incumbent.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyzes the solution and, if it is both feasible and better than the current incumbent, uses it as the new incumbent. A solution is specified using arrays vars and vals, where vals[i] specifies the solution value for vars[i].

Do not call this method multiple times. Calling it again will overwrite any previously specified solution.

From the CPLEX documentation.

To my surprise, CPLEX will accept solutions that satisfy the current constraints, but violate the lazy constraints. For my application, this is actually very convenient, because I can guarantee that my solutions satisfy the lazy constraints, and skipping the verification saves time.

However, I do have the following questions:

  • Is it intentional that the LazyConstraintCallback is not called to verify a manually provided solution?
  • Is it guaranteed that the LazyConstraintCallback is never called for a manually provided solution?

1 Answer 1


I think the answers to both questions are yes. The documentation for LazyConstraintCallback.getSolutionSource says the following: "Note that lazy constraint callbacks are not invoked for solutions provided by a heuristic callback."

I vaguely recall discussing this someplace (possibly on a forum, but not recently, and I can't find the discussion) and being told the logic in essence is that if the user has a feasibility "oracle" (the lazy constraint callback) and the user provides a solution, the user should be responsible for testing it before injecting it. That makes sense to me.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.