AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
pattern_cliques.h
1#ifndef PDBS_PATTERN_CLIQUES_H
2#define PDBS_PATTERN_CLIQUES_H
3
4#include "downward/pdbs/types.h"
5
6#include <memory>
7#include <vector>
8
9class TaskProxy;
10
11namespace pdbs {
12using VariableAdditivity = std::vector<std::vector<bool>>;
13
14extern VariableAdditivity compute_additive_vars(const TaskProxy& task_proxy);
15
16/* Returns true iff the two patterns are additive i.e. there is no operator
17 which affects variables in pattern one as well as in pattern two. */
18extern bool are_patterns_additive(
19 const Pattern& pattern1,
20 const Pattern& pattern2,
21 const VariableAdditivity& are_additive);
22
23/*
24 Computes pattern cliques of the given patterns.
25*/
26extern std::shared_ptr<std::vector<PatternClique>> compute_pattern_cliques(
27 const PatternCollection& patterns,
28 const VariableAdditivity& are_additive);
29
30/*
31 We compute pattern cliques S with the property that we could
32 add the new pattern P to S and still have a pattern clique.
33
34 Ideally, we would like to return all *maximal* cliques S with this
35 property (w.r.t. set inclusion), but we don't currently
36 guarantee this. (What we guarantee is that all maximal such cliques
37 are *included* in the result, but the result could contain
38 duplicates or cliques that are subcliques of other cliques in the
39 result.)
40
41 We currently implement this as follows:
42
43 * Consider all pattern cliques of the current collection.
44 * For each clique S, take the subclique S' that contains
45 those patterns that are additive with the new pattern P.
46 * Include the subclique S' in the result.
47
48 As an optimization, we actually only include S' in the result if
49 it is non-empty. However, this is wrong if *all* subcliques we get
50 are empty, so we correct for this case at the end.
51
52 This may include dominated elements and duplicates in the result.
53 To avoid this, we could instead use the following algorithm:
54
55 * Let N (= neighbours) be the set of patterns in our current
56 collection that are additive with the new pattern P.
57 * Let G_N be the compatibility graph of the current collection
58 restricted to set N (i.e. drop all non-neighbours and their
59 incident edges.)
60 * Return the maximal cliques of G_N.
61
62 One nice thing about this alternative algorithm is that we could
63 also use it to incrementally compute the new set of pattern cliques
64 after adding the new pattern P:
65
66 G_N_cliques = max_cliques(G_N) // as above
67 new_max_cliques = (old_max_cliques \setminus G_N_cliques) \union
68 { clique \union {P} | clique in G_N_cliques}
69
70 That is, the new set of maximal cliques is exactly the set of
71 those "old" cliques that we cannot extend by P
72 (old_max_cliques \setminus G_N_cliques) and all
73 "new" cliques including P.
74 */
75extern std::vector<PatternClique> compute_pattern_cliques_with_pattern(
76 const PatternCollection& patterns,
77 const std::vector<PatternClique>& known_pattern_cliques,
78 const Pattern& new_pattern,
79 const VariableAdditivity& are_additive);
80} // namespace pdbs
81
82#endif