Skip to main content

Losing multiobjective behavior after feasibility relaxation?

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    This post is more than three 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 why not try our AI Gurobot?.
  • Eli Towle
    Gurobi Staff Gurobi Staff

    This is expected behavior - the feasibility relaxation creates a single objective to minimize the solution's violation of the original constraints with respect to the specified metric. Note that only \( \texttt{minrelax=False} \) is currently supported for multi-objective models.

    To evaluate your multiple objectives at the feasibility relaxation's solution, you can store each objective function as a LinExpr object, then call LinExpr.getValue() once the feasibility relaxation finishes solving. For example, the following code

    import gurobipy as gp

    # Build simple model
    m = gp.Model()
    x = m.addVars(3, name='x')
    m.addConstr(x[0] >= 20)
    m.addConstr(x[1] >= 10)
    m.addConstr(x[2] >= 5)

    # Store objectives as LinExpr objects
    obj1 = x[0] + x[2]
    obj2 = 2*x[1]

    # Solve feasibility relaxation (minrelax=False)
    # For illustrative purposes - our model is feasible
    m.feasRelaxS(0, False, True, True)
    m.optimize()

    # Evaluate objectives at current solution
    print(f'obj1 = {obj1.getValue()}')
    print(f'obj2 = {obj2.getValue()}')

    evaluates the two linear expressions given the feasibility relaxation solution:

    obj1 = 25.0
    obj2 = 20.0
    1
  • Vineet Jagadeesan Nair
    Gurobi-versary
    First Comment
    First Question

    Yes, this is the kind of solution I was looking for. Thank you!

    0

Post is closed for comments.