Skip to main content

Multi Objective

Ongoing

Comments

2 comments

  • Ronald van der Velden
    Gurobi Staff Gurobi Staff

    Hi Alexandra,

    • We optimize highest priority first, so that's why Z3 is solved first in your case.
    • When you iterate over range(3) to retrieve the objective values, you'll always get the same objective value since you don't request the objective value for a specific objective. While you iterate, you should set the ObjNumber model attribute to t and then request the ObjNVal attribute. See this example for some more information.

    Hope that helps!

    Kind regards,
    Ronald

    0
  • Alexandra Baldus
    First Comment
    First Question

    Hi Ronald,

    thank you very much for your help!

    Is this the right way to implement?

    model.setObjectiveN(Z1, index=0, priority=2, name="Z1")
    model.setObjectiveN(Z2, index=1, priority=1, name="Z2")
    model.setObjectiveN(Z3, index=2, priority=0, name="Z3")


    model.optimize()

    Z_values = []

    for t in range(3):
        model.setParam(GRB.Param.ObjNumber, t)
        Z_values.append(model.ObjNVal)

    if model.status == GRB.INFEASIBLE or model.status == GRB.UNBOUNDED:
        print("Das Problem ist unlösbar oder unbeschränkt.")
    else:
        print("Optimale Zielfunktionswerte:", Z_values)

        total_objective_value = sum(Z_values)
        print(f"Gesamtwert der Zielfunktion: {total_objective_value}")

    Unfortunately, I now get the value 0 as the optimal solution. Am I missing something?

    King regards, 

    Alexandra 

    0

Please sign in to leave a comment.