AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
merge_and_shrink_algorithm.h
1#ifndef MERGE_AND_SHRINK_MERGE_AND_SHRINK_ALGORITHM_H
2#define MERGE_AND_SHRINK_MERGE_AND_SHRINK_ALGORITHM_H
3
4#include "downward/utils/logging.h"
5
6#include <memory>
7
8class TaskProxy;
9
10namespace utils {
11class CountdownTimer;
12}
13
14namespace merge_and_shrink {
15class FactoredTransitionSystem;
16class LabelReduction;
17class MergeStrategyFactory;
18class ShrinkStrategy;
19
20class MergeAndShrinkAlgorithm {
21 // TODO: when the option parser supports it, the following should become
22 // unique pointers.
23 std::shared_ptr<MergeStrategyFactory> merge_strategy_factory;
24 std::shared_ptr<ShrinkStrategy> shrink_strategy;
25 std::shared_ptr<LabelReduction> label_reduction;
26
27 // Options for shrinking
28 // Hard limit: the maximum size of a transition system at any point.
29 const int max_states;
30 // Hard limit: the maximum size of a transition system before being merged.
31 const int max_states_before_merge;
32 /* A soft limit for triggering shrinking even if the hard limits
33 max_states and max_states_before_merge are not violated. */
34 const int shrink_threshold_before_merge;
35
36 // Options for pruning
37 const bool prune_unreachable_states;
38 const bool prune_irrelevant_states;
39
40 mutable utils::LogProxy log;
41 const double main_loop_max_time;
42
43 long starting_peak_memory;
44
45 void report_peak_memory_delta(bool final = false) const;
46 void dump_options() const;
47 void warn_on_unusual_options() const;
48 bool ran_out_of_time(const utils::CountdownTimer& timer) const;
49 void statistics(int maximum_intermediate_size) const;
50 void main_loop(FactoredTransitionSystem& fts, const TaskProxy& task_proxy);
51
52public:
53 MergeAndShrinkAlgorithm(
54 const std::shared_ptr<MergeStrategyFactory>& merge_strategy,
55 const std::shared_ptr<ShrinkStrategy>& shrink_strategy,
56 const std::shared_ptr<LabelReduction>& label_reduction,
57 bool prune_unreachable_states,
58 bool prune_irrelevant_states,
59 int max_states,
60 int max_states_before_merge,
61 int threshold_before_merge,
62 double main_loop_max_time,
63 utils::Verbosity verbosity);
64 FactoredTransitionSystem
65 build_factored_transition_system(const TaskProxy& task_proxy);
66};
67
68} // namespace merge_and_shrink
69
70#endif