AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
abstract_state.h
1#ifndef CEGAR_ABSTRACT_STATE_H
2#define CEGAR_ABSTRACT_STATE_H
3
4#include "downward/cartesian_abstractions/cartesian_set.h"
5#include "downward/cartesian_abstractions/types.h"
6
7#include <vector>
8
9struct FactPair;
10class OperatorProxy;
11class State;
12class TaskProxy;
13
14namespace cartesian_abstractions {
15class Node;
16
17/*
18 Store the Cartesian set and the ID of the node in the refinement hierarchy
19 for an abstract state.
20*/
21class AbstractState {
22 int state_id;
23
24 // This state's node in the refinement hierarchy.
25 NodeID node_id;
26
27 CartesianSet cartesian_set;
28
29public:
30 AbstractState(int state_id, NodeID node_id, CartesianSet&& cartesian_set);
31
32 AbstractState(const AbstractState&) = delete;
33
34 bool domain_subsets_intersect(const AbstractState& other, int var) const;
35
36 // Return the size of var's abstract domain for this state.
37 int count(int var) const;
38
39 bool contains(int var, int value) const;
40
41 // Return the Cartesian set in which applying "op" can lead to this state.
42 CartesianSet regress(const OperatorProxy& op) const;
43
44 /*
45 Separate the "wanted" values from the other values in the abstract domain
46 and return the resulting two new Cartesian sets.
47 */
48 std::pair<CartesianSet, CartesianSet>
49 split_domain(int var, const std::vector<int>& wanted) const;
50
51 bool includes(const AbstractState& other) const;
52 bool includes(const State& concrete_state) const;
53 bool includes(const std::vector<FactPair>& facts) const;
54
55 // IDs are consecutive, so they can be used to index states in vectors.
56 int get_id() const;
57
58 NodeID get_node_id() const;
59
60 friend std::ostream&
61 operator<<(std::ostream& os, const AbstractState& state)
62 {
63 return os << "#" << state.get_id() << state.cartesian_set;
64 }
65
66 // Create the initial, unrefined abstract state.
67 static std::unique_ptr<AbstractState>
68 get_trivial_abstract_state(const std::vector<int>& domain_sizes);
69};
70} // namespace cartesian_abstractions
71
72#endif