Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <util.h>
Public Member Functions | |
FirstFewValues () | |
void | Reset () |
void | Add (const int64_t positive_value) |
bool | MightBeReachable (int64_t sum) const |
const std::array< int64_t, n > & | reachable () const |
int64_t | LastValue () const |
Simple DP to keep the set of the first n reachable value (n > 1).
(user): Maybe modulo some prime number we can keep more info.
(user): Another common case is a bunch of really small values and larger ones, so we could bound the sum of the small values and keep the first few reachable by the big ones. This is similar to some presolve transformations.
|
inline |
|
inline |
We assume the given positive value can be added as many time as wanted.
We copy from reachable_[i] to new_reachable_[j]. The position zero is already copied.
Eliminate duplicates.
insert candidate in its final place.
|
inline |
|
inline |
Returns true iff sum might be expressible as a weighted sum of the added value. Any sum >= LastValue() is always considered potentially reachable.
|
inline |
|
inline |