![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
A value type that references an objective (either primary or auxiliary) from ModelStorage. Usually this type is passed by copy.
This type implements https://abseil.io/docs/cpp/guides/hash.
Definition at line 43 of file objective.h.
#include <objective.h>
Public Types | |
| using | IdType = AuxiliaryObjectiveId |
| The type used for ids. | |
Public Member Functions | |
| std::optional< int64_t > | id () const |
| ObjectiveId | typed_id () const |
| bool | is_primary () const |
| bool | maximize () const |
| Returns true if the objective is the maximization sense. | |
| int64_t | priority () const |
| Returns the priority (lower is more important) of the objective. | |
| absl::string_view | name () const |
| Returns the name of the objective. | |
| double | offset () const |
| Returns the constant offset of the objective. | |
| int64_t | num_linear_terms () const |
| Returns the number of linear terms in the objective. | |
| int64_t | num_quadratic_terms () const |
| Returns the number of quadratic terms in the objective. | |
| double | coefficient (Variable variable) const |
| Returns the linear coefficient for the variable in the model. | |
| double | coefficient (Variable first_variable, Variable second_variable) const |
| Returns the quadratic coefficient for the pair of variables in the model. | |
| bool | is_coefficient_nonzero (Variable variable) const |
| Returns true if the variable has a nonzero linear coefficient in the model. | |
| bool | is_coefficient_nonzero (Variable first_variable, Variable second_variable) const |
| LinearExpression | AsLinearExpression () const |
| QuadraticExpression | AsQuadraticExpression () const |
| Returns a representation of the objective as a QuadraticExpression. | |
| std::string | ToString () const |
| Public Member Functions inherited from operations_research::math_opt::ModelStorageItem | |
| ModelStorageCPtr | storage () const |
Static Public Member Functions | |
| static Objective | Primary (ModelStorageCPtr storage) |
| Returns an object that refers to the primary objective of the model. | |
| static Objective | Auxiliary (ModelStorageCPtr storage, AuxiliaryObjectiveId id) |
| Returns an object that refers to an auxiliary objective of the model. | |
Friends | |
| bool | operator== (const Objective &lhs, const Objective &rhs) |
| bool | operator!= (const Objective &lhs, const Objective &rhs) |
| template<typename H> | |
| H | AbslHashValue (H h, const Objective &objective) |
| std::ostream & | operator<< (std::ostream &ostr, const Objective &objective) |
Additional Inherited Members | |
| Protected Member Functions inherited from operations_research::math_opt::ModelStorageItem | |
| ModelStorageItem (ModelStorageCPtr storage) | |
| ModelStorageItem (const ModelStorageItem &)=default | |
| ModelStorageItem & | operator= (const ModelStorageItem &)=default |
| ModelStorageItem (ModelStorageItem &&)=default | |
| ModelStorageItem & | operator= (ModelStorageItem &&)=default |
| ~ModelStorageItem ()=default | |
The type used for ids.
Definition at line 46 of file objective.h.
| LinearExpression operations_research::math_opt::Objective::AsLinearExpression | ( | ) | const |
Returns a representation of the objective as a LinearExpression.
Definition at line 29 of file objective.cc.
| QuadraticExpression operations_research::math_opt::Objective::AsQuadraticExpression | ( | ) | const |
Returns a representation of the objective as a QuadraticExpression.
Definition at line 40 of file objective.cc.
|
inlinestatic |
Returns an object that refers to an auxiliary objective of the model.
Definition at line 219 of file objective.h.
|
inline |
Returns the quadratic coefficient for the pair of variables in the model.
Definition at line 172 of file objective.h.
|
inline |
Returns the linear coefficient for the variable in the model.
Definition at line 166 of file objective.h.
|
inline |
Returns the raw integer ID associated with the objective: nullopt for the primary objective, a nonnegative int64_t for an auxiliary objective.
Inline function implementations
Definition at line 132 of file objective.h.
|
inline |
Returns true if the pair of variables has a nonzero quadratic coefficient in the model.
Definition at line 189 of file objective.h.
|
inline |
Returns true if the variable has a nonzero linear coefficient in the model.
Definition at line 182 of file objective.h.
|
inline |
Returns true if the ID corresponds to the primary objective, and false if it is an auxiliary objective.
Definition at line 141 of file objective.h.
|
inline |
Returns true if the objective is the maximization sense.
Definition at line 147 of file objective.h.
|
inline |
Returns the name of the objective.
Definition at line 149 of file objective.h.
|
inline |
Returns the number of linear terms in the objective.
Definition at line 162 of file objective.h.
|
inline |
Returns the number of quadratic terms in the objective.
Definition at line 158 of file objective.h.
|
inline |
Returns the constant offset of the objective.
Definition at line 156 of file objective.h.
|
inlinestatic |
Returns an object that refers to the primary objective of the model.
Definition at line 215 of file objective.h.
|
inline |
Returns the priority (lower is more important) of the objective.
Definition at line 143 of file objective.h.
| std::string operations_research::math_opt::Objective::ToString | ( | ) | const |
Returns a detailed string description of the contents of the objective (not its name, use << for that instead).
Definition at line 52 of file objective.cc.
|
inline |
Returns the strong int ID associated with the objective: nullopt for the primary objective, an AuxiliaryObjectiveId for an auxiliary objective.
Definition at line 139 of file objective.h.
|
friend |
Definition at line 208 of file objective.h.
Definition at line 203 of file objective.h.
|
friend |
Streams the name of the objective, as registered upon objective creation, or a short default if none was provided.
Definition at line 61 of file objective.cc.
Definition at line 199 of file objective.h.