Skip to main content

Slow constraints addition in Python vs. C++

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Marika Karbstein
    • Gurobi Staff

    Hi Timothy,

    It looks like you are mixing matrix-friendly and term-based modeling in Python.
    Did you try to use Model.addVars() instead of Model.addMVar() ?

    Best regards,
    Marika

    0
  • Timothy Baeckelant
    • Gurobi-versary
    • First Comment
    • First Question

    Hello Marika, thanks for this answer!

    I first wrote a "matrix-based modeling" but the time to build the model was even worse, so I tried like this. However, just using Model.addVars() makes the generation 50 times faster, thank you!

    0

Post is closed for comments.