1#ifndef GUARD_INCLUDE_PROBFD_ALGORITHMS_AO_SEARCH_H
2#error "This file should only be included from ao_search.h"
7#include "downward/utils/countdown_timer.h"
11inline void Statistics::print(std::ostream& out)
const
13 out <<
" Iterations: " << iterations << std::endl;
16template <
typename State,
typename Action,
typename StateInfo>
17void AOBase<State, Action, StateInfo>::print_additional_statistics(
18 std::ostream& out)
const
20 statistics_.print(out);
23template <
typename State,
typename Action,
typename StateInfo>
24void AOBase<State, Action, StateInfo>::backpropagate_tip_value(
27 std::vector<Transition<Action>>& transitions,
28 StateInfo& state_info,
29 utils::CountdownTimer& timer)
31 self.push_parents_to_queue(state_info);
33 while (!self.queue_.empty()) {
34 timer.throw_if_expired();
36 auto elem = self.queue_.top();
39 auto& info = self.state_infos_[elem.state_id];
40 assert(!info.is_on_fringe());
41 assert(!info.is_goal_state());
42 assert(!info.is_goal_or_terminal() || info.is_solved());
44 if (info.is_solved()) {
49 assert(info.is_marked());
52 const State state = mdp.get_state(elem.state_id);
54 ClearGuard _(transitions);
55 self.generate_non_tip_transitions(mdp, state, transitions);
58 self.update_value_check_solved(mdp, state, transitions, info);
60 if (info.is_solved() || value_changed) {
61 self.push_parents_to_queue(info);
66template <
typename State,
typename Action,
typename StateInfo>
67void AOBase<State, Action, StateInfo>::backpropagate_update_order(
70 unsigned update_order,
71 utils::CountdownTimer& timer)
73 tip_info.update_order = update_order;
74 queue_.emplace(update_order, tip);
77 timer.throw_if_expired();
79 auto elem = queue_.top();
82 auto& info = this->state_infos_[elem.state_id];
83 if (info.update_order > elem.update_order) {
87 std::erase_if(info.get_parents(), [
this, elem](StateID state_id) {
88 auto& pinfo = this->state_infos_[state_id];
89 if (pinfo.is_solved()) {
93 if (pinfo.update_order <= elem.update_order) {
94 pinfo.update_order = elem.update_order + 1;
95 queue_.emplace(elem.update_order + 1, state_id);
100 }
while (!queue_.empty());
103template <
typename State,
typename Action,
typename StateInfo>
104void AOBase<State, Action, StateInfo>::push_parents_to_queue(StateInfo& info)
106 auto& parents = info.get_parents();
107 for (StateID parent : parents) {
108 auto& pinfo = this->state_infos_[parent];
110 if constexpr (!StateInfo::StorePolicy) {
111 if (info.is_solved()) {
112 assert(pinfo.unsolved > 0 || pinfo.is_solved());
117 if (pinfo.is_marked())
continue;
120 queue_.emplace(pinfo.update_order, parent);
123 if (info.is_solved()) {
124 utils::release_vector_memory(parents);
Namespace dedicated to the AO* family of MDP algorithms.
Definition ao_search.h:14