19#include "absl/container/flat_hash_set.h"
20#include "ortools/math_opt/sparse_containers.pb.h"
32 data.
name = in_proto.name();
33 for (
int i = 0; i < in_proto.linear_terms().ids_size(); ++i) {
35 in_proto.linear_terms().values(i));
37 for (
int i = 0; i < in_proto.quadratic_terms().row_ids_size(); ++i) {
39 VariableId(in_proto.quadratic_terms().row_ids(i)),
40 VariableId(in_proto.quadratic_terms().column_ids(i)),
41 in_proto.quadratic_terms().coefficients(i));
53 constraint.set_name(
name);
59 absl::flat_hash_set<VariableId> vars(quad_terms.begin(), quad_terms.end());
63 return std::vector<VariableId>(vars.begin(), vars.end());
bool set(VariableId id, double coeff)
Returns true if the stored value changes.
SparseDoubleVectorProto Proto() const
const absl::flat_hash_map< VariableId, double > & terms() const
std::vector< VariableId > Variables() const
void Delete(VariableId variable)
Zeros out all coefficients for this variable.
SparseDoubleMatrixProto Proto() const
bool set(VariableId first, VariableId second, double value)
An object oriented wrapper for quadratic constraints in ModelStorage.
SparseSymmetricMatrix quadratic_terms
void DeleteVariable(VariableId var)
QuadraticConstraintProto ProtoType
SparseCoefficientMap linear_terms
static QuadraticConstraintData FromProto(const ProtoType &in_proto)
std::vector< VariableId > RelatedVariables() const