AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
abstract_state.h
1#ifndef PROBFD_CARTESIAN_ABSTRACT_STATE_H
2#define PROBFD_CARTESIAN_ABSTRACT_STATE_H
3
4#include "probfd/cartesian_abstractions/types.h"
5
6#include "downward/cartesian_abstractions/cartesian_set.h"
7
8#include <iosfwd>
9#include <memory>
10#include <utility>
11#include <vector>
12
13// Forward Declarations
14struct FactPair;
15class State;
16
17namespace probfd {
18class ProbabilisticOperatorProxy;
19class ProbabilisticEffectsProxy;
20} // namespace probfd
21
22namespace probfd::cartesian_abstractions {
23
24/*
25 Store the Cartesian set and the ID of the node in the refinement hierarchy
26 for an abstract state.
27*/
28class AbstractState {
29 int state_id_;
30
31 // This state's node in the refinement hierarchy.
32 NodeID node_id_;
33
34 CartesianSet cartesian_set_;
35
36public:
37 AbstractState(int state_id, NodeID node_id, CartesianSet&& cartesian_set);
38
39 AbstractState(const AbstractState&) = delete;
40 AbstractState& operator=(const AbstractState&) = delete;
41
42 [[nodiscard]]
43 bool domain_subsets_intersect(const AbstractState& other, int var) const;
44
45 // Return the size of var's abstract domain for this state.
46 [[nodiscard]]
47 int count(int var) const;
48
49 [[nodiscard]]
50 bool contains(int var, int value) const;
51
52 // Return the Cartesian set in which applying "effect" of the operator "op"
53 // can lead to this state.
54 [[nodiscard]]
55 CartesianSet regress(
56 const ProbabilisticOperatorProxy& op,
57 const ProbabilisticEffectsProxy& effects) const;
58
59 /*
60 Separate the "wanted" values from the other values in the abstract domain
61 and return the resulting two new Cartesian sets.
62 */
63 [[nodiscard]]
64 std::pair<CartesianSet, CartesianSet>
65 split_domain(int var, const std::vector<int>& wanted) const;
66
67 [[nodiscard]]
68 bool includes(const AbstractState& other) const;
69
70 [[nodiscard]]
71 bool includes(const State& concrete_state) const;
72
73 [[nodiscard]]
74 bool includes(const std::vector<FactPair>& facts) const;
75
76 // IDs are consecutive, so they can be used to index states in vectors.
77 [[nodiscard]]
78 int get_id() const;
79
80 [[nodiscard]]
81 NodeID get_node_id() const;
82
83 friend std::ostream&
84 operator<<(std::ostream& os, const AbstractState& state);
85
86 // Create the initial, unrefined abstract state.
87 static std::unique_ptr<AbstractState>
88 get_trivial_abstract_state(const std::vector<int>& domain_sizes);
89};
90
91} // namespace probfd::cartesian_abstractions
92
93#endif // PROBFD_CARTESIAN_ABSTRACT_STATE_H
The top-level namespace of probabilistic Fast Downward.
Definition command_line.h:8