Skip to main content

Difference objective function in code yields difference result which one is the correct one?

Answered

Comments

2 comments

  • Marika Karbstein
    • Gurobi Staff Gurobi Staff

    In your code (version 1), you have model.setObjective() before the model definition model=gp.Model(). If you do not get an error, the model object is probably defined earlier (as well as variables delta_ij). With the next call model=gp.Model(), the model is overwritten, i.e., an empty model is created.
    So, I guess in the first version you have a 0 objective, and in the second version the objective is considered.

    To troubleshoot, I would recommend writing your model into an LP file with model.write("Test.lp") directly before calling model.optimize(). In this way, you can check what model is actually optimized and you could compare the lp files (name them differently) for both of your versions.

    0
  • Muhamad Fikri
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hi, Thank you for your reply and insight.

    I already solve the problem after troubleshooting again. Thank you for the direction once again!

    0

Please sign in to leave a comment.