1#include "probfd/successor_samplers/vdiff_successor_sampler.h"
3#include "probfd/algorithms/state_properties.h"
5#include "probfd/interval.h"
7#include "downward/utils/rng.h"
11template <
typename Action>
12VDiffSuccessorSampler<Action>::VDiffSuccessorSampler(
14 bool prefer_large_gaps)
15 : rng_(
std::make_shared<utils::RandomNumberGenerator>(random_seed))
16 , prefer_large_gaps_(prefer_large_gaps)
20template <
typename Action>
21VDiffSuccessorSampler<Action>::VDiffSuccessorSampler(
22 std::shared_ptr<utils::RandomNumberGenerator> rng,
23 bool prefer_large_gaps)
24 : rng_(
std::move(rng))
25 , prefer_large_gaps_(prefer_large_gaps)
29template <
typename Action>
30StateID VDiffSuccessorSampler<Action>::sample(
33 const Distribution<StateID>& successors,
34 algorithms::StateProperties& properties)
39 for (
const auto& [item, probability] : successors) {
40 const value_t error = properties.lookup_bounds(item).length();
42 probability * (prefer_large_gaps_ ? error : (1_vt - error));
45 biased_.add_probability(item, p);
48 if (biased_.empty()) {
49 return successors.sample(*rng_)->item;
51 biased_.normalize(1_vt / sum);
52 return biased_.sample(*rng_)->item;
This namespace contains implementations of transition successor samplers.
Definition arbitrary_sampler.h:7
double value_t
Typedef for the state value type.
Definition aliases.h:7