Skip to content

Commit

Permalink
[issue1082] Update LandmarkCutHeuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
grucla committed Feb 7, 2024
1 parent 0f703df commit 3172488
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/search/AAA_Mechanical_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ search
│ ├── goal_count_heuristic.h✅
│ ├── hm_heuristic.cc✅
│ ├── hm_heuristic.h✅
│ ├── lm_cut_heuristic.cc
│ ├── lm_cut_heuristic.h
│ ├── lm_cut_landmarks.cc
│ ├── lm_cut_landmarks.h
│ ├── lm_cut_heuristic.cc
│ ├── lm_cut_heuristic.h
│ ├── lm_cut_landmarks.cc
│ ├── lm_cut_landmarks.h
│ ├── max_heuristic.cc✅
│ ├── max_heuristic.h✅
│ ├── relaxation_heuristic.cc✅
Expand Down
20 changes: 14 additions & 6 deletions src/search/heuristics/lm_cut_heuristic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
using namespace std;

namespace lm_cut_heuristic {
LandmarkCutHeuristic::LandmarkCutHeuristic(const plugins::Options &opts)
: Heuristic(opts),
LandmarkCutHeuristic::LandmarkCutHeuristic(
const shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const string &name,
utils::Verbosity verbosity)
: Heuristic(transform, cache_estimates, name, verbosity),
landmark_generator(utils::make_unique_ptr<LandmarkCutLandmarks>(task_proxy)) {
if (log.is_at_least_normal()) {
log << "Initializing landmark cut heuristic..." << endl;
}
}

LandmarkCutHeuristic::~LandmarkCutHeuristic() {
}

int LandmarkCutHeuristic::compute_heuristic(const State &ancestor_state) {
State state = convert_ancestor_state(ancestor_state);
int total_cost = 0;
Expand All @@ -43,7 +44,7 @@ class LandmarkCutHeuristicFeature : public plugins::TypedFeature<Evaluator, Land
LandmarkCutHeuristicFeature() : TypedFeature("lmcut") {
document_title("Landmark-cut heuristic");

Heuristic::add_options_to_feature(*this);
Heuristic::add_options_to_feature(*this, "lmcut");

document_language_support("action costs", "supported");
document_language_support("conditional effects", "not supported");
Expand All @@ -54,6 +55,13 @@ class LandmarkCutHeuristicFeature : public plugins::TypedFeature<Evaluator, Land
document_property("safe", "yes");
document_property("preferred operators", "no");
}

virtual shared_ptr<LandmarkCutHeuristic> create_component(
const plugins::Options &opts, const utils::Context &) const override {
return plugins::make_shared_from_args_tuple_and_args<LandmarkCutHeuristic>(
Heuristic::get_heuristic_parameters_from_options(opts)
);
}
};

static plugins::FeaturePlugin<LandmarkCutHeuristicFeature> _plugin;
Expand Down
7 changes: 5 additions & 2 deletions src/search/heuristics/lm_cut_heuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ class LandmarkCutHeuristic : public Heuristic {

virtual int compute_heuristic(const State &ancestor_state) override;
public:
explicit LandmarkCutHeuristic(const plugins::Options &opts);
virtual ~LandmarkCutHeuristic() override;
LandmarkCutHeuristic(
const std::shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const std::string &name,
utils::Verbosity verbosity);
};
}

Expand Down
3 changes: 0 additions & 3 deletions src/search/heuristics/lm_cut_landmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ LandmarkCutLandmarks::LandmarkCutLandmarks(const TaskProxy &task_proxy) {
}
}

LandmarkCutLandmarks::~LandmarkCutLandmarks() {
}

void LandmarkCutLandmarks::build_relaxed_operator(const OperatorProxy &op) {
vector<RelaxedProposition *> precondition;
vector<RelaxedProposition *> effects;
Expand Down
1 change: 0 additions & 1 deletion src/search/heuristics/lm_cut_landmarks.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class LandmarkCutLandmarks {
using LandmarkCallback = std::function<void (const Landmark &, int)>;

LandmarkCutLandmarks(const TaskProxy &task_proxy);
virtual ~LandmarkCutLandmarks();

/*
Compute LM-cut landmarks for the given state.
Expand Down

0 comments on commit 3172488

Please sign in to comment.