AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
sampling.h
1#ifndef PROBFD_TASK_UTILS_SAMPLING_H
2#define PROBFD_TASK_UTILS_SAMPLING_H
3
4#include "probfd/task_proxy.h"
5#include "probfd/value_type.h"
6
7#include <functional>
8#include <memory>
9
10namespace probfd::successor_generator {
11class ProbabilisticSuccessorGenerator;
12}
13
14namespace utils {
15class RandomNumberGenerator;
16}
17
18namespace probfd::sampling {
19/*
20 Sample states with random walks.
21*/
22class RandomWalkSampler {
23 const ProbabilisticOperatorsProxy operators;
24 const std::unique_ptr<successor_generator::ProbabilisticSuccessorGenerator>
25 successor_generator;
26 const State initial_state;
27 const double average_operator_costs;
28 utils::RandomNumberGenerator& rng;
29
30public:
31 RandomWalkSampler(
32 const ProbabilisticTaskProxy& task_proxy,
33 utils::RandomNumberGenerator& rng);
34 ~RandomWalkSampler();
35
36 /*
37 Perform a single random walk and return the last visited state.
38
39 The walk length is taken from a binomial distribution centered around the
40 estimated plan length, which is computed as the ratio of the h value of
41 the initial state divided by the average operator costs. Whenever a dead
42 end is detected or a state has no successors, restart from the initial
43 state. The function 'is_terminal' should return whether a given state is
44 a dead end. If omitted, no dead end detection is performed. The 'init_h'
45 value should be an estimate of the solution cost.
46 */
47 State sample_state(
48 value_t init_h,
49 const std::function<bool(const State&)>& is_dead_end =
50 [](const State&) { return false; }) const;
51};
52
53} // namespace probfd::sampling
54
55#endif // PROBFD_TASK_UTILS_SAMPLING_H
double value_t
Typedef for the state value type.
Definition aliases.h:7