AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
bisimulation_heuristic_search_algorithm.h
1#ifndef PROBFD_SOLVERS_BISIMULATION_HEURISTIC_SEARCH_ALGORITHM_H
2#define PROBFD_SOLVERS_BISIMULATION_HEURISTIC_SEARCH_ALGORITHM_H
3
4#include "probfd/solvers/mdp_solver.h"
5
6#include "probfd/algorithms/policy_picker.h"
7
8#include "probfd/bisimulation/bisimilar_state_space.h"
9
10#include "probfd/quotients/quotient_system.h"
11
12#include "probfd/mdp_algorithm.h"
13#include "probfd/task_proxy.h"
14
15#include "downward/utils/timer.h"
16
17namespace probfd::solvers {
18
19struct BisimulationTimer {
20 double time = 0.0;
21 unsigned states = 0;
22 unsigned transitions = 0;
23
24 void print(std::ostream& out) const;
25};
26
27class BisimulationBasedHeuristicSearchAlgorithm : public FDRMDPAlgorithm {
28protected:
29 using QState = bisimulation::QuotientState;
30 using QAction = bisimulation::QuotientAction;
31
32 using QQState = quotients::QuotientState<QState, QAction>;
33 using QQAction = quotients::QuotientAction<QAction>;
34
35 const std::shared_ptr<ProbabilisticTask> task_;
36 const std::shared_ptr<FDRCostFunction> task_cost_function_;
37
38 const std::string algorithm_name_;
39
40 std::shared_ptr<MDPAlgorithm<QState, QAction>> algorithm_;
41
42 BisimulationTimer stats_;
43
44public:
45 BisimulationBasedHeuristicSearchAlgorithm(
46 std::shared_ptr<ProbabilisticTask> task,
47 std::shared_ptr<FDRCostFunction> task_cost_function,
48 std::string algorithm_name,
49 std::shared_ptr<MDPAlgorithm<QState, QAction>> algorithm);
50
51 Interval solve(
52 FDRMDP&,
54 const State&,
55 ProgressReport progress,
56 double max_time) override;
57
58 std::unique_ptr<PolicyType> compute_policy(
59 FDRMDP&,
61 const State&,
62 ProgressReport progress,
63 double max_time) override;
64
65 void print_statistics(std::ostream& out) const override;
66
67 template <
68 template <typename, typename, bool>
69 class HS,
70 bool Interval,
71 typename... Args>
72 static std::unique_ptr<BisimulationBasedHeuristicSearchAlgorithm> create(
73 std::shared_ptr<ProbabilisticTask> task,
74 std::shared_ptr<FDRCostFunction> task_cost_function,
75 std::string algorithm_name,
76 std::shared_ptr<algorithms::PolicyPicker<QState, QAction>> tiebreaker,
77 Args&&... args)
78 {
79 return std::make_unique<BisimulationBasedHeuristicSearchAlgorithm>(
80 std::move(task),
81 std::move(task_cost_function),
82 std::move(algorithm_name),
83 std::make_shared<HS<QState, QAction, Interval>>(
84 tiebreaker,
85 std::forward<Args>(args)...));
86 }
87
88 template <
89 template <typename, typename, typename>
90 class Fret,
91 template <typename, typename, bool>
92 class HS,
93 bool Interval,
94 typename... Args>
95 static std::unique_ptr<BisimulationBasedHeuristicSearchAlgorithm> create(
96 std::shared_ptr<ProbabilisticTask> task,
97 std::shared_ptr<FDRCostFunction> task_cost_function,
98 std::string algorithm_name,
99 std::shared_ptr<algorithms::PolicyPicker<QQState, QQAction>> tiebreaker,
100 Args&&... args)
101 {
102 using StateInfoT = typename HS<QQState, QQAction, Interval>::StateInfo;
103 return std::make_unique<BisimulationBasedHeuristicSearchAlgorithm>(
104 std::move(task),
105 std::move(task_cost_function),
106 std::move(algorithm_name),
107 std::make_shared<Fret<QState, QAction, StateInfoT>>(
108 std::make_shared<HS<QQState, QQAction, Interval>>(
109 tiebreaker,
110 std::forward<Args>(args)...)));
111 }
112};
113
114} // namespace probfd::solvers
115
116#endif // PROBFD_SOLVERS_BISIMULATION_HEURISTIC_SEARCH_ALGORITHM_H
Basic interface for MDPs.
Definition mdp_algorithm.h:14
A registry for print functions related to search progress.
Definition progress_report.h:33
An strategy interface used to choose break ties between multiple greedy actions for a state.
Definition policy_picker.h:57
QuotientAction
Represents an action in the probabilistic bisimulation quotient.
Definition types.h:12
QuotientState
Represents a state in the probabilistic bisimulation quotient.
Definition types.h:9
This namespace contains the solver interface base class for various search algorithms.
Definition bisimulation_heuristic_search_algorithm.h:17
Represents a closed interval over the extended reals as a pair of lower and upper bound.
Definition interval.h:12