AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
interval_iteration.h
1#ifndef PROBFD_ALGORITHMS_INTERVAL_ITERATION_H
2#define PROBFD_ALGORITHMS_INTERVAL_ITERATION_H
3
4#include "probfd/algorithms/topological_value_iteration.h"
5
6#include "probfd/preprocessing/end_component_decomposition.h"
7#include "probfd/preprocessing/qualitative_reachability_analysis.h"
8
9#include "probfd/quotients/quotient_system.h"
10
11#include "probfd/storage/per_state_storage.h"
12
13#include "probfd/mdp_algorithm.h"
14
15#include <limits>
16
19
20struct Statistics {
21 preprocessing::ECDStatistics ecd_statistics;
22 topological_vi::Statistics tvi_statistics;
23
24 void print(std::ostream& out) const
25 {
26 tvi_statistics.print(out);
27 ecd_statistics.print(out);
28 }
29};
30
61template <typename State, typename Action>
62class IntervalIteration : public MDPAlgorithm<State, Action> {
63 using Base = typename IntervalIteration::MDPAlgorithm;
64
65 using MDPType = typename Base::MDPType;
66 using EvaluatorType = typename Base::EvaluatorType;
67 using PolicyType = typename Base::PolicyType;
68
69 using QSystem = quotients::QuotientSystem<State, Action>;
70 using QState = quotients::QuotientState<State, Action>;
71 using QAction = quotients::QuotientAction<Action>;
72
74 using QuotientQRAnalysis =
78
79 // Algorithm parameters
80 const bool extract_probability_one_states_;
81
82 // Algorithm state
83 QuotientQRAnalysis qr_analysis_;
84 Decomposer ec_decomposer_;
86
87 Statistics statistics_;
88
89public:
90 explicit IntervalIteration(
91 bool extract_probability_one_states,
92 bool expand_goals);
93
94 Interval solve(
95 MDPType& mdp,
96 EvaluatorType& heuristic,
98 ProgressReport report,
99 double max_time) override;
100
101 std::unique_ptr<PolicyType> compute_policy(
102 MDPType& mdp,
103 EvaluatorType& heuristic,
104 param_type<State> state,
105 ProgressReport report,
106 double max_time) override;
107
108 void print_statistics(std::ostream& out) const override;
109
110 template <typename ValueStoreT, typename SetLike, typename SetLike2>
111 Interval solve(
112 MDPType& mdp,
113 EvaluatorType& heuristic,
114 param_type<State> state,
115 ValueStoreT& value_store,
116 SetLike& dead_ends,
117 SetLike2& one_states,
118 double max_time = std::numeric_limits<double>::infinity());
119
120private:
121 std::unique_ptr<QSystem> create_quotient(
122 MDPType& mdp,
123 EvaluatorType& heuristic,
124 param_type<State> state,
125 utils::CountdownTimer& timer);
126
127 template <typename ValueStoreT, typename SetLike, typename SetLike2>
128 Interval mysolve(
129 MDPType& mdp,
130 EvaluatorType& heuristic,
131 param_type<State> state,
132 ValueStoreT& value_store,
133 SetLike& dead_ends,
134 SetLike2& one_states,
135 QSystem& sys,
136 utils::CountdownTimer& timer);
137};
138
139} // namespace probfd::algorithms::interval_iteration
140
141#define GUARD_INCLUDE_PROBFD_ALGORITHMS_INTERVAL_ITERATION_H
142#include "probfd/algorithms/interval_iteration_impl.h"
143#undef GUARD_INCLUDE_PROBFD_ALGORITHMS_INTERVAL_ITERATION_H
144
145#endif // PROBFD_ALGORITHMS_INTERVAL_ITERATION_H
Interface for MDP algorithm implementations.
Definition mdp_algorithm.h:29
A registry for print functions related to search progress.
Definition progress_report.h:33
Implemention of interval iteration haddad:etal:misc-17.
Definition interval_iteration.h:62
void print_statistics(std::ostream &out) const override
Prints algorithm statistics to the specified output stream.
Definition interval_iteration_impl.h:55
A builder class that implements end component decomposition.
Definition end_component_decomposition.h:86
Namespace dedicated to interval iteration on MaxProb MDPs.
Definition interval_iteration.h:18
typename std::conditional_t< is_cheap_to_copy_v< T >, T, const T & > param_type
Alias template defining the best way to pass a parameter of a given type.
Definition type_traits.h:25
Represents a closed interval over the extended reals as a pair of lower and upper bound.
Definition interval.h:12
Topological value iteration statistics.
Definition topological_value_iteration.h:32
Contains printable statistics for the end component decomposition.
Definition end_component_decomposition.h:29