From 6911c468e4e681c4304587fb275cbd915003c749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salom=C3=A9=20Eriksson?= Date: Fri, 9 Feb 2024 10:57:51 +0100 Subject: [PATCH] [issue454] uncrustify --- src/search/heuristics/cea_heuristic.cc | 1 - src/search/heuristics/cg_heuristic.cc | 1 - src/search/landmarks/landmark_heuristic.cc | 3 +- src/search/tasks/negated_axioms_task.cc | 34 ++++++++++------------ src/search/tasks/negated_axioms_task.h | 8 ++--- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/search/heuristics/cea_heuristic.cc b/src/search/heuristics/cea_heuristic.cc index 398f2f39b1..2f35905ac6 100644 --- a/src/search/heuristics/cea_heuristic.cc +++ b/src/search/heuristics/cea_heuristic.cc @@ -413,7 +413,6 @@ ContextEnhancedAdditiveHeuristic::ContextEnhancedAdditiveHeuristic( const plugins::Options &opts) : Heuristic(opts), min_action_cost(task_properties::get_min_operator_cost(task_proxy)) { - if (task_properties::has_axioms(task_proxy)) { task = make_shared(tasks::NegatedAxiomsTask(task)); task_proxy = TaskProxy(*task); diff --git a/src/search/heuristics/cg_heuristic.cc b/src/search/heuristics/cg_heuristic.cc index 2c3af22a5d..f093545639 100644 --- a/src/search/heuristics/cg_heuristic.cc +++ b/src/search/heuristics/cg_heuristic.cc @@ -23,7 +23,6 @@ CGHeuristic::CGHeuristic(const plugins::Options &opts) cache_misses(0), helpful_transition_extraction_counter(0), min_action_cost(task_properties::get_min_operator_cost(task_proxy)) { - if (task_properties::has_axioms(task_proxy)) { task = make_shared(tasks::NegatedAxiomsTask(task)); task_proxy = TaskProxy(*task); diff --git a/src/search/landmarks/landmark_heuristic.cc b/src/search/landmarks/landmark_heuristic.cc index 2930942507..a2b246673e 100644 --- a/src/search/landmarks/landmark_heuristic.cc +++ b/src/search/landmarks/landmark_heuristic.cc @@ -20,7 +20,6 @@ LandmarkHeuristic::LandmarkHeuristic( : Heuristic(opts), use_preferred_operators(opts.get("pref")), successor_generator(nullptr) { - if (task_properties::has_axioms(task_proxy)) { task = make_shared(tasks::NegatedAxiomsTask(task)); task_proxy = TaskProxy(*task); @@ -36,7 +35,7 @@ void LandmarkHeuristic::initialize(const plugins::Options &opts) { // TODO: update comment and cerr message if (task != tasks::g_root_task && dynamic_cast(task.get()) == nullptr - && dynamic_cast(task.get()) == nullptr ) { + && dynamic_cast(task.get()) == nullptr) { cerr << "The landmark heuristics currently only support " << "task transformations that modify the operator costs. " << "See issues 845 and 686 for details." << endl; diff --git a/src/search/tasks/negated_axioms_task.cc b/src/search/tasks/negated_axioms_task.cc index 6e980f2b34..0177104b60 100644 --- a/src/search/tasks/negated_axioms_task.cc +++ b/src/search/tasks/negated_axioms_task.cc @@ -15,11 +15,9 @@ using namespace std; using utils::ExitCode; namespace tasks { - NegatedAxiomsTask::NegatedAxiomsTask(const shared_ptr &parent) : DelegatingTask(parent), negated_axioms_start_index(parent->get_num_axioms()) { - TaskProxy task_proxy(*parent); vector> pos_dependencies(task_proxy.get_variables().size()); @@ -42,7 +40,7 @@ NegatedAxiomsTask::NegatedAxiomsTask(const shared_ptr &parent) } } unordered_set needed_negatively = - collect_needed_negatively(pos_dependencies, neg_dependencies); + collect_needed_negatively(pos_dependencies, neg_dependencies); /* TODO: I removed the return if needed_negatively is empty. It is somewhat wasteful if we have a big graph to compute the sccs, @@ -57,7 +55,7 @@ NegatedAxiomsTask::NegatedAxiomsTask(const shared_ptr &parent) vector> sccs = sccs::compute_maximal_sccs(pos_dependencies); vector var_to_scc(task_proxy.get_variables().size(), -1); - for (int i = 0; i < (int) sccs.size(); ++i) { + for (int i = 0; i < (int)sccs.size(); ++i) { for (int var: sccs[i]) { var_to_scc[var] = i; } @@ -96,9 +94,8 @@ NegatedAxiomsTask::NegatedAxiomsTask(const shared_ptr &parent) unordered_set NegatedAxiomsTask::collect_needed_negatively( const vector> &positive_dependencies, const vector> &negative_dependencies) { - // Stores which derived variables are needed positively or negatively. - set> needed; + set> needed; // TODO: Should we store the proxy in the class? Pass it through methods? TaskProxy task_proxy(*parent); @@ -115,7 +112,7 @@ unordered_set NegatedAxiomsTask::collect_needed_negatively( for (FactProxy condition: op.get_preconditions()) { VariableProxy var_proxy = condition.get_variable(); if (var_proxy.is_derived() - && condition.get_value() == var_proxy.get_default_axiom_value()) { + && condition.get_value() == var_proxy.get_default_axiom_value()) { needed.emplace(condition.get_pair().var, false); } } @@ -124,14 +121,14 @@ unordered_set NegatedAxiomsTask::collect_needed_negatively( for (FactProxy condition: effect.get_conditions()) { VariableProxy var_proxy = condition.get_variable(); if (var_proxy.is_derived() - && condition.get_value() == var_proxy.get_default_axiom_value()) { + && condition.get_value() == var_proxy.get_default_axiom_value()) { needed.emplace(condition.get_pair().var, false); } } } } - deque> to_process(needed.begin(), needed.end()); + deque> to_process(needed.begin(), needed.end()); while (!to_process.empty()) { int var = to_process.front().first; bool truth_value = to_process.front().second; @@ -151,7 +148,7 @@ unordered_set NegatedAxiomsTask::collect_needed_negatively( } unordered_set needed_negatively; - for (pair entry : needed) { + for (pair entry : needed) { if (!entry.second) { needed_negatively.insert(entry.first); } @@ -193,7 +190,7 @@ void NegatedAxiomsTask::add_negated_axioms_for_var( set current; set> hitting_sets; collect_non_dominated_hitting_sets_recursively( - conditions_as_cnf, 0, current, hitting_sets); + conditions_as_cnf, 0, current, hitting_sets); for (const set &c : hitting_sets) { negated_axioms.emplace_back( @@ -205,7 +202,6 @@ void NegatedAxiomsTask::add_negated_axioms_for_var( void NegatedAxiomsTask::collect_non_dominated_hitting_sets_recursively( const std::vector> &conditions_as_cnf, size_t index, std::set &hitting_set, std::set> &results) { - if (index == conditions_as_cnf.size()) { /* Check whether the axiom body denoted in body is dominated. @@ -282,15 +278,15 @@ int NegatedAxiomsTask::get_num_operator_preconditions(int index, bool is_axiom) return parent->get_num_operator_preconditions(index, is_axiom); } - return negated_axioms[index-negated_axioms_start_index].condition.size(); + return negated_axioms[index - negated_axioms_start_index].condition.size(); } FactPair NegatedAxiomsTask::get_operator_precondition( - int op_index, int fact_index, bool is_axiom) const { + int op_index, int fact_index, bool is_axiom) const { if (!is_axiom || (op_index < negated_axioms_start_index)) { return parent->get_operator_precondition(op_index, fact_index, is_axiom); } - return negated_axioms[op_index-negated_axioms_start_index].condition[fact_index]; + return negated_axioms[op_index - negated_axioms_start_index].condition[fact_index]; } int NegatedAxiomsTask::get_num_operator_effects(int op_index, bool is_axiom) const { @@ -302,7 +298,7 @@ int NegatedAxiomsTask::get_num_operator_effects(int op_index, bool is_axiom) con } int NegatedAxiomsTask::get_num_operator_effect_conditions( - int op_index, int eff_index, bool is_axiom) const { + int op_index, int eff_index, bool is_axiom) const { if (!is_axiom || op_index < negated_axioms_start_index) { return parent->get_num_operator_effect_conditions(op_index, eff_index, is_axiom); } @@ -311,19 +307,19 @@ int NegatedAxiomsTask::get_num_operator_effect_conditions( } FactPair NegatedAxiomsTask::get_operator_effect_condition( - int op_index, int eff_index, int cond_index, bool is_axiom) const { + int op_index, int eff_index, int cond_index, bool is_axiom) const { assert(!is_axiom || op_index < negated_axioms_start_index); return parent->get_operator_effect_condition(op_index, eff_index, cond_index, is_axiom); } FactPair NegatedAxiomsTask::get_operator_effect( - int op_index, int eff_index, bool is_axiom) const { + int op_index, int eff_index, bool is_axiom) const { if (!is_axiom || op_index < negated_axioms_start_index) { return parent->get_operator_effect(op_index, eff_index, is_axiom); } assert(eff_index == 0); - return negated_axioms[op_index-negated_axioms_start_index].head; + return negated_axioms[op_index - negated_axioms_start_index].head; } int NegatedAxiomsTask::convert_operator_index_to_parent(int index) const { diff --git a/src/search/tasks/negated_axioms_task.h b/src/search/tasks/negated_axioms_task.h index 6f8e3c8a00..b722ec0696 100644 --- a/src/search/tasks/negated_axioms_task.h +++ b/src/search/tasks/negated_axioms_task.h @@ -44,14 +44,14 @@ class NegatedAxiomsTask : public DelegatingTask { virtual std::string get_operator_name(int index, bool is_axiom) const override; virtual int get_num_operator_preconditions(int index, bool is_axiom) const override; virtual FactPair get_operator_precondition( - int op_index, int fact_index, bool is_axiom) const override; + int op_index, int fact_index, bool is_axiom) const override; virtual int get_num_operator_effects(int op_index, bool is_axiom) const override; virtual int get_num_operator_effect_conditions( - int op_index, int eff_index, bool is_axiom) const override; + int op_index, int eff_index, bool is_axiom) const override; virtual FactPair get_operator_effect_condition( - int op_index, int eff_index, int cond_index, bool is_axiom) const override; + int op_index, int eff_index, int cond_index, bool is_axiom) const override; virtual FactPair get_operator_effect( - int op_index, int eff_index, bool is_axiom) const override; + int op_index, int eff_index, bool is_axiom) const override; // TODO: Is this only called for actual operators or also axioms? I assume so because there is no bool is_axiom... virtual int convert_operator_index_to_parent(int index) const override;