17 unsigned long long iterations = 0;
18 void print(std::ostream& out)
const;
21template <
typename Action,
bool Interval,
bool StorePolicy>
22struct PerStateInformation
23 :
public heuristic_search::
24 PerStateBaseInformation<Action, StorePolicy, Interval> {
26 using Base = heuristic_search::PerStateBaseInformation<Action, StorePolicy, Interval>;
29 static constexpr uint8_t MARK = 1 << Base::BITS;
30 static constexpr uint8_t SOLVED = 2 << Base::BITS;
31 static constexpr uint8_t MASK = 3 << Base::BITS;
32 static constexpr uint8_t BITS = Base::BITS + 2;
34 unsigned update_order = 0;
35 std::vector<StateID> parents;
38 bool is_marked()
const
40 return this->info & MARK;
44 bool is_solved()
const
46 return this->info & SOLVED || this->is_goal_or_terminal();
50 const std::vector<StateID>& get_parents()
const
56 std::vector<StateID>& get_parents()
64 this->info = (this->info & ~MASK) | MARK;
67 void unmark() { this->info = (this->info & ~MARK); }
69 void set_solved() { this->info = (this->info & ~MASK) | SOLVED; }
71 void add_parent(
StateID s) { parents.push_back(s); }
82template <
typename State,
typename Action,
typename StateInfo>
84 :
public heuristic_search::
85 HeuristicSearchAlgorithm<State, Action, StateInfo> {
86 using Base =
typename AOBase::HeuristicSearchAlgorithm;
89 using MDPType =
typename Base::MDPType;
90 using EvaluatorType =
typename Base::EvaluatorType;
91 using PolicyPickerType =
typename Base::PolicyPicker;
94 struct PrioritizedStateID {
95 unsigned update_order;
98 friend bool operator<(
99 const PrioritizedStateID& left,
100 const PrioritizedStateID& right)
102 return left.update_order > right.update_order;
106 std::priority_queue<PrioritizedStateID> queue_;
109 Statistics statistics_;
116 void print_additional_statistics(std::ostream& out)
const override;
118 void backpropagate_tip_value(
121 std::vector<Transition<Action>>& transitions,
122 StateInfo& state_info,
123 utils::CountdownTimer& timer);
125 void backpropagate_update_order(
128 unsigned update_order,
129 utils::CountdownTimer& timer);
132 void push_parents_to_queue(StateInfo& info);