メインコンテンツへスキップ

the function of model copying

回答済み

コメント

1件のコメント

  • 正式なコメント
    Ronald van der Velden
    • Gurobi Staff Gurobi Staff

    Hi Jiakang,

    There are several options for this.

    • You could use the model.copy() function. This gives you a complete, independent copy of the model. It also means any references to variables/constraints in the original model, will still point to the original model. You should use model.getVarByName() or similar to retrieve variables/constraints in the copy to modify them.
    • You could also use the multi-scenario functionality. Here, you first build a base model and then define for each "scenario" how it differs from that base scenario. While you cannot add variables/constraints, the documentation shows how to still achieve the same (see "Tips and tricks").
    • Finally, you could treat the models sequentially. If you don't plan on solving them in parallel, you could just define the first model and solve it, store the solution, then modify it to create the second model.

    Does one of those options work for you?

    Kind regards,
    Ronald

サインインしてコメントを残してください。