Filter Content By
Version
Languages

### GRBModel.setObjective()

Set the model objective equal to a linear or quadratic expression (for multi-objective optimization, see setObjectiveN).

Note that you can also modify the linear portion of a model objective using the Obj variable attribute. If you wish to mix and match these two approaches, please note that this method replaces the entire existing objective, while the Obj attribute can be used to modify individual linear terms.

 void setObjective ( GRBExpr expr, int sense )
Set the model objective, and the objective sense (GRB.MINIMIZE for minimization, GRB.MAXIMIZE for maximization).

Arguments:

expr: New model objective.

sense: New optimization sense (GRB.MINIMIZE for minimization, GRB.MAXIMIZE for maximization).

 void setObjective ( GRBExpr expr )

Set the model objective. The sense of the objective is determined by the value of the ModelSense attribute.

Arguments:

expr: New model objective.