AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
bisimilar_state_space.h
1#ifndef PROBFD_BISIMULATION_BISIMILAR_STATE_SPACE_H
2#define PROBFD_BISIMULATION_BISIMILAR_STATE_SPACE_H
3
4#include "probfd/bisimulation/types.h"
5
6#include "probfd/fdr_types.h"
7#include "probfd/mdp.h"
8
9#include "probfd/task_proxy.h"
10#include "probfd/types.h"
11#include "probfd/value_type.h"
12
13#include "downward/algorithms/segmented_vector.h"
14
15#include <iosfwd>
16#include <memory>
17#include <vector>
18
19// Forward Declarations
20namespace merge_and_shrink {
21class Distances;
22class FactoredTransitionSystem;
23class TransitionSystem;
24struct Factor;
25} // namespace merge_and_shrink
26
27namespace probfd {
28template <typename>
29class Distribution;
30class ProbabilisticTask;
31} // namespace probfd
32
34
35class BisimilarStateSpace : public MDP<QuotientState, QuotientAction> {
36 struct CachedTransition {
37 unsigned op;
38 int* successors;
39 };
40
41 std::shared_ptr<ProbabilisticTask> task_;
42 std::shared_ptr<FDRCostFunction> task_cost_function_;
43
44 unsigned num_cached_transitions_ = 0;
45 segmented_vector::SegmentedVector<std::vector<CachedTransition>>
46 transitions_;
47
48 // Storage for transitions
49 std::vector<std::unique_ptr<int[]>> store_;
50
51 std::vector<bool> goal_flags_;
52
53public:
54 BisimilarStateSpace(
55 std::shared_ptr<ProbabilisticTask> task,
56 std::shared_ptr<FDRCostFunction> task_cost_function,
57 const TaskProxy& det_task_proxy,
58 const merge_and_shrink::TransitionSystem& transition_system);
59
60 ~BisimilarStateSpace() override;
61
62 StateID get_state_id(QuotientState state) override;
63
64 QuotientState get_state(StateID state_id) override;
65
66 void generate_applicable_actions(
67 QuotientState state,
68 std::vector<QuotientAction>& result) override;
69
70 void generate_action_transitions(
71 QuotientState state,
72 QuotientAction action,
73 Distribution<StateID>& result) override;
74
75 void generate_all_transitions(
76 QuotientState state,
77 std::vector<QuotientAction>& aops,
78 std::vector<Distribution<StateID>>& result) override;
79
80 void generate_all_transitions(
81 QuotientState state,
82 std::vector<TransitionType>& transitions) override;
83
84 TerminationInfo get_termination_info(QuotientState state) override;
85
86 value_t get_action_cost(QuotientAction action) override;
87
89 bool is_goal_state(QuotientState s) const;
90
92 unsigned num_bisimilar_states() const;
93
95 unsigned num_transitions() const;
96};
97
98merge_and_shrink::Factor
99compute_bisimulation_on_determinization(const TaskProxy& det_task_proxy);
100
101} // namespace probfd::bisimulation
102
103#endif // PROBFD_BISIMULATION_BISIMILAR_STATE_SPACE_H
A convenience class that represents a finite probability distribution.
Definition task_state_space.h:27
Basic interface for MDPs.
Definition mdp_algorithm.h:14
Specifies the termination cost and goal status of a state.
Definition cost_function.h:13
This namespace contains the implementation of deterministic bisimulation quotients for SSPs,...
Definition bisimilar_state_space.h:33
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
The top-level namespace of probabilistic Fast Downward.
Definition command_line.h:8
double value_t
Typedef for the state value type.
Definition aliases.h:7
A StateID represents a state within a StateIDMap. Just like Fast Downward's StateID type,...
Definition types.h:22