Skip to main content

Copy a class of model

Answered

Comments

2 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.
  • Riley Clement
    • Gurobi Staff

    Hi Farzane,

    Creating a (deep) copy of your model should be done with Model.copy().

    Note however the object is just the model, it does not include the branch and bound tree (which exists inside the Gurobi Optimizer and not Python), solutions or anything related to prior optimizations and so optimization on the new model would start from scratch:

    m = gp.read("mymodel.mps")
    m.optimize()
    print(m.Status) # prints 2 (= OPTIMAL)
    m2 = m.copy()
    print(m2.Status) # prints 1 (= LOADED)

    - Riley

    0

Post is closed for comments.