21#include "absl/log/check.h"
22#include "absl/strings/string_view.h"
30 CHECK_EQ(
storage()->num_quadratic_objective_terms(id_), 0)
31 <<
"The objective function contains quadratic terms and cannot be "
32 "represented as a LinearExpression";
34 for (
const auto [raw_var_id, coeff] : storage_->linear_objective(id_)) {
35 objective += coeff *
Variable(storage_, raw_var_id);
42 for (
const auto& [v,
coef] : storage_->linear_objective(id_)) {
45 for (
const auto& [v1, v2,
coef] : storage_->quadratic_objective_terms(id_)) {
56 std::stringstream str;
63 const absl::string_view
name = objective.
name();
66 ostr <<
"__primary_obj__";
68 ostr <<
"__aux_obj#" << *objective.
id() <<
"__";
std::string ToString() const
QuadraticExpression AsQuadraticExpression() const
Returns a representation of the objective as a QuadraticExpression.
std::optional< int64_t > id() const
const ModelStorage * storage() const
Returns a const-pointer to the underlying storage object for the model.
LinearExpression AsLinearExpression() const
absl::string_view name() const
Returns the name of the objective.
double offset() const
Returns the constant offset of the objective.
const std::string name
A name for logging purposes.
An object oriented wrapper for quadratic constraints in ModelStorage.
std::ostream & operator<<(std::ostream &ostr, const IndicatorConstraint &constraint)
constexpr absl::string_view kDeletedObjectiveDefaultDescription