Forum Discussion
FICO
5 years agoCommunity Manager
Obtaining 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...
FICO
5 years agoCommunity Manager
- Q1: The numbers returned by getColNum() are established when XPRBprob.loadMat() is invoked. If you do not modify your problem afterwards in any way, then the function should return the index of the variable in the matrix. Notice however that this index is unrelated to the order in which you create the XPRBvar instances. It is defined by the order in which variables are extracted in loadMat().
- Q2: In order to fetch a single solution value you can use XPRSprob.getLpSolVal. Depending on how many values you need to fetch, it may be faster to fetch the whole array in one shot, though.
- Q3: Once the solution process has started, the indices in the original model are not going to change. So it is safe to precompute the name/index mapping.
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 unread1View0likes4CommentsVariable 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...8 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum6 unread comments6 unread1View0likes6CommentsAre 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 unread2Views0likes3Comments