|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Shared helper utilities used internally by all search engines. More...
Functions | |
| template<typename Domain > | |
| bool | is_terminal_state (const Domain &domain, const typename Domain::State &state) |
Dispatch helper for the optional is_terminal hook. | |
| template<typename Domain > | |
| bool | should_prune_state (Domain &domain, const typename Domain::State &state, const size_t depth) |
Dispatch helper for the optional should_prune hook. | |
| template<typename Result > | |
| void | register_visit (const size_t depth, Result &result) |
| Update visit counters and max-depth statistic. | |
| template<typename Result > | |
| bool | expansion_limit_reached (Result &result, const SearchLimits &limits) |
| Check whether the expansion limit has been reached. | |
| template<typename Result > | |
| bool | stop_after_solution (Result &result, const ExplorationPolicy &policy, const SearchLimits &limits) |
| Decide whether to stop the search after a solution was accepted. | |
Shared helper utilities used internally by all search engines.
These functions encapsulate the optional-hook dispatch and common bookkeeping that was previously duplicated across state_search_detail, branch_and_bound_detail, and adversarial_search_detail. Engines should call these helpers instead of re-implementing the same logic locally.
| bool Aleph::search_engine_detail::expansion_limit_reached | ( | Result & | result, |
| const SearchLimits & | limits | ||
| ) |
Check whether the expansion limit has been reached.
Marks the result as SearchStatus::LimitReached and increments the limit-hit counter when the number of expanded states meets or exceeds the configured maximum. Engines that need additional side-effects (e.g., setting an internal stop_ flag) should perform them after this call returns true.
| Result | Search-result type that owns a SearchStats member. |
| result | Result object to inspect and update. |
| limits | Hard bounds for the current run. |
true if the limit has been reached; false otherwise. Definition at line 810 of file state_search_common.H.
References Aleph::LimitReached, and Aleph::SearchLimits::max_expansions.
Referenced by Aleph::Alpha_Beta< Domain >::expansion_limit_reached(), Aleph::Negamax< Domain >::expansion_limit_reached(), Aleph::Depth_First_Backtracking< Domain >::expansion_limit_reached(), and Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::expansion_limit_reached().
| bool Aleph::search_engine_detail::is_terminal_state | ( | const Domain & | domain, |
| const typename Domain::State & | state | ||
| ) |
Dispatch helper for the optional is_terminal hook.
Returns true if Domain satisfies Aleph::TerminalPredicate and the domain reports the state as a non-goal dead end. Returns false unconditionally when the domain does not expose is_terminal.
| Domain | Problem-domain type. |
| domain | Domain adapter (const reference). |
| state | Current search state. |
Definition at line 750 of file state_search_common.H.
Referenced by Aleph::ida_star_detail::dfs(), Aleph::Depth_First_Backtracking< Domain >::dfs(), Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::dfs(), Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::dfs_visited(), Aleph::Depth_First_Backtracking< Domain >::dfs_visited(), and Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::process_best_first_candidate().
| void Aleph::search_engine_detail::register_visit | ( | const size_t | depth, |
| Result & | result | ||
| ) |
Update visit counters and max-depth statistic.
Must be called once per node entry by any search engine.
| Result | Search-result type that owns a SearchStats member. |
| depth | Current search depth. |
| result | Result object whose statistics are updated in-place. |
Definition at line 790 of file state_search_common.H.
Referenced by Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::register_visit(), Aleph::Negamax< Domain >::search_node(), and Aleph::Alpha_Beta< Domain >::search_node().
| bool Aleph::search_engine_detail::should_prune_state | ( | Domain & | domain, |
| const typename Domain::State & | state, | ||
| const size_t | depth | ||
| ) |
Dispatch helper for the optional should_prune hook.
Returns true if Domain satisfies Aleph::DomainPruner and the domain requests an early cutoff of the current state. Returns false when the domain does not expose should_prune.
| Domain | Problem-domain type. |
| domain | Domain adapter. |
| state | Current search state. |
| depth | Current search depth. |
Definition at line 771 of file state_search_common.H.
Referenced by Aleph::ida_star_detail::dfs(), Aleph::Depth_First_Backtracking< Domain >::dfs(), Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::dfs(), Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::dfs_visited(), Aleph::Depth_First_Backtracking< Domain >::dfs_visited(), Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::process_best_first_candidate(), Aleph::Negamax< Domain >::search_node(), and Aleph::Alpha_Beta< Domain >::search_node().
| bool Aleph::search_engine_detail::stop_after_solution | ( | Result & | result, |
| const ExplorationPolicy & | policy, | ||
| const SearchLimits & | limits | ||
| ) |
Decide whether to stop the search after a solution was accepted.
Returns true (and updates result.status) in two cases, checked in priority order:
limit_hits, sets SearchStatus::LimitReached);The hard limit is evaluated first so that limit_hits and SearchStatus::LimitReached are always reported when max_solutions is finite and reached, regardless of the stop_at_first_solution flag.
| Result | Search-result type that owns a SearchStats member. |
| result | Result object to update. |
| policy | Exploration policy for the current run. |
| limits | Hard bounds for the current run. |
true if the engine should stop; false to keep searching. Definition at line 843 of file state_search_common.H.
References Aleph::and, Aleph::LimitReached, Aleph::SearchLimits::max_solutions, Aleph::Search_Unlimited, Aleph::ExplorationPolicy::stop_at_first_solution, and Aleph::StoppedOnSolution.
Referenced by Aleph::Depth_First_Backtracking< Domain >::stop_after_solution(), and Aleph::Branch_And_Bound< Domain, ObjectivePolicy >::stop_after_solution().