Skip to content

Commit

Permalink
reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDold committed Jul 12, 2024
1 parent c44a369 commit a874b37
Show file tree
Hide file tree
Showing 31 changed files with 171 additions and 201 deletions.
5 changes: 2 additions & 3 deletions src/search/abstract_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ ostream &operator<<(ostream &os, const FactPair &fact_pair) {
return os;
}


TaskIndependentAbstractTask::TaskIndependentAbstractTask()
: TaskIndependentComponent("abstract_task", utils::Verbosity::NORMAL) {
}

static class TaskIndependentAbstractTaskCategoryPlugin : public plugins::TypedCategoryPlugin<TaskIndependentAbstractTask> {
static class AbstractTaskCategoryPlugin : public plugins::TypedCategoryPlugin<AbstractTask> {
public:
TaskIndependentAbstractTaskCategoryPlugin() : TypedCategoryPlugin("AbstractTask") {
AbstractTaskCategoryPlugin() : TypedCategoryPlugin("AbstractTask") {
// TODO: Replace empty string by synopsis for the wiki page.
document_synopsis("");
}
Expand Down
1 change: 0 additions & 1 deletion src/search/abstract_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "algorithms/subscriber.h"
#include "utils/hash.h"
#include "utils/logging.h"

#include <memory>
#include <string>
Expand Down
19 changes: 7 additions & 12 deletions src/search/evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Evaluator::Evaluator(
bool use_for_reporting_minima, bool use_for_boosting,
bool use_for_counting_evaluations, const string &description,
utils::Verbosity verbosity)
: use_for_reporting_minima(use_for_reporting_minima),
: description(description),
use_for_reporting_minima(use_for_reporting_minima),
use_for_boosting(use_for_boosting),
use_for_counting_evaluations(use_for_counting_evaluations),
description(description),
log(utils::get_log_for_verbosity(verbosity)) {
}

Expand Down Expand Up @@ -74,23 +74,18 @@ int Evaluator::get_cached_estimate(const State &) const {
ABORT("Called get_cached_estimate when estimate is not cached.");
}

TaskIndependentEvaluator::TaskIndependentEvaluator(const string &name,
utils::Verbosity verbosity,
bool use_for_reporting_minima,
bool use_for_boosting,
bool use_for_counting_evaluations)
: TaskIndependentComponent(name, verbosity),
TaskIndependentEvaluator::TaskIndependentEvaluator(
bool use_for_reporting_minima, bool use_for_boosting,
bool use_for_counting_evaluations,
const std::string &description, utils::Verbosity verbosity)
: TaskIndependentComponent(description, verbosity),
use_for_reporting_minima(use_for_reporting_minima),
use_for_boosting(use_for_boosting),
use_for_counting_evaluations(use_for_counting_evaluations) {
}

void add_evaluator_options_to_feature(
plugins::Feature &feature, const string &description) {
//feature.add_option<string>(
// "description",
// "description used to identify evaluator in logs",
// "\"" + description + "\"");
utils::add_log_options_to_feature(feature, description);
}

Expand Down
10 changes: 4 additions & 6 deletions src/search/evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class Options;
}

class Evaluator : public Component {
const std::string description;
const bool use_for_reporting_minima;
const bool use_for_boosting;
const bool use_for_counting_evaluations;
protected:
const std::string description;
mutable utils::LogProxy log;
public:
Evaluator(
Expand Down Expand Up @@ -107,11 +107,9 @@ class TaskIndependentEvaluator : public TaskIndependentComponent {
const bool use_for_counting_evaluations;
public:
explicit TaskIndependentEvaluator(
const std::string &name,
utils::Verbosity verbosity,
bool use_for_reporting_minima,
bool use_for_boosting,
bool use_for_counting_evaluations);
bool use_for_reporting_minima, bool use_for_boosting,
bool use_for_counting_evaluations,
const std::string &description, utils::Verbosity verbosity);
virtual ~TaskIndependentEvaluator() = default;

virtual std::shared_ptr<Evaluator>
Expand Down
5 changes: 2 additions & 3 deletions src/search/evaluators/combining_evaluator.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "combining_evaluator.h"

#include "../evaluation_context.h"
#include "../evaluation_result.h"

#include "../plugins/plugin.h"

#include <utility>

using namespace std;

namespace combining_evaluator {
Expand Down Expand Up @@ -58,7 +57,7 @@ TaskIndependentCombiningEvaluator::TaskIndependentCombiningEvaluator(
vector<shared_ptr<TaskIndependentEvaluator>> subevaluators,
const string &description,
utils::Verbosity verbosity)
: TaskIndependentEvaluator(description, verbosity, false, false, false),
: TaskIndependentEvaluator(false, false, false, description, verbosity),
subevaluators(subevaluators) {
}

Expand Down
3 changes: 1 addition & 2 deletions src/search/evaluators/combining_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ get_combining_evaluator_arguments_from_options(
const plugins::Options &opts);




class TaskIndependentCombiningEvaluator : public TaskIndependentEvaluator {
protected:
std::vector<std::shared_ptr<TaskIndependentEvaluator>> subevaluators;
Expand All @@ -65,4 +63,5 @@ class TaskIndependentCombiningEvaluator : public TaskIndependentEvaluator {
virtual ~TaskIndependentCombiningEvaluator() override = default;
};
}

#endif
17 changes: 9 additions & 8 deletions src/search/evaluators/g_evaluator.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "g_evaluator.h"

#include "../evaluation_context.h"

#include "../evaluation_result.h"
#include "../plugins/plugin.h"

using namespace std;
Expand All @@ -20,14 +20,14 @@ EvaluationResult GEvaluator::compute_result(EvaluationContext &eval_context) {
}



TaskIndependentGEvaluator::TaskIndependentGEvaluator(const string &name,
utils::Verbosity verbosity)
: TaskIndependentEvaluator(name,
verbosity,
: TaskIndependentEvaluator(
false,
false,
false,
false) {
name,
verbosity) {
}

using ConcreteProduct = GEvaluator;
Expand Down Expand Up @@ -60,9 +60,10 @@ std::shared_ptr<ConcreteProduct> Concrete::create_ts([[maybe_unused]] const shar
}


class TaskIndependentGEvaluatorFeature : public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentGEvaluator> {
class GEvaluatorFeature
: public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentGEvaluator> {
public:
TaskIndependentGEvaluatorFeature() : TypedFeature("g") {
GEvaluatorFeature() : TypedFeature("g") {
document_subcategory("evaluators_basic");
document_title("g-value evaluator");
document_synopsis(
Expand All @@ -79,5 +80,5 @@ class TaskIndependentGEvaluatorFeature : public plugins::TypedFeature<TaskIndepe
}
};

static plugins::FeaturePlugin<TaskIndependentGEvaluatorFeature> _plugin;
static plugins::FeaturePlugin<GEvaluatorFeature> _plugin;
}
7 changes: 4 additions & 3 deletions src/search/evaluators/sum_evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../plugins/plugin.h"

#include <cassert>
#include <utility>

using namespace std;

Expand All @@ -12,7 +11,7 @@ SumEvaluator::SumEvaluator(
const vector<shared_ptr<Evaluator>> &evals,
const string &description, utils::Verbosity verbosity)
: CombiningEvaluator(evals, description, verbosity) {
}
}

int SumEvaluator::combine_values(const vector<int> &values) {
int result = 0;
Expand Down Expand Up @@ -71,12 +70,14 @@ std::shared_ptr<ConcreteProduct> Concrete::create_ts(const shared_ptr <AbstractT
}


class SumEvaluatorFeature : public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentSumEvaluator> {
class SumEvaluatorFeature
: public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentSumEvaluator> {
public:
SumEvaluatorFeature() : TypedFeature("sum") {
document_subcategory("evaluators_basic");
document_title("Sum evaluator");
document_synopsis("Calculates the sum of the sub-evaluators.");

combining_evaluator::add_combining_evaluator_options_to_feature(
*this, "sum");
}
Expand Down
2 changes: 1 addition & 1 deletion src/search/evaluators/sum_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TaskIndependentSumEvaluator : public combining_evaluator::TaskIndependentC
protected:
std::string get_product_name() const override {return "SumEvaluator";}
public:
explicit TaskIndependentSumEvaluator(
TaskIndependentSumEvaluator(
std::vector<std::shared_ptr<TaskIndependentEvaluator>> subevaluators,
const std::string &name,
utils::Verbosity verbosity);
Expand Down
12 changes: 7 additions & 5 deletions src/search/evaluators/weighted_evaluator.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "weighted_evaluator.h"

#include "../evaluation_context.h"
#include "../evaluation_result.h"
#include "../plugins/plugin.h"
#include "../utils/math.h"

#include <cstdlib>
#include <sstream>

using namespace std;
Expand Down Expand Up @@ -43,10 +44,10 @@ void WeightedEvaluator::get_path_dependent_evaluators(set<Evaluator *> &evals) {
TaskIndependentWeightedEvaluator::TaskIndependentWeightedEvaluator(
shared_ptr<TaskIndependentEvaluator> evaluator,
int weight,
const string &name,
const string &description,
utils::Verbosity verbosity)
: TaskIndependentEvaluator(name, verbosity, false, false,
false),
: TaskIndependentEvaluator(false, false,
false, description, verbosity),
evaluator(evaluator),
weight(weight) {
}
Expand Down Expand Up @@ -85,7 +86,8 @@ std::shared_ptr<ConcreteProduct> Concrete::create_ts(const shared_ptr <AbstractT
}


class WeightedEvaluatorFeature : public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentWeightedEvaluator> {
class WeightedEvaluatorFeature
: public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentWeightedEvaluator> {
public:
WeightedEvaluatorFeature() : TypedFeature("weight") {
document_subcategory("evaluators_basic");
Expand Down
2 changes: 1 addition & 1 deletion src/search/evaluators/weighted_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TaskIndependentWeightedEvaluator : public TaskIndependentEvaluator {
explicit TaskIndependentWeightedEvaluator(
std::shared_ptr<TaskIndependentEvaluator> evaluator,
int weight,
const std::string &name,
const std::string &description,
utils::Verbosity verbosity);

virtual ~TaskIndependentWeightedEvaluator() override = default;
Expand Down
15 changes: 7 additions & 8 deletions src/search/heuristic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

using namespace std;
Heuristic::Heuristic(
const shared_ptr<AbstractTask> task,
const shared_ptr<AbstractTask> &transform,
bool cache_estimates, const string &description,
utils::Verbosity verbosity)
: Evaluator(true, true, true, description, verbosity),
heuristic_cache(HEntry(NO_VALUE, true)), //TODO: is true really a good idea here?
cache_evaluator_values(cache_estimates),
task(task),
task(transform),
task_proxy(*task) {
}

Expand Down Expand Up @@ -119,11 +119,10 @@ int Heuristic::get_cached_estimate(const State &state) const {
return heuristic_cache[state].h;
}

TaskIndependentHeuristic::TaskIndependentHeuristic(const string &name,
utils::Verbosity verbosity,
const shared_ptr<TaskIndependentAbstractTask> task_transformation,
bool cache_evaluator_values
)
: TaskIndependentEvaluator(name, verbosity, true, true, true),
TaskIndependentHeuristic::TaskIndependentHeuristic(const shared_ptr<TaskIndependentAbstractTask> task_transformation,
bool cache_evaluator_values,
const string &description,
utils::Verbosity verbosity)
: TaskIndependentEvaluator(true, true, true, description, verbosity),
cache_evaluator_values(cache_evaluator_values), task_transformation(task_transformation) {
}
14 changes: 6 additions & 8 deletions src/search/heuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ class Heuristic : public Evaluator {

public:
Heuristic(
const std::shared_ptr<AbstractTask> task,
const std::shared_ptr<AbstractTask> &transform,
bool cache_estimates, const std::string &description,
utils::Verbosity verbosity
);
utils::Verbosity verbosity);
virtual ~Heuristic() override;

virtual void get_path_dependent_evaluators(
Expand All @@ -91,16 +90,15 @@ class Heuristic : public Evaluator {
virtual int get_cached_estimate(const State &state) const override;
};


class TaskIndependentHeuristic : public TaskIndependentEvaluator {
protected:
bool cache_evaluator_values;
std::shared_ptr<TaskIndependentAbstractTask> task_transformation;
public:
explicit TaskIndependentHeuristic(const std::string &name,
utils::Verbosity verbosity,
const std::shared_ptr<TaskIndependentAbstractTask> task_transformation,
bool cache_evaluator_values);
TaskIndependentHeuristic(const std::shared_ptr<TaskIndependentAbstractTask> task_transformation,
bool cache_evaluator_values,
const std::string &description,
utils::Verbosity verbosity);
virtual ~TaskIndependentHeuristic() = default;
};

Expand Down
14 changes: 6 additions & 8 deletions src/search/heuristics/blind_search_heuristic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@ int BlindSearchHeuristic::compute_heuristic(const State &ancestor_state) {
}




TaskIndependentBlindSearchHeuristic::TaskIndependentBlindSearchHeuristic(
const shared_ptr<TaskIndependentAbstractTask> task_transformation,
bool cache_evaluator_values,
const string &name,
const string &description,
utils::Verbosity verbosity)
: TaskIndependentHeuristic(name, verbosity, task_transformation, cache_evaluator_values) {
: TaskIndependentHeuristic(task_transformation, cache_evaluator_values, description, verbosity) {
}

TaskIndependentBlindSearchHeuristic::~TaskIndependentBlindSearchHeuristic() {
}



using ConcreteProduct = BlindSearchHeuristic;
using AbstractProduct = Evaluator;
using Concrete = TaskIndependentBlindSearchHeuristic;
Expand Down Expand Up @@ -79,13 +76,14 @@ std::shared_ptr<ConcreteProduct> Concrete::create_ts(
task, component_map,
depth >= 0 ? depth + 1 : depth),
cache_evaluator_values,
description,
verbosity
description,
verbosity
);
}


class BlindSearchHeuristicFeature : public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentBlindSearchHeuristic> {
class BlindSearchHeuristicFeature
: public plugins::TypedFeature<TaskIndependentEvaluator, TaskIndependentBlindSearchHeuristic> {
public:
BlindSearchHeuristicFeature() : TypedFeature("blind") {
document_title("Blind heuristic");
Expand Down
4 changes: 2 additions & 2 deletions src/search/heuristics/blind_search_heuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class TaskIndependentBlindSearchHeuristic : public TaskIndependentHeuristic {
protected:
std::string get_product_name() const override {return "BlindSearchHeuristic";}
public:
explicit TaskIndependentBlindSearchHeuristic(
TaskIndependentBlindSearchHeuristic(
const std::shared_ptr<TaskIndependentAbstractTask> task_transformation,
bool cache_evaluator_values,
const std::string &name,
const std::string &description,
utils::Verbosity verbosity);

virtual ~TaskIndependentBlindSearchHeuristic() override;
Expand Down
Loading

0 comments on commit a874b37

Please sign in to comment.