AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
match_tree.h
1#ifndef PDBS_MATCH_TREE_H
2#define PDBS_MATCH_TREE_H
3
4#include "downward/pdbs/types.h"
5
6#include "downward/task_proxy.h"
7
8#include <cstddef>
9#include <vector>
10
11namespace utils {
12class LogProxy;
13}
14
15namespace pdbs {
16/*
17 Successor Generator for abstract operators.
18
19 NOTE: MatchTree keeps a reference to the task proxy passed to the constructor.
20 Therefore, users of the class must ensure that the task lives at least as long
21 as the match tree.
22*/
23
24class MatchTree {
25 TaskProxy task_proxy;
26 struct Node;
27 // See PatternDatabase for documentation on pattern and hash_multipliers.
28 Pattern pattern;
29 std::vector<int> hash_multipliers;
30 Node* root;
31 void insert_recursive(
32 int op_id,
33 const std::vector<FactPair>& regression_preconditions,
34 int pre_index,
35 Node** edge_from_parent);
36 void get_applicable_operator_ids_recursive(
37 Node* node,
38 int state_index,
39 std::vector<int>& operator_ids) const;
40 void dump_recursive(Node* node, utils::LogProxy& log) const;
41
42public:
43 // Initialize an empty match tree.
44 MatchTree(
45 const TaskProxy& task_proxy,
46 const Pattern& pattern,
47 const std::vector<int>& hash_multipliers);
48 ~MatchTree();
49 /* Insert an abstract operator into the match tree, creating or
50 enlarging it. */
51 void
52 insert(int op_id, const std::vector<FactPair>& regression_preconditions);
53
54 /*
55 Extracts all IDs of applicable abstract operators for the abstract state
56 given by state_index (the index is converted back to variable/values
57 pairs).
58 */
59 void
60 get_applicable_operator_ids(int state_index, std::vector<int>& operator_ids)
61 const;
62 void dump(utils::LogProxy& log) const;
63};
64} // namespace pdbs
65
66#endif