Originally posted by: SystemAdmin
> > Thank you, so this means the passage "Not only does CPLEX® track all modifications of the model it has extracted, but also it tries to maintain as much solution information from a previous invocation of solve as is possible and reasonable. You have already encountered what is perhaps the most important modification method, that is, the method IloModel::add for adding modeling objects to a model. Conversely, you may call IloModel::remove to remove a modeling object from a model." in the manual does not apply to cuts added in a callback?
>
> Correct (as I understand things).
>
You understand correctly. Cuts are not remembered here.
> > To understand CPLEX a little bit better, what does my code do (nothing?)/why doesn't it result in some kind of error if the cuts automatically expire and then I remove them?
>
> Apparently it just fails silently. As a test (using the Java API, but C++ should be the same), I created a small model, created a constraint
>
but did not add it to the model, then invoked remove() on that constraint. No exception was thrown, and the model was unaffected.
>
It does not exactly
fail silently. Removing something that was never added is just a no-op. In order to check whether something is actually extracted to an algorithm you can use the isExtracted() method. As you already observed, it is safe to remove things that were never added.
#CPLEXOptimizers#DecisionOptimization