1#ifndef GUARD_INCLUDE_PROBFD_ALGORITHMS_EXHAUSTIVE_AO_H
2#error "This file should only be included from exhaustive_ao.h"
5#include "probfd/algorithms/open_list.h"
7#include "downward/utils/countdown_timer.h"
11template <
typename State,
typename Action,
bool UseInterval>
12ExhaustiveAOSearch<State, Action, UseInterval>::ExhaustiveAOSearch(
13 std::shared_ptr<PolicyPickerType> policy_chooser,
14 std::shared_ptr<OpenListType> open_list)
15 : Base(policy_chooser)
16 , open_list_(open_list)
20template <
typename State,
typename Action,
bool UseInterval>
21Interval ExhaustiveAOSearch<State, Action, UseInterval>::do_solve(
23 EvaluatorType& heuristic,
24 param_type<State> initial_state,
25 ProgressReport& progress,
28 utils::CountdownTimer timer(max_time);
30 StateID initstateid = mdp.get_state_id(initial_state);
31 const auto& state_info = this->state_infos_[initstateid];
33 open_list_->push(initstateid);
35 progress.register_bound(
"v", [&state_info]() {
39 progress.register_print([&](std::ostream& out) {
40 out <<
"i=" << this->statistics_.iterations;
44 timer.throw_if_expired();
47 assert(!this->open_list_->empty());
48 StateID stateid = open_list_->pop();
49 auto& info = this->state_infos_[stateid];
51 if (!info.is_on_fringe() || info.is_solved()) {
55 ++this->statistics_.iterations;
57 const State state = mdp.get_state(stateid);
58 const value_t termination_cost =
59 mdp.get_termination_info(state).get_cost();
61 ClearGuard _(transitions_);
62 this->expand_and_initialize(mdp, heuristic, state, info, transitions_);
65 this->compute_bellman(mdp, stateid, transitions_, termination_cost);
66 bool value_changed = this->update_value(info, value);
69 if (info.is_solved()) {
70 assert(transitions_.empty());
71 this->backpropagate_tip_value(mdp, transitions_, info, timer);
75 unsigned min_order = std::numeric_limits<unsigned>::max();
77 for (
const auto& [op, dist] : transitions_) {
78 for (
auto& [succid, prob] : dist) {
79 auto& succ_info = this->state_infos_[succid];
80 if (succ_info.is_solved())
continue;
82 open_list_->push(stateid, op, prob, succid);
84 if (succ_info.is_marked())
continue;
87 succ_info.add_parent(stateid);
88 min_order = std::min(min_order, succ_info.update_order);
93 if (info.unsolved == 0) {
96 this->backpropagate_tip_value(mdp, transitions_, info, timer);
100 for (
const auto& transition : transitions_) {
101 for (StateID succ_id : transition.successor_dist.support()) {
102 this->state_infos_[succ_id].unmark();
106 assert(min_order < std::numeric_limits<unsigned>::max());
107 this->backpropagate_update_order(stateid, info, min_order + 1, timer);
110 transitions_.clear();
111 this->backpropagate_tip_value(mdp, transitions_, info, timer);
113 }
while (!state_info.is_solved());
115 return state_info.get_bounds();
118template <
typename State,
typename Action,
bool UseInterval>
119bool ExhaustiveAOSearch<State, Action, UseInterval>::update_value_check_solved(
121 param_type<State> state,
122 std::vector<Transition<Action>> transitions,
125 assert(!info.is_solved());
127 const value_t termination_cost = mdp.get_termination_info(state).get_cost();
129 const auto value = this->compute_bellman(
131 mdp.get_state_id(state),
134 bool value_changed = this->update_value(info, value);
136 if (info.unsolved == 0) {
140 return value_changed;
I do not know this algorithm.
Definition exhaustive_ao.h:13
Interval as_interval(value_t lower_bound)
Returns the interval with the given lower bound and infinte upper bound.
double value_t
Typedef for the state value type.
Definition aliases.h:7