gurobipy: Must callback be a function? Problem with Cython
回答済みIt seems that the callback argument in the Python gurobipy methods is checked to be a function. Why is it not sufficient to provide anything callable? Can this be fixed or worked around? This makes it cumbersome to use Cython, where something like inspect.isfunction(f) returns False if f is a "cythonized" function.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "src/gurobipy/model.pxi", line 839, in gurobipy.Model.optimize
gurobipy.GurobiError: Callback argument must be a function
0
-
正式なコメント
This post is more than three 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. -
Hi Sebastian,
If you have a callable that isn't a function, you can work around this particular limitation by using a lambda function as follows:
import gurobipy as gp
m = gp.Model()
# where 'callback' is a callable taking two arguments
m.optimize(lambda model, where: callback(model, where))0
投稿コメントは受け付けていません。
コメント
2件のコメント