additional argument in callback function
AnsweredHi
I'm trying to implement a callback function in which a list of variables that not belong to the model has to be updated when a MIP solution is found. My approach is to add the virable as the argument to the callback function:
def mycallback(model,where,p)
but if I do so, I have to list all arguments of the callback function when I want to optimize my model:
model.optimize(mycallback(model,where,p))
and "where" is apparently not and should not be defined. How can I fix this issue? Thank you!
Best Regards
Zheren
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
I think you are looking for the following, see the Callback documentation:
If you would like to pass data to your callback function, you can do so through the Model object. For example, if your program includes the statement
model._value = 1before the optimization begins, then your callback function can query the value ofmodel._value. Note that the name of the user data field must begin with an underscore.0
Post is closed for comments.
Comments
2 comments