AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
caching_task_state_space.h
1#ifndef PROBFD_CACHING_TASK_STATE_SPACE_H
2#define PROBFD_CACHING_TASK_STATE_SPACE_H
3
4#include "probfd/task_state_space.h"
5
6#include "probfd/storage/segmented_memory_pool.h"
7
8#include "probfd/fdr_types.h"
9#include "probfd/types.h"
10
11#include "downward/per_state_information.h"
12
13#include <limits>
14#include <memory>
15#include <vector>
16
17// Forward Declarations
18class Evaluator;
19class State;
20class OperatorID;
21
22namespace utils {
23class LogProxy;
24}
25
26namespace probfd {
27class ProbabilisticTask;
28template <typename>
29class Distribution;
30} // namespace probfd
31
32namespace probfd {
33
34class CachingTaskStateSpace : public TaskStateSpace {
35 struct CacheEntry {
36 [[nodiscard]]
37 bool is_initialized() const
38 {
39 return naops != std::numeric_limits<unsigned>::max();
40 }
41
42 unsigned naops = std::numeric_limits<unsigned>::max();
43 OperatorID* aops = nullptr;
44 StateID* succs = nullptr;
45 };
46
47 PerStateInformation<CacheEntry> cache_;
48 storage::SegmentedMemoryPool<> cache_data_;
49
50 std::vector<OperatorID> aops_;
51 std::vector<StateID> successors_;
52
53public:
54 CachingTaskStateSpace(
55 std::shared_ptr<ProbabilisticTask> task,
56 utils::LogProxy log,
57 std::vector<std::shared_ptr<::Evaluator>> path_dependent_evaluators);
58
59 void generate_applicable_actions(
60 const State& state,
61 std::vector<OperatorID>& result) final;
62
63 void generate_action_transitions(
64 const State& state,
65 OperatorID operator_id,
66 Distribution<StateID>& result) final;
67
68 void generate_all_transitions(
69 const State& state,
70 std::vector<OperatorID>& aops,
71 std::vector<Distribution<StateID>>& successors) final;
72
73 void generate_all_transitions(
74 const State& state,
75 std::vector<TransitionType>& transitions) final;
76
77 void print_statistics() const final;
78
79private:
80 void compute_successor_states(
81 const State& s,
82 OperatorID op_id,
83 std::vector<StateID>& successors);
84
85 void setup_cache(const State& state, CacheEntry& entry);
86
87 CacheEntry& lookup(const State& state);
88};
89
90} // namespace probfd
91
92#endif // PROBFD_CACHING_TASK_STATE_SPACE_H
The top-level namespace of probabilistic Fast Downward.
Definition command_line.h:8
STL namespace.