Try our new documentation site (beta).
GRBsetobjectiven
int | GRBsetobjectiven ( | GRBmodel | *model, |
int | index, | ||
int | priority, | ||
double | weight, | ||
double | abstol, | ||
double | reltol, | ||
const char | *name, | ||
double | constant, | ||
int | lnz, | ||
int | *lind, | ||
double | *lval ) |
Set an alternative optimization objective equal to a linear expression.
Please refer to the discussion of Multiple Objectives for information on how to specify multiple objective functions and control the trade-off between them.
Note that you can also modify an alternative objective using the
ObjN variable attribute. If you wish to mix
and match these two approaches, please note that this method replaces
the entire existing objective, while the ObjN
attribute can be
used to modify individual terms.
Note that, due to our lazy update approach, the new alternative objective won't actually be added until you update the model (using GRBupdatemodel), optimize the model (using GRBoptimize), or write the model to disk (using GRBwrite).
Return value:
A non-zero return value indicates that a problem occurred while setting the alternative objective. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.
Arguments:
model: The model in which the new alternative objective should be set.
index: Index for new objective. If you use an index of 0, this routine will change the primary optimization objective.
priority: Priority for the alternative objective. This initializes the ObjNPriority attribute for this objective.
weight: Weight for the alternative objective. This initializes the ObjNWeight attribute for this objective.
abstol: Absolute tolerance for the alternative objective. This initializes the ObjNAbsTol attribute for this objective.
reltol: Relative tolerance for the alternative objective. This initializes the ObjNRelTol attribute for this objective.
name: Name of the alternative objective. This initializes the ObjNName attribute for this objective.
constant: Constant part of the linear expression for the new alternative objective.
lnz: Number of non-zero coefficients in new alternative objective.
lind: Variable indices for non-zero values in new alternative objective.
lval: Numerical values for non-zero values in new alternative objective.
Example usage:
int ind[] = {0, 1, 2}; double val[] = {1.0, 1.0, 1.0}; /* Objective expression: x0 + x1 + x2 */ error = GRBsetobjectiven(model, 0, 1, 0.0, 0.0, 0.0, "primary", 0.0, 3, ind, val);