Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <sparse_coefficient_map.h>
Public Member Functions | |
SparseCoefficientMap ()=default | |
SparseCoefficientMap (absl::flat_hash_map< VariableId, double > terms) | |
double | get (VariableId id) const |
Returns 0.0 by default if no value is set. | |
bool | set (VariableId id, double coeff) |
Returns true if the stored value changes. | |
const absl::flat_hash_map< VariableId, double > & | terms () const |
void | clear () |
void | erase (VariableId id) |
Has no effect if id is not set. | |
SparseDoubleVectorProto | Proto () const |
Represents a sparse collection of linear terms: {double_i x VariableId_i}_i. All VariableIds not represented in the collection are implicitly treated as having zero coefficient.
Internally it is a lightweight wrapper around absl::flat_hash_map that only explicitly stores nonzero elements.
Definition at line 33 of file sparse_coefficient_map.h.
|
default |
|
inlineexplicit |
Inline implementations
Definition at line 67 of file sparse_coefficient_map.h.
|
inline |
Definition at line 96 of file sparse_coefficient_map.h.
|
inline |
Has no effect if id is not set.
Definition at line 98 of file sparse_coefficient_map.h.
|
inline |
Returns 0.0 by default if no value is set.
Definition at line 73 of file sparse_coefficient_map.h.
SparseDoubleVectorProto operations_research::math_opt::SparseCoefficientMap::Proto | ( | ) | const |
Definition at line 24 of file sparse_coefficient_map.cc.
|
inline |
Returns true if the stored value changes.
Definition at line 81 of file sparse_coefficient_map.h.
|
inline |
Definition at line 46 of file sparse_coefficient_map.h.