setObjectiveN() doesn't accept priority
AnsweredHi,
I'm considering implementing a multi-objective model and incorporating the new feature into the objective function as the second objective, with lower priority. I'm utilizing the `setObjectiveN()` function to define the two objectives. However, it doesn't allow me to include priority as an argument, treating it as an unexpected parameter. I checked the documentation popup for the `setObjectiveN()` method and it seems it only takes two arguments.
def setObjectiveN(self,
expr: Any,
index: Any) -> None
I'm uncertain how to establish priority for the objectives. Could you provide guidance on how to define the priorities for the objectives?
def setObjectiveN(self,
expr: Any,
index: Any) -> None
I'm uncertain how to establish priority for the objectives. Could you provide guidance on how to define the priorities for the objectives?
0
-
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.
Comments
1 comment