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?