Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <variable_storage.h>
Classes | |
struct | Diff |
struct | UpdateResult |
Public Member Functions | |
VariableId | Add (double lower_bound, double upper_bound, bool is_integer, absl::string_view name) |
double | lower_bound (VariableId id) const |
double | upper_bound (VariableId id) const |
bool | is_integer (VariableId id) const |
const std::string & | name (VariableId id) const |
template<typename DiffIter > | |
void | set_lower_bound (VariableId id, double lower_bound, const iterator_range< DiffIter > &diffs) |
template<typename DiffIter > | |
void | set_upper_bound (VariableId id, double upper_bound, const iterator_range< DiffIter > &diffs) |
template<typename DiffIter > | |
void | set_integer (VariableId id, bool is_integer, const iterator_range< DiffIter > &diffs) |
template<typename DiffIter > | |
void | Delete (VariableId id, const iterator_range< DiffIter > &diffs) |
int64_t | size () const |
VariableId | next_id () const |
void | ensure_next_id_at_least (VariableId minimum) |
Sets the next variable id to be the maximum of next_id() and minimum . | |
bool | contains (VariableId id) const |
Returns true if this id has been created and not yet deleted. | |
std::vector< VariableId > | Variables () const |
The VariableIds in use (not deleted), order not defined. | |
std::vector< VariableId > | SortedVariables () const |
VariablesProto | Proto () const |
An equivalent proto of this . | |
bool | diff_is_empty (const Diff &diff) const |
UpdateResult | Update (const Diff &diff) const |
void | AdvanceCheckpointInDiff (Diff &diff) const |
Updates the checkpoint and clears all stored changes in diff. | |
std::vector< VariableId > | VariablesFrom (VariableId start) const |
The in memory representation of the variables of an optimization model.
The setter functions all accept a DiffIter
, which must be an iterator over non-const references to VariableStorage::Diff. These functions will modify the VariableStorage::Diff objects.
Definition at line 39 of file variable_storage.h.
VariableId operations_research::math_opt::VariableStorage::Add | ( | double | lower_bound, |
double | upper_bound, | ||
bool | is_integer, | ||
absl::string_view | name ) |
Adds a variable to the model and returns its id.
The returned ids begin at zero and strictly increase (in particular, if ensure_next_id_at_least() is not used, they will be consecutive). Deleted ids are NOT reused.
Definition at line 32 of file variable_storage.cc.
void operations_research::math_opt::VariableStorage::AdvanceCheckpointInDiff | ( | Diff & | diff | ) | const |
Updates the checkpoint and clears all stored changes in diff.
Definition at line 90 of file variable_storage.cc.
|
inline |
Returns true if this id has been created and not yet deleted.
Definition at line 251 of file variable_storage.h.
void operations_research::math_opt::VariableStorage::Delete | ( | VariableId | id, |
const iterator_range< DiffIter > & | diffs ) |
Removes a variable from the model.
It is an error to use a deleted variable id as input to any subsequent function calls on this.
Definition at line 229 of file variable_storage.h.
|
inline |
Functions for working with Diff Returns true if there are no changes (tracked changes before the checkpoint or new constraints after the checkpoint).
Definition at line 255 of file variable_storage.h.
|
inline |
Sets the next variable id to be the maximum of next_id() and minimum
.
Definition at line 247 of file variable_storage.h.
|
inline |
Definition at line 175 of file variable_storage.h.
|
inline |
Inline functions
Definition at line 167 of file variable_storage.h.
|
inline |
Definition at line 179 of file variable_storage.h.
|
inline |
The returned id of the next call to AddVariable.
Equal to the number of variables created.
Definition at line 245 of file variable_storage.h.
VariablesProto operations_research::math_opt::VariableStorage::Proto | ( | ) | const |
An equivalent proto of this
.
Definition at line 82 of file variable_storage.cc.
void operations_research::math_opt::VariableStorage::set_integer | ( | VariableId | id, |
bool | is_integer, | ||
const iterator_range< DiffIter > & | diffs ) |
Definition at line 214 of file variable_storage.h.
void operations_research::math_opt::VariableStorage::set_lower_bound | ( | VariableId | id, |
double | lower_bound, | ||
const iterator_range< DiffIter > & | diffs ) |
Definition at line 184 of file variable_storage.h.
void operations_research::math_opt::VariableStorage::set_upper_bound | ( | VariableId | id, |
double | upper_bound, | ||
const iterator_range< DiffIter > & | diffs ) |
Definition at line 199 of file variable_storage.h.
|
inline |
The number of variables in the model.
Equal to the number of variables created minus the number of variables deleted.
Definition at line 243 of file variable_storage.h.
std::vector< VariableId > operations_research::math_opt::VariableStorage::SortedVariables | ( | ) | const |
Returns a sorted vector of all existing (not deleted) variables in the model.
Runs in O(n log(n)), where n is the number of variables returned.
Definition at line 54 of file variable_storage.cc.
VariableStorage::UpdateResult operations_research::math_opt::VariableStorage::Update | ( | const Diff & | diff | ) | const |
Definition at line 98 of file variable_storage.cc.
|
inline |
Definition at line 171 of file variable_storage.h.
std::vector< VariableId > operations_research::math_opt::VariableStorage::Variables | ( | ) | const |
The VariableIds in use (not deleted), order not defined.
Definition at line 45 of file variable_storage.cc.
std::vector< VariableId > operations_research::math_opt::VariableStorage::VariablesFrom | ( | VariableId | start | ) | const |
Returns the variables in the model starting with start (inclusive) and larger in order. Runs in O(next_id() - start).
Definition at line 60 of file variable_storage.cc.