24 isStateValid(
const Cache& cache)
31 doStateAssembly(
Cache&& cache,
const double newWeight)
33 if (!isStateValid(cache)) {
39 const double fixedWeights = 1. /
static_cast<double>(cacheSize);
41 component.weight = fixedWeights;
52 const double scalingFactor =
55 component.weight *= scalingFactor;
63 prepareStateForAssembly(
Cache& cache)
66 if (!isStateValid(cache)) {
72 double validWeightFraction = den > 0 ? cache.
validWeightSum / den : 0;
81 return x.weight > y.weight;
85 if (totalWeight != 0.) {
89 const double minimumWeight =
95 auto lower_than = std::upper_bound(
102 auto lower_than_reverse = std::make_reverse_iterator(lower_than);
104 itr != lower_than_reverse;
110 if (!isStateValid(cache)) {
123 if (!prepareStateForAssembly(cache)) {
131 return doStateAssembly(std::move(cache), totalWeight);