19#include "absl/algorithm/container.h"
20#include "absl/container/flat_hash_map.h"
21#include "absl/container/flat_hash_set.h"
22#include "absl/strings/string_view.h"
34 const absl::string_view
name) {
36 VariableData& var_data = variables_[id];
40 var_data.name = std::string(
name);
46 std::vector<VariableId> result;
47 result.reserve(variables_.size());
48 for (
const auto& [var, _] : variables_) {
49 result.push_back(var);
55 std::vector<VariableId> result =
Variables();
62 std::vector<VariableId> result;
64 util_intops::MakeStrongIntRange(start, next_variable_id_)) {
65 if (variables_.contains(v)) {
72void VariableStorage::AppendVariable(
const VariableId variable,
74 const VariableData& data = variables_.at(variable);
85 AppendVariable(v, &result);
117 util_intops::MakeStrongIntRange(diff.
checkpoint, next_variable_id_)) {
118 if (variables_.contains(v)) {
119 AppendVariable(v, &result.
creates);
int64_t value() const
Returns the raw id value.
void add_values(bool value)
void add_ids(::int64_t value)
void add_ids(::int64_t value)
void add_values(double value)
VariablesProto Proto() const
An equivalent proto of this.
double upper_bound(VariableId id) const
double lower_bound(VariableId id) const
std::vector< VariableId > Variables() const
The VariableIds in use (not deleted), order not defined.
bool is_integer(VariableId id) const
void AdvanceCheckpointInDiff(Diff &diff) const
Updates the checkpoint and clears all stored changes in diff.
std::vector< VariableId > SortedVariables() const
std::vector< VariableId > VariablesFrom(VariableId start) const
VariableId Add(double lower_bound, double upper_bound, bool is_integer, absl::string_view name)
const std::string & name(VariableId id) const
UpdateResult Update(const Diff &diff) const
::operations_research::math_opt::SparseDoubleVectorProto *PROTOBUF_NONNULL mutable_lower_bounds()
::operations_research::math_opt::SparseDoubleVectorProto *PROTOBUF_NONNULL mutable_upper_bounds()
::operations_research::math_opt::SparseBoolVectorProto *PROTOBUF_NONNULL mutable_integers()
::std::string *PROTOBUF_NONNULL add_names()
void add_lower_bounds(double value)
void add_upper_bounds(double value)
void add_ids(::int64_t value)
void add_integers(bool 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)
absl::flat_hash_set< VariableId > integer
absl::flat_hash_set< VariableId > lower_bounds
absl::flat_hash_set< VariableId > upper_bounds
absl::flat_hash_set< VariableId > deleted
google::protobuf::RepeatedField< int64_t > deleted
Variables before the checkpoint that have been deleted.
VariablesProto creates
Variables created at or after the checkpoint that have not been deleted.
VariableUpdatesProto updates
Variables before the checkpoint that have been modified and not deleted.