Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <scattered_vector.h>
Public Member Functions | |
Fractional | operator[] (Index index) const |
Fractional & | operator[] (Index index) |
Iterator | begin () const |
Iterator | end () const |
void | Add (Index index, Fractional value) |
void | SortNonZerosIfNeeded () |
bool | ShouldUseDenseIteration (double ratio_for_using_dense_representation) const |
bool | ShouldUseDenseIteration () const |
void | ClearSparseMask () |
Efficiently clears the is_non_zero vector. | |
void | RepopulateSparseMask () |
Update the is_non_zero vector to be consistent with the non_zeros vector. | |
void | ClearNonZerosIfTooDense (double ratio_for_using_dense_representation) |
void | ClearNonZerosIfTooDense () |
size_t | NumNonZerosEstimate () const |
Public Attributes | |
StrictITIVector< Index, Fractional > | values |
bool | non_zeros_are_sorted = false |
std::vector< Index > | non_zeros |
StrictITIVector< Index, bool > | is_non_zero |
Static Public Attributes | |
static constexpr const double | kDefaultRatioForUsingDenseIteration = 0.8 |
A simple struct that contains a DenseVector and its non-zero indices.
Definition at line 53 of file scattered_vector.h.
|
inline |
Add the given value to the vector at position index. This interface encapsulates usage of the "is_non_zero" array, which should not be explicitly referenced outside of this struct.
Definition at line 95 of file scattered_vector.h.
|
inline |
The iterator syntax for (auto entry : v) where v is a ScatteredVector only works when non_zeros is populated (i.e., when the vector is treated as sparse).
Definition at line 83 of file scattered_vector.h.
|
inline |
Definition at line 156 of file scattered_vector.h.
|
inline |
If the proportion of non-zero entries is too large, clears the vector of non-zeros.
Definition at line 149 of file scattered_vector.h.
|
inline |
Efficiently clears the is_non_zero vector.
Definition at line 129 of file scattered_vector.h.
|
inline |
Definition at line 87 of file scattered_vector.h.
|
inline |
Returns an overestimate of the number of non-zeros. This is actually exact for sparse vector, or the full size otherwise.
Definition at line 162 of file scattered_vector.h.
|
inline |
Definition at line 78 of file scattered_vector.h.
|
inline |
Definition at line 77 of file scattered_vector.h.
|
inline |
Update the is_non_zero vector to be consistent with the non_zeros vector.
Definition at line 142 of file scattered_vector.h.
|
inline |
Definition at line 124 of file scattered_vector.h.
|
inline |
Returns true if it is more advantageous to use a dense iteration rather than using the non-zeros positions.
Definition at line 116 of file scattered_vector.h.
|
inline |
Sorting the non-zeros is not always needed, but it allows us to have exactly the same behavior while using a sparse iteration or a dense one. So we always do it after a Solve().
Definition at line 107 of file scattered_vector.h.
StrictITIVector<Index, bool> operations_research::glop::ScatteredVector< Index, Iterator >::is_non_zero |
Temporary vector used in some sparse computation on the ScatteredVector. True indicates a possible non-zero value. Note that its state is not always consistent.
Definition at line 64 of file scattered_vector.h.
|
staticconstexpr |
In many cases there is a choice between treating the ScatteredVector as dense or as sparse. By default, dense algorithms are used when the proportion of non-zero entries is greater than kDefaultRatioForUsingDenseIteration.
Definition at line 75 of file scattered_vector.h.
std::vector<Index> operations_research::glop::ScatteredVector< Index, Iterator >::non_zeros |
Definition at line 59 of file scattered_vector.h.
bool operations_research::glop::ScatteredVector< Index, Iterator >::non_zeros_are_sorted = false |
This can be left empty in which case we just have the dense representation above. Otherwise, it should always be a superset of the actual non-zeros.
Definition at line 58 of file scattered_vector.h.
StrictITIVector<Index, Fractional> operations_research::glop::ScatteredVector< Index, Iterator >::values |
Definition at line 54 of file scattered_vector.h.