Originally posted by: SystemAdmin
Yes, this can be done using lazy constraints. Actually it is the purpose of lazy constraints.
There are two ways to do it:
1. Create
all the constraints before you start the solve. Register some of them as hard constraints and some as lazy constraints. CPLEX will then look at the lazy constraints whenever it finds an integer feasible solution. If the solution satisfies all lazy constraints then it is accepted. If it violates a lazy constraint then this constraint is added to the set of hard constraints and the solution is rejected.
2. Depending on the number of lazy constraints, generating all of them up front may not be a good idea. In that case you can implement a lazy constraint callback. This callback is invoked whenever CPLEX finds an integer feasible solution. The callback can then either accept the solution or produce a lazy constraint that is violated by the solution. This allows you to dynamically generate lazy constraints on an as-needed basis.
We implemented some improvements concerning the handling of lazy constraints in version 12.3, so you may want to consider upgrading to that version. It is not required though, lazy constraints work in 12.2 as well.
#CPLEXOptimizers#DecisionOptimization