Skip to content

Commit 6d9be83

Browse files
[Util] Refactor CBP checks in HeuristicSearch.
Simplify conditions and merge duplicate cases.
1 parent 8c5967b commit 6d9be83

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

include/mutable/util/HeuristicSearch.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,14 @@ struct StateManager
326326
* pruning. Note, that the weighting factor was initially applied when computing `h` of a state for adding
327327
* it to the priority queue. */
328328
const auto min_path_cost = [&]() {
329-
if constexpr (use_weighted_search)
330-
return is_admissible<Heurisitc> ? state.g() + h / weighting_factor() : state.g();
331-
else
332-
return is_admissible<Heurisitc> ? state.g() + h : state.g();
329+
if constexpr (is_admissible<Heurisitc>) {
330+
if constexpr (use_weighted_search)
331+
return state.g() + h / weighting_factor();
332+
else
333+
return state.g() + h;
334+
} else {
335+
return state.g();
336+
}
333337
}();
334338
if (min_path_cost >= least_path_cost) [[unlikely]] {
335339
inc_pruned_by_cost();
@@ -417,10 +421,14 @@ struct StateManager
417421
* factor before pruning. Note, that the weighting factor was initially applied when computing `h`
418422
* of a state for adding it to the priority queue. */
419423
const auto min_path_cost = [&]() {
420-
if constexpr (use_weighted_search)
421-
return is_admissible<Heurisitc> ? state.g() + h / weighting_factor() : state.g();
422-
else
423-
return is_admissible<Heurisitc> ? state.g() + h : state.g();
424+
if constexpr (is_admissible<Heurisitc>) {
425+
if constexpr (use_weighted_search)
426+
return state.g() + h / weighting_factor();
427+
else
428+
return state.g() + h;
429+
} else {
430+
return state.g();
431+
}
424432
}();
425433
if (min_path_cost >= least_path_cost) [[unlikely]] {
426434
inc_pruned_by_cost();

0 commit comments

Comments
 (0)