Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <util.h>
Public Member Functions | |
MaxBoundedSubsetSum () | |
MaxBoundedSubsetSum (int64_t bound, int max_complexity_per_add=50) | |
void | Reset (int64_t bound) |
int64_t | MaxIfAdded (int64_t candidate) const |
Returns the updated max if value was added to the subset-sum. | |
void | Add (int64_t value) |
Add a value to the base set for which subset sums will be taken. | |
void | AddChoices (absl::Span< const int64_t > choices) |
void | AddMultiples (int64_t coeff, int64_t max_value) |
Adds [0, coeff, 2 * coeff, ... max_value * coeff]. | |
int64_t | CurrentMax () const |
int64_t | Bound () const |
Simple DP to compute the maximum reachable value of a "subset sum" under a given bound (inclusive). Note that we abort as soon as the computation become too important.
Precondition: Both bound and all added values must be >= 0.
|
inline |
|
inlineexplicit |
void operations_research::sat::MaxBoundedSubsetSum::Add | ( | int64_t | value | ) |
void operations_research::sat::MaxBoundedSubsetSum::AddChoices | ( | absl::Span< const int64_t > | choices | ) |
Add a choice of values to the base set for which subset sums will be taken.
The max is already reachable or we aborted.
Filter out zero and values greater than bound_.
So we can abort early in the AddChoicesInternal() inner loops.
void operations_research::sat::MaxBoundedSubsetSum::AddMultiples | ( | int64_t | coeff, |
int64_t | max_value ) |
|
inline |
|
inline |
int64_t operations_research::sat::MaxBoundedSubsetSum::MaxIfAdded | ( | int64_t | candidate | ) | const |
void operations_research::sat::MaxBoundedSubsetSum::Reset | ( | int64_t | bound | ) |