Skip to content

Commit

Permalink
[IR] Adapt Cost of Initial Upper Bound to Cost used during Search
Browse files Browse the repository at this point in the history
During the Search we do not consider the cost for the final result. Currentlty this cost is condidered in the initial upper bound for cost-based pruning.
To resolve this issue, we only consider the sum of the costs of the left and the right subplan as the initial upper bound.
Adapt Test Cases to lower Initial Upper Bound for Pruning.
  • Loading branch information
Nora Buschauer committed Apr 19, 2024
1 parent df3ef76 commit b39cdf0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/IR/HeuristicSearchPlanEnumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,13 @@ bool heuristic_search_helper(const char *vertex_str, const char *expand_str, con
if (options::initialize_upper_bound) {
config.upper_bound = [&]() {
/*----- Run GOO to compute upper bound of plan cost. -----*/
/* Obtain the sum of the costs of the left and the right subplan of the resulting plan. The costs
* considered for the search do not include the cardinality of the result set. */
GOO Goo;
Goo(G, CF, PT);
auto &plan = PT.get_final();
const auto &plan = PT.get_final();
M_insist(not plan.left.empty() and not plan.right.empty());
return plan.cost;
return PT[plan.left].cost + PT[plan.right].cost;
}();
}
} else if (options::initialize_upper_bound) {
Expand Down
39 changes: 20 additions & 19 deletions unittest/IR/HeuristicSearchPlanEnumeratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3400,7 +3400,8 @@ TEST_CASE("AnytimeAStar_BottomUp_and_TopDown_initial_upper_bound", "[core][IR]")
/*----- Run GOO to compute upper bound of plan cost. -----*/
GOO Goo;
Goo(G, C_out, plan_table);
return plan_table.get_final().cost;
const auto &plan = plan_table.get_final();
return plan_table[plan.left].cost + plan_table[plan.right].cost;
}();


Expand Down Expand Up @@ -3460,19 +3461,19 @@ TEST_CASE("AnytimeAStar_BottomUp_and_TopDown_initial_upper_bound", "[core][IR]")
CHECK(State::NUM_STATES_GENERATED() == 6);
CHECK(State::NUM_STATES_EXPANDED() == 1);
CHECK(State::NUM_STATES_CONSTRUCTED() == 7);
CHECK(State::NUM_STATES_DISPOSED() == 1);
CHECK(State::NUM_STATES_DISPOSED() == 3);

const auto &SM = S.state_manager();

CHECK(SM.num_new() == 6);
CHECK(SM.num_new() == 4);
CHECK(SM.num_duplicates() == 0);
CHECK(SM.num_discarded() == 0);
CHECK(SM.num_cheaper() == 0);
CHECK(SM.num_decrease_key() == 0);
CHECK(SM.num_pruned_by_cost() == 1);
CHECK(SM.num_pruned_by_cost() == 3);

CHECK(SM.num_states_seen() == 6);
CHECK(SM.num_states_in_regular_queue() == 5);
CHECK(SM.num_states_seen() == 4);
CHECK(SM.num_states_in_regular_queue() == 3);
CHECK(SM.num_states_in_beam_queue() == 0);
CHECK(S.num_cached_heuristic_value() == 0);
CHECK(SM.num_regular_to_beam() == 0);
Expand Down Expand Up @@ -3528,19 +3529,19 @@ TEST_CASE("AnytimeAStar_BottomUp_and_TopDown_initial_upper_bound", "[core][IR]")
CHECK(State::NUM_STATES_GENERATED() == 6);
CHECK(State::NUM_STATES_EXPANDED() == 1);
CHECK(State::NUM_STATES_CONSTRUCTED() == 7);
CHECK(State::NUM_STATES_DISPOSED() == 1);
CHECK(State::NUM_STATES_DISPOSED() == 3);

const auto &SM = S.state_manager();

CHECK(SM.num_new() == 6);
CHECK(SM.num_new() == 4);
CHECK(SM.num_duplicates() == 0);
CHECK(SM.num_discarded() == 0);
CHECK(SM.num_cheaper() == 0);
CHECK(SM.num_decrease_key() == 0);
CHECK(SM.num_pruned_by_cost() == 1);
CHECK(SM.num_pruned_by_cost() == 3);

CHECK(SM.num_states_seen() == 6);
CHECK(SM.num_states_in_regular_queue() == 5);
CHECK(SM.num_states_seen() == 4);
CHECK(SM.num_states_in_regular_queue() == 3);
CHECK(SM.num_states_in_beam_queue() == 0);
CHECK(S.num_cached_heuristic_value() == 0);
CHECK(SM.num_regular_to_beam() == 0);
Expand Down Expand Up @@ -3658,21 +3659,21 @@ TEST_CASE("AnytimeAStar_BottomUp_and_TopDown_initial_upper_bound", "[core][IR]")
CHECK(State::NUM_STATES_GENERATED() == 11);
CHECK(State::NUM_STATES_EXPANDED() == 4);
CHECK(State::NUM_STATES_CONSTRUCTED() == 12);
CHECK(State::NUM_STATES_DISPOSED() == 3);
CHECK(State::NUM_STATES_DISPOSED() == 5);

const auto &SM = S.state_manager();

CHECK(SM.num_new() == 9);
CHECK(SM.num_duplicates() == 1);
CHECK(SM.num_discarded() == 1);
CHECK(SM.num_new() == 7);
CHECK(SM.num_duplicates() == 0);
CHECK(SM.num_discarded() == 0);
CHECK(SM.num_cheaper() == 0);
CHECK(SM.num_decrease_key() == 0);
CHECK(SM.num_pruned_by_cost() == 2);
CHECK(SM.num_pruned_by_cost() == 5);

CHECK(SM.num_states_seen() == 9);
CHECK(SM.num_states_in_regular_queue() == 4);
CHECK(SM.num_states_seen() == 7);
CHECK(SM.num_states_in_regular_queue() == 2);
CHECK(SM.num_states_in_beam_queue() == 0);
CHECK(S.num_cached_heuristic_value() == 1);
CHECK(S.num_cached_heuristic_value() == 0);
CHECK(SM.num_regular_to_beam() == 0);
CHECK(SM.num_none_to_beam() == 0);
}
Expand Down

0 comments on commit b39cdf0

Please sign in to comment.