Forum Discussion
FICO
1 year agoCommunity Manager
how to use getcpcuts() and delcpcuts() method in python library?
Hello, I’m currently implementing a Benders decomposition algorithm using the Xpress Python library. I'm working on a model that exhibits basic characteristics of the Traveling Salesman Problem (TSP...
FICO
1 year agoCommunity Manager
Hi,
There is a TSP example in the online documentation that uses .addcuts() to provide sub-tour elimination constraints within the preintsol callback:
Unfortunately, it doesn't show you how to delete cuts since this example assumes it is unnecessary to remove constraints once they have been added. When cuts are added to a node problem by .addcuts(), they are only applied to the current node and its descendants.
Could you provide a snippet of code that you use within your preintsol callback? This would help us understand how you are calling these cut management functions.
You are correct that any cuts added by .addcuts() are automatically and immediately stored within the user cut pool. To retrieve these cuts from the cut pool, you should first call .getcpcutlist()
to retrieve the references to the cuts in the pool. Note that this function will retrieve a subset of your cuts, depending on the 'cuttype', 'interp' and 'delta' arguments. To retrieve all cuts, you would set 'interp = -1' and 'delta = -xpress.infinity`. The function will return a list of cut references, which you can then pass to .getcpcuts() to retrieve the actual cut coefficients.
You should be aware that adding or deleting cuts from the user cut pool does not have any impact on the active cuts currently loaded into node problems of the branch-and-bound search tree. The pool is only provided as a convenience for accessing user cuts that have been stored previously. Deleting a cut from the pool only means that it is no longer available through .getcpcuts().
To remove cuts from a node problem and its descendants, you have to call .delcuts().
You can call this function without a list of cut references if you want to e.g. remove all inactive cuts from the current node.
Best Regards,
Michael
Related Content
Related Content
Is it possible that the XPRESS c-libraries can be called directly from Python using ctypes?
I have successfully called a C dll from Python (using ctypes) that calls XPRMInit, XPRMloadmod etc but it would be nice to avoid the need to create the DLL altogether and call these functions direc...8 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum9 unread comments9 unread0Views0likes9Comments
