diff --git a/src/search/pruning/limited_pruning.cc b/src/search/pruning/limited_pruning.cc index 2a2f29016d..ad2cbe5e0f 100644 --- a/src/search/pruning/limited_pruning.cc +++ b/src/search/pruning/limited_pruning.cc @@ -6,12 +6,16 @@ using namespace std; namespace limited_pruning { -LimitedPruning::LimitedPruning(const plugins::Options &opts) - : PruningMethod(opts), - pruning_method(opts.get>("pruning")), - min_required_pruning_ratio(opts.get("min_required_pruning_ratio")), +LimitedPruning::LimitedPruning( + const shared_ptr &pruning, + double min_required_pruning_ratio, + int expansions_before_checking_pruning_ratio, + utils::Verbosity verbosity) + : PruningMethod(verbosity), + pruning_method(pruning), + min_required_pruning_ratio(min_required_pruning_ratio), num_expansions_before_checking_pruning_ratio( - opts.get("expansions_before_checking_pruning_ratio")), + expansions_before_checking_pruning_ratio), num_pruning_calls(0), is_pruning_disabled(false) { } @@ -83,6 +87,15 @@ class LimitedPruningFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + options.get>("pruning"), + options.get("min_required_pruning_ratio"), + options.get("expansions_before_checking_pruning_ratio"), + get_pruning_arguments_from_options(options)); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/pruning/limited_pruning.h b/src/search/pruning/limited_pruning.h index 557fb2b647..51a450ff67 100644 --- a/src/search/pruning/limited_pruning.h +++ b/src/search/pruning/limited_pruning.h @@ -18,7 +18,10 @@ class LimitedPruning : public PruningMethod { virtual void prune( const State &state, std::vector &op_ids) override; public: - explicit LimitedPruning(const plugins::Options &opts); + explicit LimitedPruning(const std::shared_ptr &pruning, + double min_required_pruning_ratio, + int expansions_before_checking_pruning_ratio, + utils::Verbosity verbosity); virtual void initialize(const std::shared_ptr &) override; }; } diff --git a/src/search/pruning/null_pruning_method.cc b/src/search/pruning/null_pruning_method.cc index 1aa285da35..806357017b 100644 --- a/src/search/pruning/null_pruning_method.cc +++ b/src/search/pruning/null_pruning_method.cc @@ -6,8 +6,8 @@ using namespace std; namespace null_pruning_method { -NullPruningMethod::NullPruningMethod(const plugins::Options &opts) - : PruningMethod(opts) { +NullPruningMethod::NullPruningMethod(utils::Verbosity verbosity) + : PruningMethod(verbosity) { } void NullPruningMethod::initialize(const shared_ptr &task) { @@ -26,6 +26,12 @@ class NullPruningMethodFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + get_pruning_arguments_from_options(options)); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/pruning/null_pruning_method.h b/src/search/pruning/null_pruning_method.h index acd93092cb..3f857dd872 100644 --- a/src/search/pruning/null_pruning_method.h +++ b/src/search/pruning/null_pruning_method.h @@ -8,7 +8,7 @@ class NullPruningMethod : public PruningMethod { virtual void prune( const State &, std::vector &) override {} public: - explicit NullPruningMethod(const plugins::Options &opts); + explicit NullPruningMethod(utils::Verbosity verbosity); virtual void initialize(const std::shared_ptr &) override; virtual void print_statistics() const override {} }; diff --git a/src/search/pruning/stubborn_sets.cc b/src/search/pruning/stubborn_sets.cc index 9d1a65ae88..78005aebe5 100644 --- a/src/search/pruning/stubborn_sets.cc +++ b/src/search/pruning/stubborn_sets.cc @@ -6,8 +6,8 @@ using namespace std; namespace stubborn_sets { -StubbornSets::StubbornSets(const plugins::Options &opts) - : PruningMethod(opts), +StubbornSets::StubbornSets(utils::Verbosity verbosity) + : PruningMethod(verbosity), num_operators(-1) { } diff --git a/src/search/pruning/stubborn_sets.h b/src/search/pruning/stubborn_sets.h index a5841d3f4b..402395ddec 100644 --- a/src/search/pruning/stubborn_sets.h +++ b/src/search/pruning/stubborn_sets.h @@ -54,7 +54,7 @@ class StubbornSets : public PruningMethod { virtual void compute_stubborn_set(const State &state) = 0; public: - explicit StubbornSets(const plugins::Options &opts); + explicit StubbornSets(utils::Verbosity verbosity); virtual void initialize(const std::shared_ptr &task) override; }; diff --git a/src/search/pruning/stubborn_sets_action_centric.cc b/src/search/pruning/stubborn_sets_action_centric.cc index 23c5a21172..574537e215 100644 --- a/src/search/pruning/stubborn_sets_action_centric.cc +++ b/src/search/pruning/stubborn_sets_action_centric.cc @@ -23,8 +23,8 @@ static bool contain_conflicting_fact(const vector &facts1, return false; } -StubbornSetsActionCentric::StubbornSetsActionCentric(const plugins::Options &opts) - : StubbornSets(opts) { +StubbornSetsActionCentric::StubbornSetsActionCentric(utils::Verbosity verbosity) + : StubbornSets(verbosity) { } void StubbornSetsActionCentric::compute_stubborn_set(const State &state) { diff --git a/src/search/pruning/stubborn_sets_action_centric.h b/src/search/pruning/stubborn_sets_action_centric.h index b859a95684..cde64cfb45 100644 --- a/src/search/pruning/stubborn_sets_action_centric.h +++ b/src/search/pruning/stubborn_sets_action_centric.h @@ -17,7 +17,7 @@ class StubbornSetsActionCentric : public stubborn_sets::StubbornSets { virtual void handle_stubborn_operator(const State &state, int op_no) = 0; virtual void compute_stubborn_set(const State &state) override; protected: - explicit StubbornSetsActionCentric(const plugins::Options &opts); + explicit StubbornSetsActionCentric(utils::Verbosity verbosity); bool can_disable(int op1_no, int op2_no) const; bool can_conflict(int op1_no, int op2_no) const; diff --git a/src/search/pruning/stubborn_sets_atom_centric.cc b/src/search/pruning/stubborn_sets_atom_centric.cc index 302c52fbdc..105d1faf72 100644 --- a/src/search/pruning/stubborn_sets_atom_centric.cc +++ b/src/search/pruning/stubborn_sets_atom_centric.cc @@ -9,10 +9,12 @@ using namespace std; namespace stubborn_sets_atom_centric { -StubbornSetsAtomCentric::StubbornSetsAtomCentric(const plugins::Options &opts) - : StubbornSets(opts), - use_sibling_shortcut(opts.get("use_sibling_shortcut")), - atom_selection_strategy(opts.get("atom_selection_strategy")) { +StubbornSetsAtomCentric::StubbornSetsAtomCentric( + bool use_sibling_shortcut, AtomSelectionStrategy atom_selection_strategy, + utils::Verbosity verbosity) + : StubbornSets(verbosity), + use_sibling_shortcut(use_sibling_shortcut), + atom_selection_strategy(atom_selection_strategy) { } void StubbornSetsAtomCentric::initialize(const shared_ptr &task) { @@ -275,6 +277,14 @@ class StubbornSetsAtomCentricFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + options.get("use_sibling_shortcut"), + options.get("atom_selection_strategy"), + get_pruning_arguments_from_options(options)); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/pruning/stubborn_sets_atom_centric.h b/src/search/pruning/stubborn_sets_atom_centric.h index 95c364bb1d..7ce6b85a77 100644 --- a/src/search/pruning/stubborn_sets_atom_centric.h +++ b/src/search/pruning/stubborn_sets_atom_centric.h @@ -51,7 +51,8 @@ class StubbornSetsAtomCentric : public stubborn_sets::StubbornSets { void handle_stubborn_operator(const State &state, int op); virtual void compute_stubborn_set(const State &state) override; public: - explicit StubbornSetsAtomCentric(const plugins::Options &opts); + explicit StubbornSetsAtomCentric(bool use_sibling_shortcut, + AtomSelectionStrategy atom_selection_strategy, utils::Verbosity verbosity); virtual void initialize(const std::shared_ptr &task) override; }; } diff --git a/src/search/pruning/stubborn_sets_ec.cc b/src/search/pruning/stubborn_sets_ec.cc index aee27e142f..55379e6116 100644 --- a/src/search/pruning/stubborn_sets_ec.cc +++ b/src/search/pruning/stubborn_sets_ec.cc @@ -102,8 +102,8 @@ static void get_conflicting_vars(const vector &facts1, } } -StubbornSetsEC::StubbornSetsEC(const plugins::Options &opts) - : StubbornSetsActionCentric(opts) { +StubbornSetsEC::StubbornSetsEC(utils::Verbosity verbosity) + : StubbornSetsActionCentric(verbosity) { } void StubbornSetsEC::initialize(const shared_ptr &task) { @@ -346,6 +346,12 @@ class StubbornSetsECFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + get_pruning_arguments_from_options(options)); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/pruning/stubborn_sets_ec.h b/src/search/pruning/stubborn_sets_ec.h index 5cc6e0c3c9..8ac60024bb 100644 --- a/src/search/pruning/stubborn_sets_ec.h +++ b/src/search/pruning/stubborn_sets_ec.h @@ -32,7 +32,7 @@ class StubbornSetsEC : public stubborn_sets::StubbornSetsActionCentric { virtual void initialize_stubborn_set(const State &state) override; virtual void handle_stubborn_operator(const State &state, int op_no) override; public: - explicit StubbornSetsEC(const plugins::Options &opts); + explicit StubbornSetsEC(utils::Verbosity verbosity); virtual void initialize(const std::shared_ptr &task) override; }; } diff --git a/src/search/pruning/stubborn_sets_simple.cc b/src/search/pruning/stubborn_sets_simple.cc index eb95a3daf4..c5bc2b9248 100644 --- a/src/search/pruning/stubborn_sets_simple.cc +++ b/src/search/pruning/stubborn_sets_simple.cc @@ -7,8 +7,8 @@ using namespace std; namespace stubborn_sets_simple { -StubbornSetsSimple::StubbornSetsSimple(const plugins::Options &opts) - : StubbornSetsActionCentric(opts) { +StubbornSetsSimple::StubbornSetsSimple(utils::Verbosity verbosity) + : StubbornSetsActionCentric(verbosity) { } void StubbornSetsSimple::initialize(const shared_ptr &task) { @@ -104,6 +104,12 @@ class StubbornSetsSimpleFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + get_pruning_arguments_from_options(options)); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/pruning/stubborn_sets_simple.h b/src/search/pruning/stubborn_sets_simple.h index 5f9db288e7..2a6d8366b8 100644 --- a/src/search/pruning/stubborn_sets_simple.h +++ b/src/search/pruning/stubborn_sets_simple.h @@ -26,7 +26,7 @@ class StubbornSetsSimple : public stubborn_sets::StubbornSetsActionCentric { virtual void handle_stubborn_operator(const State &state, int op_no) override; public: - explicit StubbornSetsSimple(const plugins::Options &opts); + explicit StubbornSetsSimple(utils::Verbosity verbosity); virtual void initialize(const std::shared_ptr &task) override; }; } diff --git a/src/search/pruning_method.cc b/src/search/pruning_method.cc index 519761d0bb..c232061841 100644 --- a/src/search/pruning_method.cc +++ b/src/search/pruning_method.cc @@ -9,9 +9,9 @@ using namespace std; -PruningMethod::PruningMethod(const plugins::Options &opts) +PruningMethod::PruningMethod(utils::Verbosity verbosity) : timer(false), - log(utils::get_log_from_options(opts)), + log(utils::get_log_for_verbosity(verbosity)), task(nullptr) { } @@ -69,6 +69,10 @@ void add_pruning_options_to_feature(plugins::Feature &feature) { "normal verbosity for running experiments."); } +tuple get_pruning_arguments_from_options(const plugins::Options &opts) { + return utils::get_log_arguments_from_options(opts); +} + static class PruningMethodCategoryPlugin : public plugins::TypedCategoryPlugin { public: PruningMethodCategoryPlugin() : TypedCategoryPlugin("PruningMethod") { diff --git a/src/search/pruning_method.h b/src/search/pruning_method.h index 531f3771ab..11f7521d74 100644 --- a/src/search/pruning_method.h +++ b/src/search/pruning_method.h @@ -33,7 +33,7 @@ class PruningMethod { long num_successors_before_pruning; long num_successors_after_pruning; public: - explicit PruningMethod(const plugins::Options &opts); + explicit PruningMethod(utils::Verbosity verbosity); virtual ~PruningMethod() = default; virtual void initialize(const std::shared_ptr &task); void prune_operators(const State &state, std::vector &op_ids); @@ -41,5 +41,7 @@ class PruningMethod { }; extern void add_pruning_options_to_feature(plugins::Feature &feature); +extern std::tuple get_pruning_arguments_from_options( + const plugins::Options &opts); #endif diff --git a/src/search/utils/logging.cc b/src/search/utils/logging.cc index aa8cfe1077..a87557cdba 100644 --- a/src/search/utils/logging.cc +++ b/src/search/utils/logging.cc @@ -31,8 +31,7 @@ void add_log_options_to_feature(plugins::Feature &feature) { } tuple get_log_arguments_from_options(const plugins::Options &opts) { - auto own_tuple = make_tuple(opts.get("verbosity")); - return tuple(own_tuple); + return make_tuple(opts.get("verbosity")); } LogProxy get_log_for_verbosity(const Verbosity &verbosity) {