Skip to content

Commit da99dd9

Browse files
author
Nora Buschauer
committed
[Util] Adapt budget depletion for heuristic search
1 parent b5cbba7 commit da99dd9

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

include/mutable/util/HeuristicSearch.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -916,16 +916,16 @@ const State & genericAStar<State, Expand, Heuristic, StaticConfig, Context...>::
916916
}
917917

918918
/* Lambda function to assure that the budgeted number of expansions is met when using Anytime A*. */
919-
auto have_budget = [&config]() mutable -> bool {
919+
auto have_budget = [budget=config.expansion_budget]() mutable -> bool {
920920
if constexpr (use_anytime_search) {
921-
if (config.expansion_budget) {
922-
--config.expansion_budget;
921+
if (budget) {
922+
--budget;
923923
return true;
924924
} else {
925-
return false;
925+
/* Expansion budget exhausted. The search did not terminate with a goal state. */
926+
throw budget_exhausted_exception("no goal state found with given expansion budget");
926927
}
927928
} else {
928-
(void) config; // silence unused warning
929929
return true;
930930
}
931931
};
@@ -946,10 +946,6 @@ const State & genericAStar<State, Expand, Heuristic, StaticConfig, Context...>::
946946
explore_state(state, heuristic, expand, context...);
947947
}
948948

949-
if constexpr (use_anytime_search) {
950-
if (config.expansion_budget == 0) // expansion budget exhausted?
951-
throw budget_exhausted_exception("no goal state found with given expansion budget");
952-
}
953949
throw std::logic_error("goal state unreachable from provided initial state");
954950
}
955951

0 commit comments

Comments
 (0)