Skip to main content

setObjectiveN() doesn't accept priority

Answered

Comments

1 comment

  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Sonia,

    You should be able to set the priority through the setObjectiveN method.

    If your IDE is suggesting otherwise then this may be a limitation of the IDE.

    If you're using an interactive Python session then you can use

    import gurobipy as gp
    print(gp.Model.setObjectiveN)

    to print the documentation to your screen:

    setObjectiveN(self, expr, index, priority=0, weight=1.0, abstol=1e-06, reltol=0.0, name='')
        ROUTINE:
          setObjectiveN(expr, index)
        
        PURPOSE:
          Set the model objective equal to a LinExpr or QuadExpr
        
        ARGUMENTS:
          expr:     The desired objective function.  The objective can be
                    a linear expression (LinExpr) a variable (Var) or a constant.
                    This routine will replace the 'ObjNVal' attribute on model variables
                    with the corresponding values from the supplied expression for
                    multi-objective 'index'
          index:    Identify which multi-objective to set
          priority: Set the ObjNPriority attribute for this multi-objective (default is zero)
          weight:   Set the ObjNWeight attribute for this multi-objective (default is 1.0)
          abstol:   Set the ObjNAbsTol  attribute for this multi-objective (default is 1e-6)
          reltol:   Set the ObjNRelTol  attribute for this multi-objective (default is zero)
          name:     multi-objective name (default is no name)
        
        RETURN VALUE:
          None.
        
        EXAMPLE:
          model.setObjectiveN(x + y, 1)
          model.setObjectiveN(x + y + 2*z, 2)

    - Riley

    0

Please sign in to leave a comment.