Forum Discussion
FICO
4 years agoCommunity Manager
Using callback to re-set (modify) control in middle on B&B search [Using Python]
Hello Xpress Experts,
I am wondering if any of you could help me with this callback in Python. I want to quickly find an integer solution during the BB, and then, switch to the default BB search settings of Xpress.
To do that, I am trying to set a callback such that after the first integer solution is found, the setControl for SBBEST and SBESTIMATE are re-set. Also, I do not want to keep using such callback function further in the BB, so I want to remove it.
Below you can see a piece of the code where I am trying to achieve what I mentioned before. Can anyone tell me why Xpress is stopping immediately after the first integer solution is found and says that stopped by user?
# Define callback to depth search first and then switch to Xpress default
def change_search_strategy(prob):
prob.setControl({'sbbest':-1,'sbestimate':-1})
print("CHANGED THE BRANCH STRATEGY")
prob.removecbintsol()
# Add function to callback
p.addcbintsol(change_search_strategy, None,0)
2 Replies
- FICOCommunity Manager
Not an answer to your question but would it not be much simpler to
- Set your special parameters
- Set the integer solution limit (MAXMIPSOL) to 1
- Call solve()
- Reset your special parameters and reset the integer solution limit to its default.
- Call solve()
This should give you the same effect but without any callbacks.
- FICOCommunity Manager
Hi Daniel,
First of all, thanks a lot for your message. Actually, I ended up doing something like that, I interrupted the search and reset the parameters. But MaxMipsol seems to do exactly the same but effortless. I am just getting to know all the capabilities, so I missed that control parameter.
Thanks a lot, it is really helpful.
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