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
-
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 = 1
before 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
Please sign in to leave a comment.
Comments
1 comment