Forum Discussion
FICO
1 year agoCommunity Manager
getCallbackSolution failing and yielding error 422 inside a chgbranchobject callback?
Hi sll,I'm using the Python API of the Xpress Optimizer to try and implement through the addcbchgbranchobject callback a custom branching choice during a MIP search.According to the reference manual,...
FICO
1 year agoCommunity Manager
Thank you Daniel for your reply and sorry for my laconic one,unfortunately I got my account blocked for whatever reason as I tried to attach multiple screenshots.This time I'll paste the code as plain text,for good measure.After the model definition we have:
class controldata:
def __init__(self,inputdata,outputdata,bestbound,nodenumber,brancher,threshold,threshindex,Mleft,Mright):
self.bestbound=bestbound
self.inputdata=inputdata
self.outputdata=outputdata
self.nodenumber=nodenumber
self.brancher=brancher
self.threshold=threshold
self.threshindex=threshindex
self.Mleft=Mleft
self.Mright=Mright
controlmatrix=controldata(X,y,10000,[],[],[],[],[],[])
(An object to be passed to the callback,useful only for providing the input and output samples X and y,most of the attribute lists were meant for an early implementation and will stay empty)
def spatialbranch(prob,obj,obranch):
N=np.shape(obj.inputdata)[0]
X=(obj.inputdata)
y=(obj.outputdata)
h=math.floor(0.8*N)
sol=prob.getCallbackSolution(z)
(The actual callback,up to the point where the issue is encountered.We might argue that z is not defined inside the function,but only as an xpress object of the prob we'll pass as input argument;still,even using getCallbackSolution() with no argument inside the brackets to get the full solution will result in the execution stopping with error 422).
I add the callback to the problem with p.addcbchgbranchobject(spatialbranch,controlmatrix,5),and I then optimize with p.mipoptimize().
As for the CSV file,it's one of several regression datasets available on Kaggle as part of the Starter: R robustbase Datasets 6f223ec8-4
package;I doubt the issue depends on how the CSV's are parsed,since optimization of the problem on the same dataset without custom branching will work fine.
Related Content
Related Content
Are 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 unread2Views0likes3CommentsVariable 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 unread1View0likes6Comments