From ea73ee6b13ae852c61b4d37196d3ff454adc89b7 Mon Sep 17 00:00:00 2001 From: Florian Pommerening Date: Thu, 8 Feb 2024 23:02:31 +0100 Subject: [PATCH] update operator-counting --- src/search/AAA_Mechanical_Changes.md | 4 ++-- .../delete_relaxation_constraints.cc | 14 +++++++++++--- .../delete_relaxation_constraints.h | 2 +- src/search/operator_counting/pho_constraints.cc | 11 ++++++++--- src/search/operator_counting/pho_constraints.h | 2 +- .../state_equation_constraints.cc | 11 ++++++++--- .../operator_counting/state_equation_constraints.h | 2 +- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/search/AAA_Mechanical_Changes.md b/src/search/AAA_Mechanical_Changes.md index f6791bbda0..c8c601161a 100644 --- a/src/search/AAA_Mechanical_Changes.md +++ b/src/search/AAA_Mechanical_Changes.md @@ -73,7 +73,7 @@ search ├── ❓ heuristic.h ├── ✅ heuristics ├── ✅ landmarks -├── ❌ lp +├── ✅ lp ├── ✅ merge_and_shrink ├── ✅ open_list_factory.cc ├── ✅ open_list_factory.h @@ -81,7 +81,7 @@ search ├── ❌ open_lists ├── ✅ operator_cost.cc ├── ✅ operator_cost.h -├── ❌ operator_counting +├── ✅ operator_counting ├── ✅ operator_id.cc ├── ✅ operator_id.h ├── ✅ parser diff --git a/src/search/operator_counting/delete_relaxation_constraints.cc b/src/search/operator_counting/delete_relaxation_constraints.cc index 959de4bad9..54bbbbe20f 100644 --- a/src/search/operator_counting/delete_relaxation_constraints.cc +++ b/src/search/operator_counting/delete_relaxation_constraints.cc @@ -21,9 +21,10 @@ static void add_lp_variables(int count, LPVariables &variables, vector &ind } -DeleteRelaxationConstraints::DeleteRelaxationConstraints(const plugins::Options &opts) - : use_time_vars(opts.get("use_time_vars")), - use_integer_vars(opts.get("use_integer_vars")) { +DeleteRelaxationConstraints::DeleteRelaxationConstraints(bool use_time_vars, + bool use_integer_vars) + : use_time_vars(use_time_vars), + use_integer_vars(use_integer_vars) { } int DeleteRelaxationConstraints::get_var_op_used(const OperatorProxy &op) { @@ -280,6 +281,13 @@ class DeleteRelaxationConstraintsFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return make_shared( + options.get("use_time_vars"), + options.get("use_integer_vars")); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/operator_counting/delete_relaxation_constraints.h b/src/search/operator_counting/delete_relaxation_constraints.h index a28fed269e..5465496bf1 100644 --- a/src/search/operator_counting/delete_relaxation_constraints.h +++ b/src/search/operator_counting/delete_relaxation_constraints.h @@ -63,7 +63,7 @@ class DeleteRelaxationConstraints : public ConstraintGenerator { const TaskProxy &task_proxy, LPVariables &variables); void create_constraints(const TaskProxy &task_proxy, lp::LinearProgram &lp); public: - explicit DeleteRelaxationConstraints(const plugins::Options &opts); + explicit DeleteRelaxationConstraints(bool use_time_vars, bool use_integer_vars); virtual void initialize_constraints( const std::shared_ptr &task, diff --git a/src/search/operator_counting/pho_constraints.cc b/src/search/operator_counting/pho_constraints.cc index 72ccacc876..6a069284fb 100644 --- a/src/search/operator_counting/pho_constraints.cc +++ b/src/search/operator_counting/pho_constraints.cc @@ -15,9 +15,8 @@ using namespace std; namespace operator_counting { -PhOConstraints::PhOConstraints(const plugins::Options &opts) - : pattern_generator( - opts.get>("patterns")) { +PhOConstraints::PhOConstraints(const shared_ptr &pattern_generator) + : pattern_generator(pattern_generator) { } void PhOConstraints::initialize_constraints( @@ -84,6 +83,12 @@ class PhOConstraintsFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + options.get>("patterns")); + } }; static plugins::FeaturePlugin _plugin; diff --git a/src/search/operator_counting/pho_constraints.h b/src/search/operator_counting/pho_constraints.h index 7a4b861f20..2f7edafd81 100644 --- a/src/search/operator_counting/pho_constraints.h +++ b/src/search/operator_counting/pho_constraints.h @@ -24,7 +24,7 @@ class PhOConstraints : public ConstraintGenerator { int constraint_offset; std::shared_ptr pdbs; public: - explicit PhOConstraints(const plugins::Options &opts); + explicit PhOConstraints(const std::shared_ptr &pattern_generator); virtual void initialize_constraints( const std::shared_ptr &task, lp::LinearProgram &lp) override; diff --git a/src/search/operator_counting/state_equation_constraints.cc b/src/search/operator_counting/state_equation_constraints.cc index ca685da232..fd3b36eff7 100644 --- a/src/search/operator_counting/state_equation_constraints.cc +++ b/src/search/operator_counting/state_equation_constraints.cc @@ -11,9 +11,8 @@ using namespace std; namespace operator_counting { -StateEquationConstraints::StateEquationConstraints( - const plugins::Options &opts) - : log(utils::get_log_from_options(opts)) { +StateEquationConstraints::StateEquationConstraints(utils::Verbosity verbosity) + : log(utils::get_log_for_verbosity(verbosity)) { } static void add_indices_to_constraint(lp::LPConstraint &constraint, @@ -159,6 +158,12 @@ class StateEquationConstraintsFeature : public plugins::TypedFeature create_component( + const plugins::Options &options, const utils::Context &) const override { + return plugins::make_shared_from_arg_tuples( + utils::get_log_arguments_from_options(options)); + } }; diff --git a/src/search/operator_counting/state_equation_constraints.h b/src/search/operator_counting/state_equation_constraints.h index 471f9bbec4..7d2c42e72b 100644 --- a/src/search/operator_counting/state_equation_constraints.h +++ b/src/search/operator_counting/state_equation_constraints.h @@ -40,7 +40,7 @@ class StateEquationConstraints : public ConstraintGenerator { void build_propositions(const TaskProxy &task_proxy); void add_constraints(named_vector::NamedVector &constraints, double infinity); public: - explicit StateEquationConstraints(const plugins::Options &opts); + explicit StateEquationConstraints(utils::Verbosity verbosity); virtual void initialize_constraints( const std::shared_ptr &task, lp::LinearProgram &lp) override; virtual bool update_constraints(const State &state, lp::LPSolver &lp_solver) override;