Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#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 |
const ModelStorage * | storage () const |
Returns a const-pointer to the underlying storage object for the model. | |
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 |
Static Public Member Functions | |
static Objective | Primary (const ModelStorage *storage) |
Returns an object that refers to the primary objective of the model. | |
static Objective | Auxiliary (const ModelStorage *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) |
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.
using operations_research::math_opt::Objective::IdType = AuxiliaryObjectiveId |
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 224 of file objective.h.
|
inline |
Returns the quadratic coefficient for the pair of variables in the model.
Definition at line 177 of file objective.h.
|
inline |
Returns the linear coefficient for the variable in the model.
Definition at line 171 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 135 of file objective.h.
|
inline |
Returns true if the pair of variables has a nonzero quadratic coefficient in the model.
Definition at line 194 of file objective.h.
|
inline |
Returns true if the variable has a nonzero linear coefficient in the model.
Definition at line 187 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 146 of file objective.h.
|
inline |
Returns true if the objective is the maximization sense.
Definition at line 152 of file objective.h.
|
inline |
Returns the name of the objective.
Definition at line 154 of file objective.h.
|
inline |
Returns the number of linear terms in the objective.
Definition at line 167 of file objective.h.
|
inline |
Returns the number of quadratic terms in the objective.
Definition at line 163 of file objective.h.
|
inline |
Returns the constant offset of the objective.
Definition at line 161 of file objective.h.
|
inlinestatic |
Returns an object that refers to the primary objective of the model.
Definition at line 220 of file objective.h.
|
inline |
Returns the priority (lower is more important) of the objective.
Definition at line 148 of file objective.h.
|
inline |
Returns a const-pointer to the underlying storage object for the model.
Definition at line 144 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 142 of file objective.h.
|
friend |
Definition at line 213 of file objective.h.
Definition at line 208 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 204 of file objective.h.