10 #ifndef SYMBOLIC_ACTION_H_
11 #define SYMBOLIC_ACTION_H_
19 #include "symbolic/formula.h"
20 #include "symbolic/object.h"
21 #include "symbolic/proposition.h"
22 #include "symbolic/state.h"
23 #include "symbolic/utils/parameter_generator.h"
40 Action(
const Pddl& pddl,
const VAL::operator_* symbol);
43 Action(
const Pddl& pddl,
const std::string& action_call);
45 bool IsValid(
const State& state,
const std::vector<Object>& arguments)
const {
46 return Preconditions_(state, arguments);
50 const std::vector<Object>& arguments)
const {
51 return Preconditions_(state, arguments);
54 State Apply(
const State& state,
const std::vector<Object>& arguments)
const;
56 bool Apply(
const std::vector<Object>& arguments,
State* state)
const {
57 return static_cast<bool>(Apply_(arguments, state));
61 const std::vector<Object>& arguments)
const;
68 return ApplyPartial_(arguments, state);
71 const VAL::operator_* symbol()
const {
return symbol_; }
73 const Pddl& pddl()
const {
return *pddl_; }
75 const std::string& name()
const {
return name_; }
77 const std::vector<Object>& parameters()
const {
return parameters_; }
79 const ParameterGenerator& parameter_generator()
const {
return param_gen_; }
81 const Formula& preconditions()
const {
return Preconditions_; }
83 const VAL::effect_lists* postconditions()
const;
85 std::string to_string()
const;
87 std::string to_string(
const std::vector<Object>& arguments)
const;
89 static std::pair<Action, std::vector<Object>> Parse(
90 const Pddl& pddl,
const std::string& action_call);
92 friend bool operator<(
const Action& lhs,
const Action& rhs) {
93 return lhs.name() < rhs.name();
96 friend bool operator==(
const Action& lhs,
const Action& rhs) {
97 return lhs.name() == rhs.name();
100 friend std::ostream& operator<<(std::ostream& os,
const Action& action);
103 const VAL::operator_* symbol_ =
nullptr;
104 const Pddl* pddl_ =
nullptr;
106 std::vector<Object> parameters_;
107 ParameterGenerator param_gen_;
109 Formula Preconditions_;
110 std::function<int(
const std::vector<Object>&, State*)> Apply_;
111 std::function<int(
const std::vector<Object>&, PartialState*)> ApplyPartial_;
116 #endif // SYMBOLIC_ACTION_H_