Skip to main content

Slow constraints addition in Python vs. C++

Answered

Comments

2 comments

  • Marika Karbstein
    • Gurobi Staff 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

Please sign in to leave a comment.