21#include "absl/algorithm/container.h"
22#include "absl/container/flat_hash_map.h"
23#include "absl/container/flat_hash_set.h"
24#include "absl/strings/string_view.h"
25#include "absl/types/span.h"
38 const absl::string_view
name) {
41 Data& lin_con_data = linear_constraints_[id];
44 lin_con_data.name = std::string(
name);
50 std::vector<LinearConstraintId> result;
51 for (
const auto& [lin_con, _] : linear_constraints_) {
52 result.push_back(lin_con);
57std::vector<LinearConstraintId>
64std::vector<LinearConstraintId> LinearConstraintStorage::ConstraintsFrom(
66 std::vector<LinearConstraintId> result;
68 util_intops::MakeStrongIntRange(start, next_id_)) {
69 if (linear_constraints_.contains(
c)) {
76std::pair<LinearConstraintsProto, SparseDoubleMatrixProto>
79 const std::vector<LinearConstraintId> sorted_constraints =
82 AppendConstraint(
id, &constraints);
84 return {constraints, matrix_.Proto()};
87void LinearConstraintStorage::AppendConstraint(
91 const Data& data = linear_constraints_.at(constraint);
100 LinearConstraintsProto result;
102 util_intops::MakeStrongIntRange(start,
end)) {
103 if (linear_constraints_.contains(
id)) {
104 AppendConstraint(
id, &result);
126 const Diff& diff,
const absl::flat_hash_set<VariableId>& deleted_variables,
127 absl::Span<const VariableId> new_variables)
const {
148 deleted_variables, new_variables, diff.
matrix_keys);
int64_t value() const
Returns the raw id value.
double lower_bound(LinearConstraintId id) const
LinearConstraintId next_id() const
UpdateResult Update(const Diff &diff, const absl::flat_hash_set< VariableId > &deleted_variables, absl::Span< const VariableId > new_variables) const
double upper_bound(LinearConstraintId id) const
std::pair< LinearConstraintsProto, SparseDoubleMatrixProto > Proto() const
Returns an equivalent proto of this.
void AdvanceCheckpointInDiff(VariableId variable_checkpoint, Diff &diff) const
Updates the checkpoint and clears all stored changes in diff.
const std::string & name(LinearConstraintId id) const
LinearConstraintId Add(double lower_bound, double upper_bound, absl::string_view name)
std::vector< LinearConstraintId > LinearConstraints() const
The LinearConstraintsIds in use (not deleted), order not defined.
std::vector< LinearConstraintId > SortedLinearConstraints() const
::operations_research::math_opt::SparseDoubleVectorProto *PROTOBUF_NONNULL mutable_lower_bounds()
::operations_research::math_opt::SparseDoubleVectorProto *PROTOBUF_NONNULL mutable_upper_bounds()
::std::string *PROTOBUF_NONNULL add_names()
void add_ids(::int64_t value)
void add_lower_bounds(double value)
void add_upper_bounds(double value)
void add_ids(::int64_t value)
void add_values(double value)
An object oriented wrapper for quadratic constraints in ModelStorage.
ElementId< ElementType::kVariable > VariableId
std::vector< T > SortedSetElements(const absl::flat_hash_set< T > &elements)
ElementId< ElementType::kLinearConstraint > LinearConstraintId
ClosedInterval::Iterator end(ClosedInterval interval)
absl::flat_hash_set< LinearConstraintId > lower_bounds
absl::flat_hash_set< LinearConstraintId > upper_bounds
absl::flat_hash_set< std::pair< LinearConstraintId, VariableId > > matrix_keys
LinearConstraintId checkpoint
Diff(const LinearConstraintStorage &storage, VariableId variable_checkpoint)
VariableId variable_checkpoint
absl::flat_hash_set< LinearConstraintId > deleted
LinearConstraintsProto creates
google::protobuf::RepeatedField< int64_t > deleted
LinearConstraintUpdatesProto updates
SparseDoubleMatrixProto matrix_updates