From 435768eeaa1b5919763cf9bc57a73f57028d071f Mon Sep 17 00:00:00 2001 From: ClemensBuechner Date: Tue, 19 Dec 2023 17:51:09 +0100 Subject: [PATCH] Add option to decide which set of goals to use. --- src/search/pdbs/cegar.cc | 21 +++++++++++++++---- src/search/pdbs/cegar.h | 4 +++- ...ern_collection_generator_disjoint_cegar.cc | 4 +++- ...tern_collection_generator_disjoint_cegar.h | 1 + ...ern_collection_generator_multiple_cegar.cc | 6 ++++-- ...tern_collection_generator_multiple_cegar.h | 1 + src/search/pdbs/pattern_generator_cegar.cc | 4 +++- src/search/pdbs/pattern_generator_cegar.h | 1 + 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/search/pdbs/cegar.cc b/src/search/pdbs/cegar.cc index a6b5a802b2..33393be1ef 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,12 +786,18 @@ 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" ); } } diff --git a/src/search/pdbs/cegar.h b/src/search/pdbs/cegar.h index 9557463263..376c84e231 100644 --- a/src/search/pdbs/cegar.h +++ b/src/search/pdbs/cegar.h @@ -40,6 +40,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, @@ -55,6 +56,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, @@ -62,7 +64,7 @@ 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); +extern void add_cegar_options_to_feature(plugins::Feature &feature); } #endif diff --git a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc index 58a44f5425..b983cdae58 100644 --- a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc +++ b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.cc @@ -17,6 +17,7 @@ PatternCollectionGeneratorDisjointCegar::PatternCollectionGeneratorDisjointCegar max_collection_size(opts.get("max_collection_size")), max_time(opts.get("max_time")), use_wildcard_plans(opts.get("use_wildcard_plans")), + use_restricted_goal(opts.get("use_restricted_goal")), rng(utils::parse_rng_from_options(opts)) { } @@ -35,6 +36,7 @@ PatternCollectionInformation PatternCollectionGeneratorDisjointCegar::compute_pa max_collection_size, max_time, use_wildcard_plans, + use_restricted_goal, log, rng, task, @@ -74,7 +76,7 @@ class PatternCollectionGeneratorDisjointCegarFeature : public plugins::TypedFeat "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); add_generator_options_to_feature(*this); utils::add_rng_options(*this); diff --git a/src/search/pdbs/pattern_collection_generator_disjoint_cegar.h b/src/search/pdbs/pattern_collection_generator_disjoint_cegar.h index 5622588ee2..544f40a4e7 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; diff --git a/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc b/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc index 9ed1be1956..a0c3bf2b90 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc +++ b/src/search/pdbs/pattern_collection_generator_multiple_cegar.cc @@ -13,7 +13,8 @@ namespace pdbs { PatternCollectionGeneratorMultipleCegar::PatternCollectionGeneratorMultipleCegar( const plugins::Options &opts) : PatternCollectionGeneratorMultiple(opts), - use_wildcard_plans(opts.get("use_wildcard_plans")) { + use_wildcard_plans(opts.get("use_wildcard_plans")), + use_restricted_goal(opts.get("use_restricted_goal")) { } string PatternCollectionGeneratorMultipleCegar::id() const { @@ -32,6 +33,7 @@ PatternInformation PatternCollectionGeneratorMultipleCegar::compute_pattern( max_pdb_size, max_time, use_wildcard_plans, + use_restricted_goal, silent_log, rng, task, @@ -52,7 +54,7 @@ class PatternCollectionGeneratorMultipleCegarFeature : public plugins::TypedFeat "the algorithms."); add_multiple_options_to_feature(*this); - add_cegar_wildcard_option_to_feature(*this); + add_cegar_options_to_feature(*this); add_cegar_implementation_notes_to_feature(*this); add_multiple_algorithm_implementation_notes_to_feature(*this); diff --git a/src/search/pdbs/pattern_collection_generator_multiple_cegar.h b/src/search/pdbs/pattern_collection_generator_multiple_cegar.h index b6d9aaa37b..df64655d89 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 {} diff --git a/src/search/pdbs/pattern_generator_cegar.cc b/src/search/pdbs/pattern_generator_cegar.cc index 9bea9e0a6f..ea460be0a9 100644 --- a/src/search/pdbs/pattern_generator_cegar.cc +++ b/src/search/pdbs/pattern_generator_cegar.cc @@ -21,6 +21,7 @@ PatternGeneratorCEGAR::PatternGeneratorCEGAR(const plugins::Options &opts) max_pdb_size(opts.get("max_pdb_size")), max_time(opts.get("max_time")), use_wildcard_plans(opts.get("use_wildcard_plans")), + use_restricted_goal(opts.get("use_restricted_goal")), rng(utils::parse_rng_from_options(opts)) { } @@ -36,6 +37,7 @@ PatternInformation PatternGeneratorCEGAR::compute_pattern( max_pdb_size, max_time, use_wildcard_plans, + use_restricted_goal, log, rng, task, @@ -64,7 +66,7 @@ class PatternGeneratorCEGARFeature : public plugins::TypedFeature rng; virtual std::string name() const override;