Originally posted by: KTAT_Leonardo_Lamorgese
Hi,
I am having problems with implementing a callback for adding lazy constraints in integer branching nodes.
In my model i have two sets of variables: S (continous variables) and Y (Integer variables), and two sets of constraints (A with only S var's and B with both S and Y).
I start the optimization with a core problem of all and only constraints belonging to A.
As CPLEX branches, when it finds an integer solution, I implemented a callback which verifies if the solution is feasible. If not, I want to add the (lazy) constraints in B (so both S and Y variables) that are violated, hence narrowing the feasible region.
By reading some posts I was under the impression that the best way to do so is by using a LazyConstraintCallback, so I tried to follow the Benders cut implementation.
I implement an extension of LazyConstraintCallback and create an instance of this class in the main method, with the instruction cplex.use(LazyConsCallback(.....), which in my understanding should tell CPLEX to use the callback in every integer node.
What happens when CPLEX solves is that it only finds the optimal solution to the core problem (not feasible in the master problem), as if it didnt add any LazyConstraints.
In my debugging attempt it seems to me as if the main() method in my LazyConstraintCallback extension is never called by CPLEX (I simply tried inserting a System.out object in the main() but nothing is printed in output).
On the otherhand the new instance of LazyConstraintCallback is definetly created.
Is there something I'm missing? To add the IloConstraint objects don't
I hope I was clear enough, thank you for your help
Leo
#CPLEXOptimizers#DecisionOptimization