IBM Support

Sample C program to retrieve the cuts added by CPLEX during a MIP optimization

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 wrtnode.cto 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.

[{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF014","label":"iOS"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"12.6;12.5;12.4;12.3;12.2","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

cplex/FAQ/148

Document Information

Modified date:
16 June 2018

UID

swg21400065