Skip to main content

How to profile Gurobi in Python?

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • rllb
    • Gurobi-versary
    • First Question
    • First Comment

    I found this package which provides profiling by line. Contrary to cProfile, it does show Model.optimize() as the most time-consuming line.

    https://github.com/pyutils/line_profiler#id2

    0
  • Eli Towle
    • Gurobi Staff

    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.