From 02939e64df286d300441dda151073aa900dcedd2 Mon Sep 17 00:00:00 2001 From: ClemensBuechner Date: Mon, 30 Oct 2023 09:59:20 +0100 Subject: [PATCH 1/3] Consider all goals for goal flaws. --- src/search/pdbs/cegar.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/search/pdbs/cegar.cc b/src/search/pdbs/cegar.cc index 2969fdf7a2..be79216194 100644 --- a/src/search/pdbs/cegar.cc +++ b/src/search/pdbs/cegar.cc @@ -385,7 +385,8 @@ bool CEGAR::get_flaws_for_pattern( log << "plan did not lead to a goal state: "; } bool raise_goal_flaw = false; - for (const FactPair &goal : goals) { + for (const FactProxy &goal_proxy : task_proxy.get_goals()) { + const FactPair &goal = goal_proxy.get_pair(); int goal_var_id = goal.var; if (final_state[goal_var_id].get_value() != goal.value && !blacklisted_variables.count(goal_var_id)) { From dd684220f3ab8196c77812cb2a6713b56527aaaa Mon Sep 17 00:00:00 2001 From: ClemensBuechner Date: Tue, 19 Dec 2023 17:51:09 +0100 Subject: [PATCH 2/3] Add option to decide which set of goals to use. --- src/search/pdbs/cegar.cc | 27 ++++++++++++++----- src/search/pdbs/cegar.h | 6 +++-- ...ern_collection_generator_disjoint_cegar.cc | 8 +++--- ...tern_collection_generator_disjoint_cegar.h | 5 ++-- ...ern_collection_generator_multiple_cegar.cc | 18 +++++++------ ...tern_collection_generator_multiple_cegar.h | 3 ++- src/search/pdbs/pattern_generator_cegar.cc | 8 +++--- src/search/pdbs/pattern_generator_cegar.h | 3 ++- 8 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/search/pdbs/cegar.cc b/src/search/pdbs/cegar.cc index be79216194..feadaf35a1 100644 --- a/src/search/pdbs/cegar.cc +++ b/src/search/pdbs/cegar.cc @@ -84,6 +84,7 @@ class CEGAR { const int max_collection_size; const double max_time; const bool use_wildcard_plans; + const bool use_restricted_goal; utils::LogProxy &log; shared_ptr rng; const shared_ptr &task; @@ -151,6 +152,7 @@ class CEGAR { int max_collection_size, double max_time, bool use_wildcard_plans, + bool use_restricted_goal, utils::LogProxy &log, const shared_ptr &rng, const shared_ptr &task, @@ -164,6 +166,7 @@ CEGAR::CEGAR( int max_collection_size, double max_time, bool use_wildcard_plans, + bool use_restricted_goal, utils::LogProxy &log, const shared_ptr &rng, const shared_ptr &task, @@ -173,6 +176,7 @@ CEGAR::CEGAR( max_collection_size(max_collection_size), max_time(max_time), use_wildcard_plans(use_wildcard_plans), + use_restricted_goal(use_restricted_goal), log(log), rng(rng), task(task), @@ -385,8 +389,7 @@ bool CEGAR::get_flaws_for_pattern( log << "plan did not lead to a goal state: "; } bool raise_goal_flaw = false; - for (const FactProxy &goal_proxy : task_proxy.get_goals()) { - const FactPair &goal = goal_proxy.get_pair(); + for (const FactPair &goal : use_restricted_goal ? goals : task_properties::get_fact_pairs(task_proxy.get_goals())) { int goal_var_id = goal.var; if (final_state[goal_var_id].get_value() != goal.value && !blacklisted_variables.count(goal_var_id)) { @@ -565,7 +568,7 @@ PatternCollectionInformation CEGAR::compute_pattern_collection() { log << "max time: " << max_time << endl; log << "wildcard plans: " << use_wildcard_plans << endl; log << "goal variables: "; - for (const FactPair &goal : this->goals) { + for (const FactPair &goal : use_restricted_goal ? this->goals : task_properties::get_fact_pairs(task_proxy.get_goals())) { log << goal.var << ", "; } log << endl; @@ -662,6 +665,7 @@ PatternCollectionInformation generate_pattern_collection_with_cegar( int max_collection_size, double max_time, bool use_wildcard_plans, + bool use_restricted_goal, utils::LogProxy &log, const shared_ptr &rng, const shared_ptr &task, @@ -672,6 +676,7 @@ PatternCollectionInformation generate_pattern_collection_with_cegar( max_collection_size, max_time, use_wildcard_plans, + use_restricted_goal, log, rng, task, @@ -684,6 +689,7 @@ PatternInformation generate_pattern_with_cegar( int max_pdb_size, double max_time, bool use_wildcard_plans, + bool use_restricted_goal, utils::LogProxy &log, const shared_ptr &rng, const shared_ptr &task, @@ -695,6 +701,7 @@ PatternInformation generate_pattern_with_cegar( max_pdb_size, max_time, use_wildcard_plans, + use_restricted_goal, log, rng, task, @@ -779,16 +786,24 @@ void add_cegar_implementation_notes_to_feature(plugins::Feature &feature) { true); } -void add_cegar_wildcard_option_to_feature(plugins::Feature &feature) { +void add_cegar_options_to_feature(plugins::Feature &feature) { feature.add_option( "use_wildcard_plans", "if true, compute wildcard plans which are sequences of sets of " "operators that induce the same transition; otherwise compute regular " "plans which are sequences of single operators", "true"); + + feature.add_option( + "use_restricted_goal", + "if true, CEGAR considers only those variables for goal flaws that are " + "used to initialize the pattern collection; otherwise all goal " + "variables can occur in goal flaws"); } -tuple get_cegar_wildcard_arguments_from_options( + +tuple get_cegar_arguments_from_options( const plugins::Options &opts) { - return make_tuple(opts.get("use_wildcard_plans")); + return make_tuple(opts.get("use_wildcard_plans"), + opts.get("use_restricted_goal")); } } diff --git a/src/search/pdbs/cegar.h b/src/search/pdbs/cegar.h index 88178481ac..b98bac396b 100644 --- a/src/search/pdbs/cegar.h +++ b/src/search/pdbs/cegar.h @@ -41,6 +41,7 @@ extern PatternCollectionInformation generate_pattern_collection_with_cegar( int max_collection_size, double max_time, bool use_wildcard_plans, + bool use_restricted_goal, utils::LogProxy &log, const std::shared_ptr &rng, const std::shared_ptr &task, @@ -56,6 +57,7 @@ extern PatternInformation generate_pattern_with_cegar( int max_pdb_size, double max_time, bool use_wildcard_plans, + bool use_restricted_goal, utils::LogProxy &log, const std::shared_ptr &rng, const std::shared_ptr &task, @@ -63,8 +65,8 @@ extern PatternInformation generate_pattern_with_cegar( std::unordered_set &&blacklisted_variables = std::unordered_set()); extern void add_cegar_implementation_notes_to_feature(plugins::Feature &feature); -extern void add_cegar_wildcard_option_to_feature(plugins::Feature &feature); -std::tuple get_cegar_wildcard_arguments_from_options( +extern void add_cegar_options_to_feature(plugins::Feature &feature); +std::tuple get_cegar_arguments_from_options( const plugins::Options &opts); } diff --git a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc index a767122610..c84faafcb6 100644 --- a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc +++ b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc @@ -12,13 +12,14 @@ using namespace std; namespace pdbs { PatternCollectionGeneratorDisjointCegar::PatternCollectionGeneratorDisjointCegar( int max_pdb_size, int max_collection_size, double max_time, - bool use_wildcard_plans, int random_seed, + bool use_wildcard_plans, bool use_restricted_goal, int random_seed, utils::Verbosity verbosity) : PatternCollectionGenerator(verbosity), max_pdb_size(max_pdb_size), max_collection_size(max_collection_size), max_time(max_time), use_wildcard_plans(use_wildcard_plans), + use_restricted_goal(use_restricted_goal), rng(utils::get_rng(random_seed)) { } @@ -37,6 +38,7 @@ PatternCollectionInformation PatternCollectionGeneratorDisjointCegar::compute_pa max_collection_size, max_time, use_wildcard_plans, + use_restricted_goal, log, rng, task, @@ -77,7 +79,7 @@ class PatternCollectionGeneratorDisjointCegarFeature "singleton pattern for each goal variable)", "infinity", plugins::Bounds("0.0", "infinity")); - add_cegar_wildcard_option_to_feature(*this); + add_cegar_options_to_feature(*this); utils::add_rng_options_to_feature(*this); add_generator_options_to_feature(*this); @@ -91,7 +93,7 @@ class PatternCollectionGeneratorDisjointCegarFeature opts.get("max_pdb_size"), opts.get("max_collection_size"), opts.get("max_time"), - get_cegar_wildcard_arguments_from_options(opts), + get_cegar_arguments_from_options(opts), utils::get_rng_arguments_from_options(opts), get_generator_arguments_from_options(opts) ); diff --git a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.h b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.h index 32ac888bad..cf4e0a99b7 100644 --- a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.h +++ b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.h @@ -17,6 +17,7 @@ class PatternCollectionGeneratorDisjointCegar : public PatternCollectionGenerato const int max_collection_size; const double max_time; const bool use_wildcard_plans; + const bool use_restricted_goal; std::shared_ptr rng; virtual std::string name() const override; @@ -25,8 +26,8 @@ class PatternCollectionGeneratorDisjointCegar : public PatternCollectionGenerato public: PatternCollectionGeneratorDisjointCegar( int max_pdb_size, int max_collection_size, double max_time, - bool use_wildcard_plans, int random_seed, - utils::Verbosity verbosity); + bool use_wildcard_plans, bool use_restricted_goal, + int random_seed, utils::Verbosity verbosity); }; } diff --git a/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc b/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc index 27be32d970..da8106844c 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc +++ b/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc @@ -11,17 +11,18 @@ using namespace std; namespace pdbs { PatternCollectionGeneratorMultipleCegar::PatternCollectionGeneratorMultipleCegar( - bool use_wildcard_plans, int max_pdb_size, int max_collection_size, - double pattern_generation_max_time, double total_max_time, - double stagnation_limit, double blacklist_trigger_percentage, - bool enable_blacklist_on_stagnation, int random_seed, - utils::Verbosity verbosity) + bool use_wildcard_plans, bool use_restricted_goal, int max_pdb_size, + int max_collection_size, double pattern_generation_max_time, + double total_max_time, double stagnation_limit, + double blacklist_trigger_percentage, bool enable_blacklist_on_stagnation, + int random_seed, utils::Verbosity verbosity) : PatternCollectionGeneratorMultiple( max_pdb_size, max_collection_size, pattern_generation_max_time, total_max_time, stagnation_limit, blacklist_trigger_percentage, enable_blacklist_on_stagnation, random_seed, verbosity), - use_wildcard_plans(use_wildcard_plans) { + use_wildcard_plans(use_wildcard_plans), + use_restricted_goal(use_restricted_goal) { } string PatternCollectionGeneratorMultipleCegar::id() const { @@ -40,6 +41,7 @@ PatternInformation PatternCollectionGeneratorMultipleCegar::compute_pattern( max_pdb_size, max_time, use_wildcard_plans, + use_restricted_goal, silent_log, rng, task, @@ -60,7 +62,7 @@ class PatternCollectionGeneratorMultipleCegarFeature "restricted to a single goal variable. See below for descriptions of " "the algorithms."); - add_cegar_wildcard_option_to_feature(*this); + add_cegar_options_to_feature(*this); add_multiple_options_to_feature(*this); add_cegar_implementation_notes_to_feature(*this); @@ -72,7 +74,7 @@ class PatternCollectionGeneratorMultipleCegarFeature const plugins::Options &opts, const utils::Context &) const override { return plugins::make_shared_from_arg_tuples( - get_cegar_wildcard_arguments_from_options(opts), + get_cegar_arguments_from_options(opts), get_multiple_arguments_from_options(opts) ); } diff --git a/src/search/pdbs/pattern_collection_generator_multiple_cegar.h b/src/search/pdbs/pattern_collection_generator_multiple_cegar.h index a2e9b6d40f..f7a0e1f98a 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple_cegar.h +++ b/src/search/pdbs/pattern_collection_generator_multiple_cegar.h @@ -6,6 +6,7 @@ namespace pdbs { class PatternCollectionGeneratorMultipleCegar : public PatternCollectionGeneratorMultiple { const bool use_wildcard_plans; + const bool use_restricted_goal; virtual std::string id() const override; virtual void initialize(const std::shared_ptr &) override {} @@ -18,7 +19,7 @@ class PatternCollectionGeneratorMultipleCegar : public PatternCollectionGenerato std::unordered_set &&blacklisted_variables) override; public: PatternCollectionGeneratorMultipleCegar( - bool use_wildcard_plans, int max_pdb_size, + bool use_wildcard_plans, bool use_restricted_goal, int max_pdb_size, int max_collection_size, double pattern_generation_max_time, double total_max_time, double stagnation_limit, double blacklist_trigger_percentage, diff --git a/src/search/pdbs/pattern_generator_cegar.cc b/src/search/pdbs/pattern_generator_cegar.cc index b589d400bc..0957c84330 100644 --- a/src/search/pdbs/pattern_generator_cegar.cc +++ b/src/search/pdbs/pattern_generator_cegar.cc @@ -18,11 +18,12 @@ using namespace std; namespace pdbs { PatternGeneratorCEGAR::PatternGeneratorCEGAR( int max_pdb_size, double max_time, bool use_wildcard_plans, - int random_seed, utils::Verbosity verbosity) + bool use_restricted_goal, int random_seed, utils::Verbosity verbosity) : PatternGenerator(verbosity), max_pdb_size(max_pdb_size), max_time(max_time), use_wildcard_plans(use_wildcard_plans), + use_restricted_goal(use_restricted_goal), rng(utils::get_rng(random_seed)) { } @@ -38,6 +39,7 @@ PatternInformation PatternGeneratorCEGAR::compute_pattern( max_pdb_size, max_time, use_wildcard_plans, + use_restricted_goal, log, rng, task, @@ -67,7 +69,7 @@ class PatternGeneratorCEGARFeature "maximum time in seconds for the pattern generation", "infinity", plugins::Bounds("0.0", "infinity")); - add_cegar_wildcard_option_to_feature(*this); + add_cegar_options_to_feature(*this); utils::add_rng_options_to_feature(*this); add_generator_options_to_feature(*this); @@ -80,7 +82,7 @@ class PatternGeneratorCEGARFeature return plugins::make_shared_from_arg_tuples( opts.get("max_pdb_size"), opts.get("max_time"), - get_cegar_wildcard_arguments_from_options(opts), + get_cegar_arguments_from_options(opts), utils::get_rng_arguments_from_options(opts), get_generator_arguments_from_options(opts) ); diff --git a/src/search/pdbs/pattern_generator_cegar.h b/src/search/pdbs/pattern_generator_cegar.h index 7a0066a144..03297f02ac 100644 --- a/src/search/pdbs/pattern_generator_cegar.h +++ b/src/search/pdbs/pattern_generator_cegar.h @@ -12,6 +12,7 @@ class PatternGeneratorCEGAR : public PatternGenerator { const int max_pdb_size; const double max_time; const bool use_wildcard_plans; + const bool use_restricted_goal; std::shared_ptr rng; virtual std::string name() const override; @@ -20,7 +21,7 @@ class PatternGeneratorCEGAR : public PatternGenerator { public: PatternGeneratorCEGAR( int max_pdb_size, double max_time, bool use_wildcard_plans, - int random_seed, utils::Verbosity verbosity); + bool use_restricted_goal, int random_seed, utils::Verbosity verbosity); }; } From f23d861d4dd515d45bc61559b7dce36fa3154a64 Mon Sep 17 00:00:00 2001 From: ClemensBuechner Date: Tue, 9 Jul 2024 12:02:05 +0200 Subject: [PATCH 3/3] Set default for option. --- src/search/pdbs/cegar.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/search/pdbs/cegar.cc b/src/search/pdbs/cegar.cc index feadaf35a1..5859f4573a 100644 --- a/src/search/pdbs/cegar.cc +++ b/src/search/pdbs/cegar.cc @@ -798,7 +798,8 @@ void add_cegar_options_to_feature(plugins::Feature &feature) { "use_restricted_goal", "if true, CEGAR considers only those variables for goal flaws that are " "used to initialize the pattern collection; otherwise all goal " - "variables can occur in goal flaws"); + "variables can occur in goal flaws", + "false"); } tuple get_cegar_arguments_from_options(