AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
utils.h
1#ifndef MERGE_AND_SHRINK_UTILS_H
2#define MERGE_AND_SHRINK_UTILS_H
3
4#include "downward/merge_and_shrink/types.h"
5
6#include <memory>
7#include <vector>
8
9namespace utils {
10class LogProxy;
11}
12
13namespace merge_and_shrink {
14class FactoredTransitionSystem;
15class ShrinkStrategy;
16class TransitionSystem;
17
18/*
19 Compute target sizes for shrinking two transition systems with sizes size1
20 and size2 before they are merged. Use the following rules:
21 1) Right before merging, the transition systems may have at most
22 max_states_before_merge states.
23 2) Right after merging, the product may have most max_states_after_merge
24 states.
25 3) Transition systems are shrunk as little as necessary to satisfy the above
26 constraints. (If possible, neither is shrunk at all.)
27 There is often a Pareto frontier of solutions following these rules. In this
28 case, balanced solutions (where the target sizes are close to each other)
29 are preferred over less balanced ones.
30*/
31extern std::pair<int, int> compute_shrink_sizes(
32 int size1,
33 int size2,
34 int max_states_before_merge,
35 int max_states_after_merge);
36
37/*
38 This function first determines if any of the two factors at indices index1
39 and index2 must be shrunk according to the given size limits max_states and
40 max_states_before_merge, using the function compute_shrink_sizes (see above).
41 If not, then the function further checks if any of the two factors has a
42 size larger than shrink_treshold_before_merge, in which case shrinking is
43 still triggered.
44
45 If shrinking is triggered, apply the abstraction to the two factors
46 within the factored transition system. Return true iff at least one of the
47 factors was shrunk.
48*/
49extern bool shrink_before_merge_step(
50 FactoredTransitionSystem& fts,
51 int index1,
52 int index2,
53 int max_states,
54 int max_states_before_merge,
55 int shrink_threshold_before_merge,
56 const ShrinkStrategy& shrink_strategy,
57 utils::LogProxy& log);
58
59/*
60 Prune unreachable and/or irrelevant states of the factor at index. This
61 requires that init and/or goal distances have been computed accordingly.
62 Return true iff any states have been pruned.
63
64 TODO: maybe this functionality belongs to a new class PruneStrategy.
65*/
66extern bool prune_step(
67 FactoredTransitionSystem& fts,
68 int index,
69 bool prune_unreachable_states,
70 bool prune_irrelevant_states,
71 utils::LogProxy& log);
72
73/*
74 Compute the abstraction mapping based on the given state equivalence
75 relation.
76*/
77extern std::vector<int> compute_abstraction_mapping(
78 int num_states,
79 const StateEquivalenceRelation& equivalence_relation);
80
81extern bool is_goal_relevant(const TransitionSystem& ts);
82} // namespace merge_and_shrink
83
84#endif