there is no guarantee that the callback is called at every feasible primal solution.
Is there a way to get around this using Gurobi? I have run into a problem where only a part of the necessary LazyConstraints get added before the callback function is never called again.
Example execution could be: finding an optimal solution → calling my callback function → adding a violated lazy constraint → finding new optimal solution
At this point Gurobi terminates, having found “the optimal solution”. However if the callback function was called again, it would find a new violated constraint and have to resolve the problem.
I do have an example but it is quite lengthy. Luckily most of the code needn’t be understood except for the LazyConstraintCallback part. I tried to explain the problem in a bit more detail in the README file. Here is a link to the repository with the code.
I think that the final solution is indeed feasible for all lazy constraints that are added. However, I add one violated constraint at a time (a single callback function call), and at some point the callback function is just not called anymore, and the solution process terminates having found a solution that satisfies all constraints added so far.
Thank you very much. I rounded the current optimal solutions before using the values and set the callback to run only at integer solutions (before it was at all nodes). Now the solution is as expected.