1#ifndef SEARCH_ALGORITHM_H
2#define SEARCH_ALGORITHM_H
4#include "downward/operator_cost.h"
5#include "downward/operator_id.h"
6#include "downward/plan_manager.h"
7#include "downward/search_progress.h"
8#include "downward/search_space.h"
9#include "downward/search_statistics.h"
10#include "downward/state_registry.h"
11#include "downward/task_proxy.h"
13#include "downward/utils/logging.h"
17namespace ordered_set {
22namespace successor_generator {
23class SuccessorGenerator;
26enum SearchStatus { IN_PROGRESS, TIMEOUT, FAILED, SOLVED };
28class SearchAlgorithm {
29 std::string description;
37 const std::shared_ptr<AbstractTask> task;
41 mutable utils::LogProxy log;
42 PlanManager plan_manager;
43 StateRegistry state_registry;
44 const successor_generator::SuccessorGenerator& successor_generator;
45 SearchSpace search_space;
46 SearchProgress search_progress;
47 SearchStatistics statistics;
49 OperatorCost cost_type;
53 virtual void initialize() {}
54 virtual SearchStatus step() = 0;
56 void set_plan(
const Plan& plan);
57 bool check_goal_and_set_plan(
const State& state);
58 int get_adjusted_cost(
const OperatorProxy& op)
const;
62 OperatorCost cost_type,
65 const std::string& description,
66 utils::Verbosity verbosity);
68 virtual ~SearchAlgorithm();
69 virtual void print_statistics()
const = 0;
70 virtual void save_plan_if_necessary();
71 bool found_solution()
const;
72 SearchStatus get_status()
const;
73 const Plan& get_plan()
const;
75 const SearchStatistics& get_statistics()
const {
return statistics; }
76 void set_bound(
int b) { bound = b; }
77 int get_bound() {
return bound; }
78 PlanManager& get_plan_manager() {
return plan_manager; }
79 std::string get_description() {
return description; }
86print_initial_evaluator_values(
const EvaluationContext& eval_context);
88extern void collect_preferred_operators(
89 EvaluationContext& eval_context,
90 Evaluator* preferred_operator_evaluator,
91 ordered_set::OrderedSet<OperatorID>& preferred_operators);