Skip to content

Commit

Permalink
Added bound option to symbolic search engines. Implemented write_plan…
Browse files Browse the repository at this point in the history
…s option in plan selector to control writing plans to disk.
  • Loading branch information
speckdavid committed Jun 20, 2024
1 parent ebfd2c6 commit b0b509a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/search/symbolic/plan_selection/plan_selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using namespace std;
namespace symbolic {
void PlanSelector::add_options_to_feature(plugins::Feature &feature) {
feature.add_option<bool>("dump_plans", "dump plans to console", "false");
feature.add_option<bool>("write_plans", "write plans to disk", "true");
feature.add_option<int>("num_plans", "number of plans", "infinity", plugins::Bounds("1", "infinity"));
}

Expand All @@ -17,6 +18,7 @@ PlanSelector::PlanSelector(const plugins::Options &opts)
state_registry(nullptr),
anytime_completness(false),
dump_plans(opts.get<bool>("dump_plans")),
write_plans(opts.get<bool>("write_plans")),
num_desired_plans(opts.get<int>("num_plans")),
num_accepted_plans(0),
num_rejected_plans(0),
Expand Down Expand Up @@ -131,6 +133,10 @@ void PlanSelector::save_accepted_plan(const Plan &plan) {
first_accepted_plan = plan;
first_accepted_plan_cost = calculate_plan_cost(
plan, state_registry->get_task_proxy());

if (!write_plans) {
plan_mgr.save_plan(plan, state_registry->get_task_proxy(), false, num_desired_plans > 1);
}
}

size_t plan_seed = get_hash_value(plan);
Expand All @@ -143,8 +149,14 @@ void PlanSelector::save_accepted_plan(const Plan &plan) {

if (dump_plans) {
utils::g_log << endl << "New plan " << num_accepted_plans << ":" << endl;
if (!write_plans) {
plan_mgr.dump_plan(plan, state_registry->get_task_proxy());
}
}

if (write_plans) {
plan_mgr.save_plan(plan, state_registry->get_task_proxy(), dump_plans, num_desired_plans > 1);
}
plan_mgr.save_plan(plan, state_registry->get_task_proxy(), dump_plans, num_desired_plans > 1);
}

void PlanSelector::save_rejected_plan(const Plan &plan) {
Expand Down
1 change: 1 addition & 0 deletions src/search/symbolic/plan_selection/plan_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class PlanSelector {
bool anytime_completness;

bool dump_plans;
bool write_plans;

int num_desired_plans;
int num_accepted_plans;
Expand Down
12 changes: 11 additions & 1 deletion src/search/symbolic/plan_selection/unordered_selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ void UnorderedSelector::save_accepted_plan(const Plan &ordered_plan, const Plan
first_accepted_plan = ordered_plan;
first_accepted_plan_cost = calculate_plan_cost(
ordered_plan, state_registry->get_task_proxy());

if (!write_plans) {
plan_mgr.save_plan(ordered_plan, state_registry->get_task_proxy(), false, num_desired_plans > 1);
}
}

size_t plan_seed = get_hash_value(unordered_plan);
Expand All @@ -35,8 +39,14 @@ void UnorderedSelector::save_accepted_plan(const Plan &ordered_plan, const Plan

if (dump_plans) {
utils::g_log << endl << "New plan " << num_accepted_plans << ":" << endl;
if (!write_plans) {
plan_mgr.dump_plan(ordered_plan, state_registry->get_task_proxy());
}
}

if (write_plans) {
plan_mgr.save_plan(ordered_plan, state_registry->get_task_proxy(), dump_plans, num_desired_plans > 1);
}
plan_mgr.save_plan(ordered_plan, state_registry->get_task_proxy(), dump_plans, num_desired_plans > 1);
}

class UnorderedSelectorFeature : public plugins::TypedFeature<PlanSelector, UnorderedSelector> {
Expand Down
4 changes: 2 additions & 2 deletions src/search/symbolic/search_engines/symbolic_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SymbolicSearch::SymbolicSearch(const plugins::Options &opts)
step_num(-1),
lower_bound_increased(true),
lower_bound(0),
upper_bound(numeric_limits<int>::max()),
upper_bound(bound),
min_g(0),
plan_data_base(opts.get<shared_ptr<PlanSelector>>("plan_selection")),
solution_registry(make_shared<SymSolutionRegistry>()),
Expand Down Expand Up @@ -64,8 +64,8 @@ void SymbolicSearch::initialize() {
task_properties::get_max_operator_cost(task_proxy);

utils::g_log << "Plan Reconstruction: Simple (without loops)" << endl;
utils::g_log << "Maximal plan cost: " << max_plan_cost << endl;
upper_bound = static_cast<int>(min((double)upper_bound, max_plan_cost + 1));
utils::g_log << "Maximal plan cost: " << upper_bound << endl;
cout << endl;
}

Expand Down

0 comments on commit b0b509a

Please sign in to comment.