Originally posted by: SystemAdmin
The
duplicateCallback function should return a clone of the callback. In your implementation this is not the case since the
x field is not cloned (so the clone will have an empty
x field). So IMO the
duplicateCallback function should read
IloCplex::CallbackI *duplicateCallback() const {
return new (getEnv()) CutCallbackModel1(getEnv(), x);
}
Here is how the
duplicateCallback function is used:
When CPLEX runs a solve on multiple threads then it invokes
duplicateCallback for each thread so that there is a different instance of the callback class for each thread. The different threads then invoke their thread-specific callback instance during the solve.
So, if you use only one thread then
duplicateCallback will never be invoked (and can be anything). If you use more than one thread then the function will be invoked and the value it returns should be a clone of the callback.
Note that in parallel callbacks you may need to use locks (you can use class IloFastMutex) to avoid race conditions.
#CPLEXOptimizers#DecisionOptimization