How to profile Gurobi in Python?
AnsweredI am using cProfile to profile gurobi. Unfortunately, the calls to Model.optimize() do not seem to appear, despite having the largest cumulative time.
Is there any solution besides manually profiling specfic lines with timeit?
0
-
Official comment
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. -
I found this package which provides profiling by line. Contrary to cProfile, it does show Model.optimize() as the most time-consuming line.
0 -
You could try wrapping the call to Model.optimize() in a simple function:
import gurobipy as gp
import cProfile
def main():
m = gp.Model()
# Build model here
optimize(m)
def optimize(model):
model.optimize()
cProfile.run('main()')0
Post is closed for comments.
Comments
3 comments