AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
shrink_bucket_based.h
1#ifndef MERGE_AND_SHRINK_SHRINK_BUCKET_BASED_H
2#define MERGE_AND_SHRINK_SHRINK_BUCKET_BASED_H
3
4#include "downward/merge_and_shrink/shrink_strategy.h"
5
6#include <memory>
7#include <vector>
8
9namespace utils {
10class RandomNumberGenerator;
11}
12
13namespace merge_and_shrink {
14/* A base class for bucket-based shrink strategies.
15
16 A bucket-based strategy partitions the states into an ordered
17 vector of buckets, from low to high priority, and then abstracts
18 them to a given target size according to the following rules:
19
20 Repeat until we respect the target size:
21 If any bucket still contains two states:
22 Combine two random states from the non-singleton bucket
23 with the lowest priority.
24 Otherwise:
25 Combine the two lowest-priority buckets.
26
27 For the (usual) case where the target size is larger than the
28 number of buckets, this works out in such a way that the
29 high-priority buckets are not abstracted at all, the low-priority
30 buckets are abstracted by combining all states in each bucket, and
31 (up to) one bucket "in the middle" is partially abstracted.
32*/
33class ShrinkBucketBased : public ShrinkStrategy {
34protected:
35 using Bucket = std::vector<int>;
36 std::shared_ptr<utils::RandomNumberGenerator> rng;
37
38private:
39 StateEquivalenceRelation compute_abstraction(
40 const std::vector<Bucket>& buckets,
41 int target_size,
42 utils::LogProxy& log) const;
43
44protected:
45 virtual std::vector<Bucket> partition_into_buckets(
46 const TransitionSystem& ts,
47 const Distances& Distances) const = 0;
48
49public:
50 explicit ShrinkBucketBased(int random_seed);
51 virtual StateEquivalenceRelation compute_equivalence_relation(
52 const TransitionSystem& ts,
53 const Distances& distances,
54 int target_size,
55 utils::LogProxy& log) const override;
56};
57
58} // namespace merge_and_shrink
59
60#endif