Forum Discussion
FICO
8 months agoCommunity Manager
Variable object mapping issue in Python Callbacks with Presolve enabled
Hi, I am implementing a Branch-and-Cut algorithm using the Xpress Python interface. I have structured my code as a class where I create variables (using xp.var) and store them in a dictionary attrib...
FICO
8 months agoCommunity Manager
We recommend that you work in the original problem space where possible, so that you do not need to worry about the presolve mapping. The getCallbackSolution function (and other related functions) postsolves the solution, returning values for all of your original variables, including those which were eliminated during presolve. So you can check connectivity without needing to do any mapping.
Things get a bit complicated when you need to query problem data such as bounds on variables, right-hand side values of constraints, or names of objects. This data is not available in the original space during the solve, so if you need to query it, it must be cached beforehand, as shown in my example.
In some cases it is necessary to work in the presolved space, for example if you want to add cuts to the problem during the preintsol callback, you need to express them using presolve indices, but we provide APIs to translate from original space to presolve space for this purpose: problem.presolverow. See an example here. And you can query the presolve mapping by calling problem.getpresolvemap. But this is advanced functionality that you hopefully will not need.
Related Content
Related Content
Variable names in callback (Java API)
I construct a cut in a preintsol callback using variables from the model containing the callback. When constructing the model, I give the variables names (using withName(...)) and store them in a vec...9 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum4 unread comments4 unread1View0likes4CommentsAre preintsol callbacks threadsafe?
The optimizer documentation states "When the MIP callbacks are called they are MUTEX protected to allow non threadsafe user callbacks." In my Java code for one-tree Benders, if I specify a single thr...9 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread2Views0likes3CommentsObtaining the variable values in a callback
In the XPRSoptNodeEvent callback, in order to separate valid inequalities, one must access the values of the variables. Let's say we want to obtain the values of XBRBvar[] myVarSubset. To my understa...5 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2Comments