Question & Answer
Question
How do I retrieve the cuts added by CPLEX during a MIP optimization?
Answer
Yes, there is a way to retrieve and export the cuts added by CPLEX.
To do so, use callbacks in the C API. First, define your own solve callback by means of the routine CPXsetsolvecallbackfunc
. The callback then calls the routine CPXgetcallbacknodelp
in order to get the relaxed model from the node of the branch and cut tree. Then export the model as a .lp file
. You can then compare those constraints to the constraints of the original model and determine the cuts that CPLEX added.
CPLEX adds cuts primarily at the root node, but also at subsequent nodes of the branch and cut algorithm it implements. If you wish to write out the cuts only for a specific range of nodes, your callback routine can check the node count, then decide whether to export the node LP .
Not only can you use a solve callback to generate node LPs at the root node, but you can also easily generate node LPs at arbitrary node counts or under other conditions. This technique enables you to see the cuts and also to investigate arbitrary node LPs at which you encounter any sort of unexpected behavior.
Click this attachment to access a complete sample that writes the node subproblem into a .SAV file for a specified range of nodes, with an optional parameter file if non default parameter settings are desired.
Historical Number
cplex/FAQ/148
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21400065