When does gurobipy call C code?
回答済みI am wondering at which point in the execution of a python program, using gurobipy, does C code get called?
Is it at the point where the model is created, i.e., m = gp.Model()?
Or is it when the model is optimized, i.e., m.optimize()?
Additionally, is the C code that is called compiled/object code? Finally, does the execution return to the python program at any point during the solving, or does everything happen in C code until the solution is returned to the python program?
Thank you,
Samuel
-
Hi Samuel,
gurobipy is tightly integrated with the Gurobi C API, so C code is called any time you make a gurobipy API call. For example:
- gp.Model(...) calls the C API to construct a model
- x = model.addVar() calls the C API to add a variable to a model
- model.addConstr(x + y <= 1) calls the C API to add a constraint (though the expression arithmetic is done on the python side)
All C code that is called here is compiled: gurobipy itself is a compiled extension module, which is linked to the compiled Gurobi library.
Execution does return back to Python during solving in a few cases. One case is logging: log messages from the solver are routed back to Python's logging module and output streams. Another case is callbacks: if you provide a callback function, execution returns to your Python code on every callback invocation.
0
サインインしてコメントを残してください。
コメント
1件のコメント