18#ifndef ORTOOLS_MATH_OPT_CPP_OBJECTIVE_H_
19#define ORTOOLS_MATH_OPT_CPP_OBJECTIVE_H_
26#include "absl/log/check.h"
27#include "absl/strings/string_view.h"
37 "[objective deleted from model]";
56 inline std::optional<int64_t>
id()
const;
72 inline absl::string_view
name()
const;
75 inline double offset()
const;
106 friend inline bool operator==(
const Objective& lhs,
const Objective& rhs);
107 friend inline bool operator!=(
const Objective& lhs,
const Objective& rhs);
108 template <
typename H>
110 friend std::ostream&
operator<<(std::ostream& ostr,
111 const Objective& objective);
142 return storage()->objective_priority(id_);
157 return storage()->num_quadratic_objective_terms(id_);
161 return storage()->num_linear_objective_terms(id_);
167 return storage()->linear_objective_coefficient(id_, variable.typed_id());
171 const Variable second_variable)
const {
176 return storage()->quadratic_objective_coefficient(
183 return storage()->is_linear_objective_coefficient_nonzero(
184 id_, variable.typed_id());
188 const Variable second_variable)
const {
193 return storage()->is_quadratic_objective_coefficient_nonzero(
202 return !(lhs == rhs);
207 return H::combine(std::move(h), objective.id_, objective.
storage());
ModelStorageCPtr storage() const
ModelStorageItem(ModelStorageCPtr storage)
std::string ToString() const
QuadraticExpression AsQuadraticExpression() const
std::optional< int64_t > id() const
friend bool operator==(const Objective &lhs, const Objective &rhs)
bool is_coefficient_nonzero(Variable variable) const
friend std::ostream & operator<<(std::ostream &ostr, const Objective &objective)
AuxiliaryObjectiveId IdType
double coefficient(Variable variable) const
ObjectiveId typed_id() const
LinearExpression AsLinearExpression() const
int64_t num_linear_terms() const
static Objective Primary(ModelStorageCPtr storage)
friend H AbslHashValue(H h, const Objective &objective)
absl::string_view name() const
friend bool operator!=(const Objective &lhs, const Objective &rhs)
int64_t num_quadratic_terms() const
static Objective Auxiliary(ModelStorageCPtr storage, AuxiliaryObjectiveId id)
constexpr absl::string_view kObjectsFromOtherModelStorage
const ModelStorage *absl_nonnull ModelStorageCPtr
ElementId< ElementType::kAuxiliaryObjective > AuxiliaryObjectiveId
constexpr ObjectiveId kPrimaryObjectiveId
bool operator==(const SecondOrderConeConstraint &lhs, const SecondOrderConeConstraint &rhs)
bool operator!=(const SecondOrderConeConstraint &lhs, const SecondOrderConeConstraint &rhs)
absl::flat_hash_map< Objective, V > ObjectiveMap
std::ostream & operator<<(std::ostream &ostr, const SecondOrderConeConstraint &constraint)
H AbslHashValue(H h, const SecondOrderConeConstraint &constraint)
constexpr absl::string_view kDeletedObjectiveDefaultDescription
std::optional< AuxiliaryObjectiveId > ObjectiveId