Overview | Group | Tree | Graph | Index | Concepts |
An instance of this class is an objective in a model. An objective consists of its sense (indicating whether it is a minimization or maximization) and an expression. The expression may be a constant.
An objective belongs to the environment that the variables in its expression belong to. Generally, you will create an objective, add it to a model, and extract the model for an algorithm.
Most member functions in this class contain assert
statements. For an
explanation of the macro NDEBUG
(a way to turn on or turn off these
assert
statements), see the concept
Assert and NDEBUG.
What Is Extracted
All the variables (that is, instances of IloNumVar
or one of its subclasses) in the objective (an instance of IloObjective
)
will be extracted when an algorithm such as IloCplex
, documented in the
ILOG CPLEX Reference Manual, extracts the objective.
Multiple Objectives
You may create more than one objective in a model, for example, by creating more
than one group. However, certain algorithms, such as an instance of
IloCplex
, will throw an exception (on a platform that supports C++
exceptions, when exceptions are enabled) if you attempt to extract more than one
objective at a time.
Also see the functions IloMaximize
and
IloMinimize
for “short cuts” to create
objectives.
Normalizing Linear Expressions: Reducing the Terms
Normalizing is sometimes known as reducing the terms of a linear expression.
Linear expressions consist of terms made up of constants and variables related by arithmetic operations; for example, x + 3y is a linear expression of two terms consisting of two variables. In some linear expressions, a given variable may appear in more than one term, for example, x + 3y +2x. Concert Technology has more than one way of dealing with linear expressions in this respect, and you control which way Concert Technology treats linear expressions from your application.
In one mode (the default mode), Concert Technology analyzes expressions that your
application passes it and attempts to reduce them so that a given variable appears in
only one term in the expression. You set this mode with the member function
IloEnv::setNormalizer
.
Certain constructors and member functions in this class check this setting in the model and behave accordingly: they attempt to reduce expressions. This mode may require more time during preliminary computation, but it avoids the possibility of an assertion failing for certain member functions of this class in case of duplicates.
In the other mode, Concert Technology assumes that no variable appears in more than
one term in any of the linear expressions that your application passes to Concert
Technology. We call this mode assume no duplicates. You set this mode with the member
function IloEnv::setNormalizer
.
Certain constructors and member functions in this class check this setting in the
model and behave accordingly: they assume that no variable appears in more than one
term in an expression. This mode may save time during computation, but it entails the
risk that an expression may contain one or more variables, each of which appears in
one or more terms. This situation will cause certain assert
statements in
Concert Technology to fail if you do not compile with the flag -DNDEBUG
.
See Also:
IloMaximize, IloMinimize, IloModel, IloObjective::Sense
Constructor Summary | |
---|---|
public | IloObjective() |
public | IloObjective(IloObjective::ImplClass *) |
public | IloObjective(const IloEnv, IloNum, IloObjective::Sense, const char *) |
public | IloObjective(const IloEnv, const IloNumExprArg, IloObjective::Sense, const char *) |
Method Summary | |
---|---|
public IloNum | getConstant() |
public IloNumExprArg | getExpr() |
public IloObjective::ImplClass * | getImpl() |
public IloObjective::Sense | getSense() |
public IloAddValueToObj | operator()(IloNum) |
public IloAddValueToObj | operator()() |
public void | setConstant(IloNum) |
public void | setExpr(const IloNumExprArg) |
public void | setLinearCoef(const IloNumVar, IloNum) |
public void | setLinearCoefs(const IloNumVarArray, const IloNumArray) |
public void | setSense(IloObjective::Sense) |
Inherited Methods from IloExtractable |
---|
end, getEnv, getId, getImpl, getName, getObject, setName, setObject |
Inner Enumeration |
---|
IloObjective::Sense |
Constructor Detail |
---|
This constructor creates an objective consisting of a constant
and
belonging to env
. The sense of the objective (whether it is a
minimization or maximization) is indicated by sense
; by default, it is a
minimization. You may supply a name
for the objective; by default, its
name
is the empty string. This constructor is useful when you want to
create an empty objective and fill it later by column-wise modeling.
This constructor creates an objective to add to a model from
expr
.
After you create an objective from an expression with this constructor,
you must use the member function add
explicitly to add your
objective to your model or to a group in order for the objective to be taken
into account.
Method Detail |
---|
This member function returns the constant term from the expression of the invoking objective.
This member function returns the expression of the invoking
IloObjective
object.
This member function returns the sense of the invoking objective, indicating
whether the objective is a minimization (Minimize
) or a maximization
(Maximize
).
This casting operator uses a floating-point value
to create an
instance of IloAddNumVar
or one of its subclasses and to add that
value
to that instance. See the concept Column-Wise Modeling
for an explanation of how to use this operator in column-wise modeling.
This casting operator uses a floating-point value
to create an
instance of IloAddNumVar
or one of its subclasses and to add that
value
to that instance. If no argument is given, it assumes 1.0. See the
concept Column-Wise Modeling
for an explanation of how to use this operator in column-wise modeling.
This member function sets constant
as the constant term in the
invoking objective, and it creates the appropriate instance of the undocumented class
IloChange
to notify algorithms about this change of an extractable object
in the model.
setConstant
notifies Concert Technology algorithms
about this change of this invoking object.
This member function sets the expression of the invoking
IloObjective
object.
This member function sets value
as the linear coefficient of the
variable var
in the invoking objective, and it creates the appropriate
instance of the undocumented class IloChange
to notify algorithms about
this change of an extractable object in the model.
setLinearCoef
notifies Concert Technology algorithms
about this change of this invoking object.
If you attempt to use setLinearCoef
on a nonlinear expression, it will
throw an exception on platforms that support C++ exceptions when exceptions are
enabled.
For each of the variables in vars
, this member function sets the
corresponding value of values
(whether integer or floating-point) as its
linear coefficient in the invoking objective, and it creates the appropriate instance
of the undocumented class IloChange
to notify algorithms about this
change of an extractable object in the model.
setLinearCoefs
notifies Concert Technology algorithms
about this change of this invoking object.
If you attempt to use setLinearCoef
on a non linear expression,
Concert Technology will throw an exception on platforms that support C++ exceptions
when exceptions are enabled.
This member function sets sense
to indicate whether the invoking
objective is a maximization (Maximize
) or minimization
(Minimize
), and it creates the appropriate instance of the undocumented
class IloChange
to notify algorithms about this change of an extractable
object in the model.
setSense
notifies Concert Technology algorithms about
this change of this invoking object.
Inner Enumeration Detail |
---|
An instance of the class IloObjective
represents an
objective in a model. This nested enumeration is limited in scope to that class, and
its values indicate the sense of an objective—whether it is a minimization
(Minimize
) or a maximization (Maximize
).
See Also:
Fields |
---|
Minimize | |
Maximize |