From 93bde94ba2f8381180990cb6edee00661a4e5dd6 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 00:13:17 +0200 Subject: [PATCH 1/8] [issue1113] Check argument duplicates of features. --- src/search/parser/abstract_syntax_tree.cc | 4 ++++ src/search/plugins/raw_registry.cc | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/search/parser/abstract_syntax_tree.cc b/src/search/parser/abstract_syntax_tree.cc index 5aecdb7290..872667b10a 100644 --- a/src/search/parser/abstract_syntax_tree.cc +++ b/src/search/parser/abstract_syntax_tree.cc @@ -183,6 +183,10 @@ void FunctionCallNode::collect_keyword_arguments( DecorateContext &context, CollectedArguments &arguments) const { unordered_map argument_infos_by_key; for (const plugins::ArgumentInfo &arg_info : argument_infos) { + assert(!argument_infos_by_key.contains(arg_info.key)); + if (argument_infos_by_key.contains(arg_info.key)){ + cout << "Already contains " << arg_info.key << endl; + } argument_infos_by_key.insert({arg_info.key, arg_info}); } diff --git a/src/search/plugins/raw_registry.cc b/src/search/plugins/raw_registry.cc index 4c652a8266..a95cdf6361 100644 --- a/src/search/plugins/raw_registry.cc +++ b/src/search/plugins/raw_registry.cc @@ -163,13 +163,27 @@ Features RawRegistry::collect_features( "Missing Plugin for type of feature '" + key + "'."); } + unordered_map occurrences; for (const ArgumentInfo &arg_info : feature.get_arguments()) { if (arg_info.type == TypeRegistry::NO_TYPE) { errors.push_back( "Missing Plugin for type of argument '" + arg_info.key + "' of feature '" + key + "'."); } + ++occurrences[arg_info.key]; + } + // Check that arg_keys are unique + for (const auto &pair : occurrences) { + const string &arg_key = pair.first; + int occurrence = pair.second; + if (occurrence > 1) { + errors.push_back( + "The Argument '" + arg_key + "' in '" + key + "' is defined " + + to_string(occurrence) + " times."); + } + } + } return features; From b317bf78b22d12465ec7eace27a5f36c61b7b990 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 00:13:48 +0200 Subject: [PATCH 2/8] [issue1113] Remove duplicate verbosity argument of feature. --- src/search/pdbs/pattern_collection_generator_hillclimbing.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search/pdbs/pattern_collection_generator_hillclimbing.cc b/src/search/pdbs/pattern_collection_generator_hillclimbing.cc index 74609dc173..441a664140 100644 --- a/src/search/pdbs/pattern_collection_generator_hillclimbing.cc +++ b/src/search/pdbs/pattern_collection_generator_hillclimbing.cc @@ -552,7 +552,6 @@ static void add_hillclimbing_options(plugins::Feature &feature) { "infinity", plugins::Bounds("0.0", "infinity")); utils::add_rng_options(feature); - add_generator_options_to_feature(feature); } static void check_hillclimbing_options( @@ -596,6 +595,7 @@ class PatternCollectionGeneratorHillclimbingFeature : public plugins::TypedFeatu "optimized for the Evaluator#Canonical_PDB heuristic. It it described " "in the following paper:" + paper_references()); add_hillclimbing_options(*this); + add_generator_options_to_feature(*this); } virtual shared_ptr create_component(const plugins::Options &options, const utils::Context &context) const override { From 9e54ca8c179b5fe07ab12871d556cf3fa30ba90e Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 00:24:43 +0200 Subject: [PATCH 3/8] Remove unused output. --- src/search/parser/abstract_syntax_tree.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/search/parser/abstract_syntax_tree.cc b/src/search/parser/abstract_syntax_tree.cc index 872667b10a..280174b645 100644 --- a/src/search/parser/abstract_syntax_tree.cc +++ b/src/search/parser/abstract_syntax_tree.cc @@ -184,9 +184,6 @@ void FunctionCallNode::collect_keyword_arguments( unordered_map argument_infos_by_key; for (const plugins::ArgumentInfo &arg_info : argument_infos) { assert(!argument_infos_by_key.contains(arg_info.key)); - if (argument_infos_by_key.contains(arg_info.key)){ - cout << "Already contains " << arg_info.key << endl; - } argument_infos_by_key.insert({arg_info.key, arg_info}); } From d4797f13cd0d211483c823d5d5eb4e29ea64b68a Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 00:32:55 +0200 Subject: [PATCH 4/8] fix style. --- src/search/plugins/raw_registry.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/search/plugins/raw_registry.cc b/src/search/plugins/raw_registry.cc index a95cdf6361..ec7ddc9d0c 100644 --- a/src/search/plugins/raw_registry.cc +++ b/src/search/plugins/raw_registry.cc @@ -171,7 +171,6 @@ Features RawRegistry::collect_features( + "' of feature '" + key + "'."); } ++occurrences[arg_info.key]; - } // Check that arg_keys are unique for (const auto &pair : occurrences) { @@ -179,11 +178,10 @@ Features RawRegistry::collect_features( int occurrence = pair.second; if (occurrence > 1) { errors.push_back( - "The Argument '" + arg_key + "' in '" + key + "' is defined " + - to_string(occurrence) + " times."); + "The Argument '" + arg_key + "' in '" + key + "' is defined " + + to_string(occurrence) + " times."); } } - } return features; From b5fc7405e05177c9520c82d3e2bde9912d883207 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 10:27:03 +0200 Subject: [PATCH 5/8] rename variables. --- src/search/plugins/raw_registry.cc | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/search/plugins/raw_registry.cc b/src/search/plugins/raw_registry.cc index ec7ddc9d0c..c5c90b07ff 100644 --- a/src/search/plugins/raw_registry.cc +++ b/src/search/plugins/raw_registry.cc @@ -118,28 +118,28 @@ SubcategoryPlugins RawRegistry::collect_subcategory_plugins( Features RawRegistry::collect_features( const SubcategoryPlugins &subcategory_plugins, vector &errors) const { Features features; - unordered_map key_occurrences; + unordered_map feature_key_occurrences; for (const Plugin *plugin : plugins) { shared_ptr feature = plugin->create_feature(); - string key = feature->get_key(); - key_occurrences[key]++; - features[key] = move(feature); + string feature_key = feature->get_key(); + feature_key_occurrences[feature_key]++; + features[feature_key] = move(feature); } - // Check that keys are unique - for (const auto &pair : key_occurrences) { - const string &key = pair.first; + // Check that feature_keys are unique + for (const auto &pair : feature_key_occurrences) { + const string &feature_key = pair.first; int occurrences = pair.second; if (occurrences > 1) { errors.push_back( to_string(occurrences) + " Features are defined for the key '" + - key + "'."); + feature_key + "'."); } } // Check that all subcategories used in features are defined for (const auto &item : features) { - const string &key = item.first; + const string &feature_key = item.first; const Feature &feature = *item.second; string subcategory = feature.get_subcategory(); @@ -147,39 +147,39 @@ Features RawRegistry::collect_features( const Type &type = feature.get_type(); errors.push_back( "Missing SubcategoryPlugin '" + subcategory + "' for Plugin '" + - key + "' of type " + type.name()); + feature_key + "' of type " + type.name()); } } // Check that all types used in features are defined unordered_set missing_types; for (const auto &item : features) { - const string &key = item.first; + const string &feature_key = item.first; const Feature &feature = *item.second; const Type &type = feature.get_type(); if (type == TypeRegistry::NO_TYPE) { errors.push_back( - "Missing Plugin for type of feature '" + key + "'."); + "Missing Plugin for type of feature '" + feature_key + "'."); } - unordered_map occurrences; + unordered_map argument_key_occurrences; for (const ArgumentInfo &arg_info : feature.get_arguments()) { if (arg_info.type == TypeRegistry::NO_TYPE) { errors.push_back( "Missing Plugin for type of argument '" + arg_info.key - + "' of feature '" + key + "'."); + + "' of feature '" + feature_key + "'."); } - ++occurrences[arg_info.key]; + ++argument_key_occurrences[arg_info.key]; } // Check that arg_keys are unique - for (const auto &pair : occurrences) { + for (const auto &pair : argument_key_occurrences) { const string &arg_key = pair.first; - int occurrence = pair.second; - if (occurrence > 1) { + int arg_key_occurrence = pair.second; + if (arg_key_occurrence > 1) { errors.push_back( - "The Argument '" + arg_key + "' in '" + key + "' is defined " + - to_string(occurrence) + " times."); + "The Argument '" + arg_key + "' in '" + feature_key + "' is defined " + + to_string(arg_key_occurrence) + " times."); } } } From 7cd700633d378d83a375a66235145d978c465cdd Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 17:01:35 +0200 Subject: [PATCH 6/8] rename variables. --- src/search/plugins/raw_registry.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/search/plugins/raw_registry.cc b/src/search/plugins/raw_registry.cc index c5c90b07ff..6d4c4c0b79 100644 --- a/src/search/plugins/raw_registry.cc +++ b/src/search/plugins/raw_registry.cc @@ -163,23 +163,23 @@ Features RawRegistry::collect_features( "Missing Plugin for type of feature '" + feature_key + "'."); } - unordered_map argument_key_occurrences; + unordered_map parameter_occurrences; for (const ArgumentInfo &arg_info : feature.get_arguments()) { if (arg_info.type == TypeRegistry::NO_TYPE) { errors.push_back( - "Missing Plugin for type of argument '" + arg_info.key + "Missing Plugin for type of parameter '" + arg_info.key + "' of feature '" + feature_key + "'."); } - ++argument_key_occurrences[arg_info.key]; + ++parameter_occurrences[arg_info.key]; } - // Check that arg_keys are unique - for (const auto &pair : argument_key_occurrences) { - const string &arg_key = pair.first; - int arg_key_occurrence = pair.second; - if (arg_key_occurrence > 1) { + // Check that parameters are unique + for (const auto &pair : parameter_occurrences) { + const string ¶meter = pair.first; + int parameter_occurrence = pair.second; + if (parameter_occurrence > 1) { errors.push_back( - "The Argument '" + arg_key + "' in '" + feature_key + "' is defined " + - to_string(arg_key_occurrence) + " times."); + "The Parameter '" + parameter + "' in '" + feature_key + "' is defined " + + to_string(parameter_occurrence) + " times."); } } } From 9679849836571c3e4df2d0191399be5706e8101e Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 8 Sep 2023 17:40:03 +0200 Subject: [PATCH 7/8] fix style. --- src/search/plugins/raw_registry.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search/plugins/raw_registry.cc b/src/search/plugins/raw_registry.cc index 6d4c4c0b79..1bb0862376 100644 --- a/src/search/plugins/raw_registry.cc +++ b/src/search/plugins/raw_registry.cc @@ -178,8 +178,8 @@ Features RawRegistry::collect_features( int parameter_occurrence = pair.second; if (parameter_occurrence > 1) { errors.push_back( - "The Parameter '" + parameter + "' in '" + feature_key + "' is defined " + - to_string(parameter_occurrence) + " times."); + "The Parameter '" + parameter + "' in '" + feature_key + "' is defined " + + to_string(parameter_occurrence) + " times."); } } } From 8ee93c46e2c2aa820965217ef6a899ce7d18ba57 Mon Sep 17 00:00:00 2001 From: SimonDold <48084373+SimonDold@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:16:55 +0200 Subject: [PATCH 8/8] fix message. --- src/search/plugins/raw_registry.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search/plugins/raw_registry.cc b/src/search/plugins/raw_registry.cc index 1bb0862376..67e9cc5f06 100644 --- a/src/search/plugins/raw_registry.cc +++ b/src/search/plugins/raw_registry.cc @@ -178,7 +178,7 @@ Features RawRegistry::collect_features( int parameter_occurrence = pair.second; if (parameter_occurrence > 1) { errors.push_back( - "The Parameter '" + parameter + "' in '" + feature_key + "' is defined " + + "The parameter '" + parameter + "' in '" + feature_key + "' is defined " + to_string(parameter_occurrence) + " times."); } }