From 031ba0723590ed79f8441f2918199c74ec8ae757 Mon Sep 17 00:00:00 2001 From: Silvan Sievers Date: Tue, 12 Mar 2019 14:46:13 +0100 Subject: [PATCH 1/3] [issue906] PatternInformation and PatternCollectionInformation do not store TaskProxy --- src/search/operator_counting/pho_constraints.cc | 2 +- src/search/pdbs/canonical_pdbs_heuristic.cc | 5 +++-- src/search/pdbs/pattern_collection_information.cc | 13 ++++++++----- src/search/pdbs/pattern_collection_information.h | 15 ++++----------- src/search/pdbs/pattern_information.cc | 14 +++++--------- src/search/pdbs/pattern_information.h | 9 ++------- src/search/pdbs/pdb_heuristic.cc | 2 +- src/search/pdbs/utils.cc | 6 ++++-- src/search/pdbs/utils.h | 2 ++ 9 files changed, 30 insertions(+), 38 deletions(-) diff --git a/src/search/operator_counting/pho_constraints.cc b/src/search/operator_counting/pho_constraints.cc index 3603376f61..527eda098b 100644 --- a/src/search/operator_counting/pho_constraints.cc +++ b/src/search/operator_counting/pho_constraints.cc @@ -30,9 +30,9 @@ void PhOConstraints::initialize_constraints( create pattern_generator locally and no longer need to explicitly reset it. */ - pdbs = pattern_collection_info.get_pdbs(); pattern_generator = nullptr; TaskProxy task_proxy(*task); + pdbs = pattern_collection_info.get_pdbs(task_proxy); named_vector::NamedVector &constraints = lp.get_constraints(); constraint_offset = constraints.size(); for (const shared_ptr &pdb : *pdbs) { diff --git a/src/search/pdbs/canonical_pdbs_heuristic.cc b/src/search/pdbs/canonical_pdbs_heuristic.cc index b7b839a51e..0cdc9354a1 100644 --- a/src/search/pdbs/canonical_pdbs_heuristic.cc +++ b/src/search/pdbs/canonical_pdbs_heuristic.cc @@ -32,9 +32,10 @@ CanonicalPDBs get_canonical_pdbs_from_options( computed before) so that their computation is not taken into account for dominance pruning time. */ - shared_ptr pdbs = pattern_collection_info.get_pdbs(); + TaskProxy task_proxy(*task); + shared_ptr pdbs = pattern_collection_info.get_pdbs(*task); shared_ptr> pattern_cliques = - pattern_collection_info.get_pattern_cliques(); + pattern_collection_info.get_pattern_cliques(*task); double max_time_dominance_pruning = opts.get("max_time_dominance_pruning"); if (max_time_dominance_pruning > 0.0) { diff --git a/src/search/pdbs/pattern_collection_information.cc b/src/search/pdbs/pattern_collection_information.cc index 3467405fb6..e8fffafa75 100644 --- a/src/search/pdbs/pattern_collection_information.cc +++ b/src/search/pdbs/pattern_collection_information.cc @@ -4,6 +4,8 @@ #include "pattern_cliques.h" #include "validation.h" +#include "../task_proxy.h" + #include "../utils/logging.h" #include "../utils/timer.h" @@ -19,8 +21,7 @@ PatternCollectionInformation::PatternCollectionInformation( const TaskProxy &task_proxy, const shared_ptr &patterns, utils::LogProxy &log) - : task_proxy(task_proxy), - patterns(patterns), + : patterns(patterns), pdbs(nullptr), pattern_cliques(nullptr), log(log) { @@ -55,7 +56,8 @@ bool PatternCollectionInformation::information_is_valid() const { return true; } -void PatternCollectionInformation::create_pdbs_if_missing() { +void PatternCollectionInformation::create_pdbs_if_missing( + const TaskProxy &task_proxy) { assert(patterns); if (!pdbs) { utils::Timer timer; @@ -106,8 +108,9 @@ shared_ptr PatternCollectionInformation::get_patterns() const return patterns; } -shared_ptr PatternCollectionInformation::get_pdbs() { - create_pdbs_if_missing(); +shared_ptr PatternCollectionInformation::get_pdbs( + const TaskProxy &task_proxy) { + create_pdbs_if_missing(task_proxy); return pdbs; } diff --git a/src/search/pdbs/pattern_collection_information.h b/src/search/pdbs/pattern_collection_information.h index 566d74b9a7..ea7f2d4a79 100644 --- a/src/search/pdbs/pattern_collection_information.h +++ b/src/search/pdbs/pattern_collection_information.h @@ -3,8 +3,6 @@ #include "types.h" -#include "../task_proxy.h" - #include namespace utils { @@ -25,14 +23,13 @@ namespace pdbs { as an interface for ownership transfer rather than sharing it. */ class PatternCollectionInformation { - TaskProxy task_proxy; std::shared_ptr patterns; std::shared_ptr pdbs; std::shared_ptr> pattern_cliques; utils::LogProxy &log; - void create_pdbs_if_missing(); - void create_pattern_cliques_if_missing(); + void create_pdbs_if_missing(const TaskProxy &task_proxy); + void create_pattern_cliques_if_missing(const TaskProxy &task_proxy); bool information_is_valid() const; public: @@ -46,13 +43,9 @@ class PatternCollectionInformation { void set_pattern_cliques( const std::shared_ptr> &pattern_cliques); - TaskProxy get_task_proxy() const { - return task_proxy; - } - std::shared_ptr get_patterns() const; - std::shared_ptr get_pdbs(); - std::shared_ptr> get_pattern_cliques(); + std::shared_ptr get_pdbs(const TaskProxy &task_proxy); + std::shared_ptr> get_pattern_cliques(const TaskProxy &task_proxy); }; } diff --git a/src/search/pdbs/pattern_information.cc b/src/search/pdbs/pattern_information.cc index 8430e68a78..80a3dfcc59 100644 --- a/src/search/pdbs/pattern_information.cc +++ b/src/search/pdbs/pattern_information.cc @@ -12,17 +12,12 @@ PatternInformation::PatternInformation( const TaskProxy &task_proxy, Pattern pattern, utils::LogProxy &log) - : task_proxy(task_proxy), - pattern(move(pattern)), + : pattern(move(pattern)), pdb(nullptr) { validate_and_normalize_pattern(task_proxy, this->pattern, log); } -bool PatternInformation::information_is_valid() const { - return !pdb || pdb->get_pattern() == pattern; -} - -void PatternInformation::create_pdb_if_missing() { +void PatternInformation::create_pdb_if_missing(const TaskProxy &task_proxy) { if (!pdb) { pdb = make_shared(task_proxy, pattern); } @@ -37,8 +32,9 @@ const Pattern &PatternInformation::get_pattern() const { return pattern; } -shared_ptr PatternInformation::get_pdb() { - create_pdb_if_missing(); +shared_ptr PatternInformation::get_pdb( + const TaskProxy &task_proxy) { + create_pdb_if_missing(task_proxy); return pdb; } } diff --git a/src/search/pdbs/pattern_information.h b/src/search/pdbs/pattern_information.h index d3f352d745..9c9f874ec1 100644 --- a/src/search/pdbs/pattern_information.h +++ b/src/search/pdbs/pattern_information.h @@ -24,11 +24,10 @@ namespace pdbs { ownership transfer, from the generator to the user. */ class PatternInformation { - TaskProxy task_proxy; Pattern pattern; std::shared_ptr pdb; - void create_pdb_if_missing(); + void create_pdb_if_missing(const TaskProxy &task_proxy); bool information_is_valid() const; public: @@ -37,12 +36,8 @@ class PatternInformation { void set_pdb(const std::shared_ptr &pdb); - TaskProxy get_task_proxy() const { - return task_proxy; - } - const Pattern &get_pattern() const; - std::shared_ptr get_pdb(); + std::shared_ptr get_pdb(const TaskProxy &task_proxy); }; } diff --git a/src/search/pdbs/pdb_heuristic.cc b/src/search/pdbs/pdb_heuristic.cc index 87d9b17795..c5a7e689fc 100644 --- a/src/search/pdbs/pdb_heuristic.cc +++ b/src/search/pdbs/pdb_heuristic.cc @@ -16,7 +16,7 @@ shared_ptr get_pdb_from_options(const shared_ptr shared_ptr pattern_generator = opts.get>("pattern"); PatternInformation pattern_info = pattern_generator->generate(task); - return pattern_info.get_pdb(); + return pattern_info.get_pdb(TaskProxy(*task)); } PDBHeuristic::PDBHeuristic(const plugins::Options &opts) diff --git a/src/search/pdbs/utils.cc b/src/search/pdbs/utils.cc index 11eafb96cd..bf0627b757 100644 --- a/src/search/pdbs/utils.cc +++ b/src/search/pdbs/utils.cc @@ -102,6 +102,7 @@ PatternCollectionInformation get_pattern_collection_info( } void dump_pattern_generation_statistics( + const TaskProxy &task_proxy, const string &identifier, utils::Duration runtime, const PatternInformation &pattern_info, @@ -111,12 +112,13 @@ void dump_pattern_generation_statistics( log << identifier << " pattern: " << pattern << endl; log << identifier << " number of variables: " << pattern.size() << endl; log << identifier << " PDB size: " - << compute_pdb_size(pattern_info.get_task_proxy(), pattern) << endl; + << compute_pdb_size(task_proxy, pattern) << endl; log << identifier << " computation time: " << runtime << endl; } } void dump_pattern_collection_generation_statistics( + const TaskProxy &task_proxy, const string &identifier, utils::Duration runtime, const PatternCollectionInformation &pci, @@ -127,7 +129,7 @@ void dump_pattern_collection_generation_statistics( << endl; log << identifier << " total PDB size: " << compute_total_pdb_size( - pci.get_task_proxy(), pattern_collection) << endl; + task_proxy, pattern_collection) << endl; log << identifier << " computation time: " << runtime << endl; } } diff --git a/src/search/pdbs/utils.h b/src/search/pdbs/utils.h index 94fbde3777..eccc5de48c 100644 --- a/src/search/pdbs/utils.h +++ b/src/search/pdbs/utils.h @@ -48,6 +48,7 @@ extern PatternCollectionInformation get_pattern_collection_info( prepended with the given string identifier. */ extern void dump_pattern_generation_statistics( + const TaskProxy &task_proxy, const std::string &identifier, utils::Duration runtime, const PatternInformation &pattern_info, @@ -59,6 +60,7 @@ extern void dump_pattern_generation_statistics( prepended with the given string identifier. */ extern void dump_pattern_collection_generation_statistics( + const TaskProxy &task_proxy, const std::string &identifier, utils::Duration runtime, const PatternCollectionInformation &pci, From be34afc2da997e00a60852122920e6e201eb1fda Mon Sep 17 00:00:00 2001 From: Silvan Sievers Date: Tue, 12 Mar 2019 15:21:45 +0100 Subject: [PATCH 2/3] [issue906] minor --- src/search/pdbs/pattern_collection_generator_systematic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search/pdbs/pattern_collection_generator_systematic.cc b/src/search/pdbs/pattern_collection_generator_systematic.cc index 3cc412a6bb..76f5d77b7d 100644 --- a/src/search/pdbs/pattern_collection_generator_systematic.cc +++ b/src/search/pdbs/pattern_collection_generator_systematic.cc @@ -275,8 +275,8 @@ PatternCollectionInformation PatternCollectionGeneratorSystematic::compute_patte const shared_ptr &task) { TaskProxy task_proxy(*task); patterns = make_shared(); - pattern_set.clear(); if (only_interesting_patterns) { + assert(pattern_set.empty()); build_patterns(task_proxy); } else { build_patterns_naive(task_proxy); From ccabf0733464357a0dd4e7550dc5dfb3a77444f8 Mon Sep 17 00:00:00 2001 From: Silvan Sievers Date: Mon, 30 Jan 2023 14:58:53 +0100 Subject: [PATCH 3/3] [issue906] fix compilation --- src/search/pdbs/canonical_pdbs_heuristic.cc | 6 +++--- src/search/pdbs/cegar.cc | 4 +++- src/search/pdbs/pattern_collection_generator_multiple.cc | 4 +++- src/search/pdbs/pattern_collection_generator_multiple.h | 1 + src/search/pdbs/pattern_collection_information.cc | 8 +++++--- src/search/pdbs/pattern_collection_information.h | 2 ++ src/search/pdbs/pattern_generator.cc | 5 ++++- src/search/pdbs/pattern_information.cc | 4 ++++ 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/search/pdbs/canonical_pdbs_heuristic.cc b/src/search/pdbs/canonical_pdbs_heuristic.cc index 0cdc9354a1..9b92034063 100644 --- a/src/search/pdbs/canonical_pdbs_heuristic.cc +++ b/src/search/pdbs/canonical_pdbs_heuristic.cc @@ -33,9 +33,9 @@ CanonicalPDBs get_canonical_pdbs_from_options( for dominance pruning time. */ TaskProxy task_proxy(*task); - shared_ptr pdbs = pattern_collection_info.get_pdbs(*task); + shared_ptr pdbs = pattern_collection_info.get_pdbs(task_proxy); shared_ptr> pattern_cliques = - pattern_collection_info.get_pattern_cliques(*task); + pattern_collection_info.get_pattern_cliques(task_proxy); double max_time_dominance_pruning = opts.get("max_time_dominance_pruning"); if (max_time_dominance_pruning > 0.0) { @@ -59,7 +59,7 @@ CanonicalPDBs get_canonical_pdbs_from_options( } dump_pattern_collection_generation_statistics( - "Canonical PDB heuristic", timer(), pattern_collection_info, log); + task_proxy, "Canonical PDB heuristic", timer(), pattern_collection_info, log); return CanonicalPDBs(pdbs, pattern_cliques); } diff --git a/src/search/pdbs/cegar.cc b/src/search/pdbs/cegar.cc index d5d7304486..606a4dccba 100644 --- a/src/search/pdbs/cegar.cc +++ b/src/search/pdbs/cegar.cc @@ -648,6 +648,7 @@ PatternCollectionInformation CEGAR::compute_pattern_collection() { if (log.is_at_least_normal()) { log << "CEGAR number of iterations: " << iteration << endl; dump_pattern_collection_generation_statistics( + task_proxy, "CEGAR", timer.get_elapsed_time(), pattern_collection_information, @@ -708,7 +709,8 @@ PatternInformation generate_pattern_with_cegar( } Pattern &pattern = new_patterns->front(); - shared_ptr new_pdbs = collection_info.get_pdbs(); + TaskProxy task_proxy(*task); + shared_ptr new_pdbs = collection_info.get_pdbs(task_proxy); shared_ptr &pdb = new_pdbs->front(); PatternInformation result(TaskProxy(*task), move(pattern), log); result.set_pdb(pdb); diff --git a/src/search/pdbs/pattern_collection_generator_multiple.cc b/src/search/pdbs/pattern_collection_generator_multiple.cc index 6e8ea1cfb7..753194f772 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple.cc +++ b/src/search/pdbs/pattern_collection_generator_multiple.cc @@ -76,6 +76,7 @@ unordered_set PatternCollectionGeneratorMultiple::get_blacklisted_variables } void PatternCollectionGeneratorMultiple::handle_generated_pattern( + const TaskProxy &task_proxy, PatternInformation &&pattern_info, set &generated_patterns, shared_ptr &generated_pdbs, @@ -90,7 +91,7 @@ void PatternCollectionGeneratorMultiple::handle_generated_pattern( PDB, update collection size and reset time_point_of_last_new_pattern. */ time_point_of_last_new_pattern = timer.get_elapsed_time(); - shared_ptr pdb = pattern_info.get_pdb(); + shared_ptr pdb = pattern_info.get_pdb(task_proxy); remaining_collection_size -= pdb->get_size(); generated_pdbs->push_back(move(pdb)); } @@ -216,6 +217,7 @@ PatternCollectionInformation PatternCollectionGeneratorMultiple::compute_pattern goals[goal_index], move(blacklisted_variables)); handle_generated_pattern( + task_proxy, move(pattern_info), generated_patterns, generated_pdbs, diff --git a/src/search/pdbs/pattern_collection_generator_multiple.h b/src/search/pdbs/pattern_collection_generator_multiple.h index dfd31e1d9a..847533f8a9 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple.h +++ b/src/search/pdbs/pattern_collection_generator_multiple.h @@ -52,6 +52,7 @@ class PatternCollectionGeneratorMultiple : public PatternCollectionGenerator { std::unordered_set get_blacklisted_variables( std::vector &non_goal_variables); void handle_generated_pattern( + const TaskProxy &task_proxy, PatternInformation &&pattern_info, std::set &generated_patterns, std::shared_ptr &generated_pdbs, diff --git a/src/search/pdbs/pattern_collection_information.cc b/src/search/pdbs/pattern_collection_information.cc index e8fffafa75..ad935c34d6 100644 --- a/src/search/pdbs/pattern_collection_information.cc +++ b/src/search/pdbs/pattern_collection_information.cc @@ -77,7 +77,8 @@ void PatternCollectionInformation::create_pdbs_if_missing( } } -void PatternCollectionInformation::create_pattern_cliques_if_missing() { +void PatternCollectionInformation::create_pattern_cliques_if_missing( + const TaskProxy &task_proxy) { if (!pattern_cliques) { utils::Timer timer; if (log.is_at_least_normal()) { @@ -114,8 +115,9 @@ shared_ptr PatternCollectionInformation::get_pdbs( return pdbs; } -shared_ptr> PatternCollectionInformation::get_pattern_cliques() { - create_pattern_cliques_if_missing(); +shared_ptr> PatternCollectionInformation::get_pattern_cliques( + const TaskProxy &task_proxy) { + create_pattern_cliques_if_missing(task_proxy); return pattern_cliques; } } diff --git a/src/search/pdbs/pattern_collection_information.h b/src/search/pdbs/pattern_collection_information.h index ea7f2d4a79..1a7d79e880 100644 --- a/src/search/pdbs/pattern_collection_information.h +++ b/src/search/pdbs/pattern_collection_information.h @@ -5,6 +5,8 @@ #include +class TaskProxy; + namespace utils { class LogProxy; } diff --git a/src/search/pdbs/pattern_generator.cc b/src/search/pdbs/pattern_generator.cc index f64751674d..9e39390d98 100644 --- a/src/search/pdbs/pattern_generator.cc +++ b/src/search/pdbs/pattern_generator.cc @@ -18,8 +18,9 @@ PatternCollectionInformation PatternCollectionGenerator::generate( } utils::Timer timer; PatternCollectionInformation pci = compute_patterns(task); + TaskProxy task_proxy(*task); dump_pattern_collection_generation_statistics( - name(), timer(), pci, log); + task_proxy, name(), timer(), pci, log); return pci; } @@ -34,7 +35,9 @@ PatternInformation PatternGenerator::generate( } utils::Timer timer; PatternInformation pattern_info = compute_pattern(task); + TaskProxy task_proxy(*task); dump_pattern_generation_statistics( + task_proxy, name(), timer.stop(), pattern_info, diff --git a/src/search/pdbs/pattern_information.cc b/src/search/pdbs/pattern_information.cc index 80a3dfcc59..7d63183b6c 100644 --- a/src/search/pdbs/pattern_information.cc +++ b/src/search/pdbs/pattern_information.cc @@ -17,6 +17,10 @@ PatternInformation::PatternInformation( validate_and_normalize_pattern(task_proxy, this->pattern, log); } +bool PatternInformation::information_is_valid() const { + return !pdb || pdb->get_pattern() == pattern; +} + void PatternInformation::create_pdb_if_missing(const TaskProxy &task_proxy) { if (!pdb) { pdb = make_shared(task_proxy, pattern);