From 01da84af6d43716a11d4103bd0ae388ad53f2c03 Mon Sep 17 00:00:00 2001 From: Florian Pommerening Date: Fri, 9 Feb 2024 12:37:10 +0100 Subject: [PATCH] update cegar generators --- .../subtask_generators.cc | 43 +++++++++++++++---- .../subtask_generators.h | 7 +-- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/search/cartesian_abstractions/subtask_generators.cc b/src/search/cartesian_abstractions/subtask_generators.cc index 00a311fb00..6da6d20314 100644 --- a/src/search/cartesian_abstractions/subtask_generators.cc +++ b/src/search/cartesian_abstractions/subtask_generators.cc @@ -94,8 +94,8 @@ static Facts filter_and_order_facts( } -TaskDuplicator::TaskDuplicator(const plugins::Options &opts) - : num_copies(opts.get("copies")) { +TaskDuplicator::TaskDuplicator(int num_copies) + : num_copies(num_copies) { } SharedTasks TaskDuplicator::get_subtasks( @@ -108,9 +108,9 @@ SharedTasks TaskDuplicator::get_subtasks( return subtasks; } -GoalDecomposition::GoalDecomposition(const plugins::Options &opts) - : fact_order(opts.get("order")), - rng(utils::parse_rng_from_options(opts)) { +GoalDecomposition::GoalDecomposition(FactOrder fact_order, int random_seed) + : fact_order(fact_order), + rng(utils::get_rng(random_seed)) { } SharedTasks GoalDecomposition::get_subtasks( @@ -128,10 +128,11 @@ SharedTasks GoalDecomposition::get_subtasks( } -LandmarkDecomposition::LandmarkDecomposition(const plugins::Options &opts) - : fact_order(opts.get("order")), - combine_facts(opts.get("combine_facts")), - rng(utils::parse_rng_from_options(opts)) { +LandmarkDecomposition::LandmarkDecomposition( + FactOrder fact_order, bool combine_facts, int random_seed) + : fact_order(fact_order), + combine_facts(combine_facts), + rng(utils::get_rng(random_seed)) { } shared_ptr LandmarkDecomposition::build_domain_abstracted_task( @@ -176,6 +177,11 @@ static void add_fact_order_option(plugins::Feature &feature) { utils::add_rng_options_to_feature(feature); } +static tuple get_fact_order_arguments_from_options(const plugins::Options &opts) { + return tuple_cat(make_tuple(opts.get("order")), + utils::get_rng_arguments_from_options(opts)); +} + class TaskDuplicatorFeature : public plugins::TypedFeature { public: TaskDuplicatorFeature() : TypedFeature("original") { @@ -185,6 +191,12 @@ class TaskDuplicatorFeature : public plugins::TypedFeature create_component( + const plugins::Options &opts, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + opts.get("copies")); + } }; static plugins::FeaturePlugin _plugin_original; @@ -194,6 +206,12 @@ class GoalDecompositionFeature : public plugins::TypedFeature create_component( + const plugins::Options &opts, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + get_fact_order_arguments_from_options(opts)); + } }; static plugins::FeaturePlugin _plugin_goals; @@ -208,6 +226,13 @@ class LandmarkDecompositionFeature : public plugins::TypedFeature create_component( + const plugins::Options &opts, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + get_fact_order_arguments_from_options(opts), + opts.get("combine_facts")); + } }; static plugins::FeaturePlugin _plugin_landmarks; diff --git a/src/search/cartesian_abstractions/subtask_generators.h b/src/search/cartesian_abstractions/subtask_generators.h index de68ceb601..2e71651228 100644 --- a/src/search/cartesian_abstractions/subtask_generators.h +++ b/src/search/cartesian_abstractions/subtask_generators.h @@ -51,7 +51,7 @@ class TaskDuplicator : public SubtaskGenerator { int num_copies; public: - explicit TaskDuplicator(const plugins::Options &opts); + explicit TaskDuplicator(int num_copies); virtual SharedTasks get_subtasks( const std::shared_ptr &task, @@ -67,7 +67,7 @@ class GoalDecomposition : public SubtaskGenerator { std::shared_ptr rng; public: - explicit GoalDecomposition(const plugins::Options &opts); + explicit GoalDecomposition(FactOrder fact_order, int random_seed); virtual SharedTasks get_subtasks( const std::shared_ptr &task, @@ -92,7 +92,8 @@ class LandmarkDecomposition : public SubtaskGenerator { const FactPair &fact) const; public: - explicit LandmarkDecomposition(const plugins::Options &opts); + explicit LandmarkDecomposition(FactOrder fact_order, bool combine_facts, + int random_seed); virtual SharedTasks get_subtasks( const std::shared_ptr &task,