diff --git a/include/loki/details/pddl/axiom.hpp b/include/loki/details/pddl/axiom.hpp index 0d837bd8..e7da5a70 100644 --- a/include/loki/details/pddl/axiom.hpp +++ b/include/loki/details/pddl/axiom.hpp @@ -32,8 +32,9 @@ class AxiomImpl : public Base std::string m_derived_predicate_name; ParameterList m_parameters; Condition m_condition; + size_t m_num_parameters_to_ground_head; - AxiomImpl(size_t identifier, std::string derived_predicate_name, ParameterList parameters, Condition condition); + AxiomImpl(size_t identifier, std::string derived_predicate_name, ParameterList parameters, Condition condition, size_t num_parameters_to_ground_head); // Give access to the constructor. friend class PDDLFactory, EqualTo>; @@ -50,6 +51,7 @@ class AxiomImpl : public Base const std::string& get_derived_predicate_name() const; const ParameterList& get_parameters() const; const Condition& get_condition() const; + size_t get_num_parameters_to_ground_head() const; }; } diff --git a/include/loki/details/pddl/factories.hpp b/include/loki/details/pddl/factories.hpp index 58e80a09..0c274fa8 100644 --- a/include/loki/details/pddl/factories.hpp +++ b/include/loki/details/pddl/factories.hpp @@ -264,9 +264,9 @@ class PDDLFactories return actions.get_or_create(std::move(name), std::move(original_arity), std::move(parameters), std::move(condition), std::move(effect)); } - Axiom get_or_create_axiom(std::string derived_predicate_name, ParameterList parameters, Condition condition) + Axiom get_or_create_axiom(std::string derived_predicate_name, ParameterList parameters, Condition condition, size_t num_parameters_to_ground_head) { - return axioms.get_or_create(std::move(derived_predicate_name), std::move(parameters), std::move(condition)); + return axioms.get_or_create(std::move(derived_predicate_name), std::move(parameters), std::move(condition), num_parameters_to_ground_head); } OptimizationMetric get_or_create_optimization_metric(OptimizationMetricEnum metric, FunctionExpression function_expression) diff --git a/src/pddl/axiom.cpp b/src/pddl/axiom.cpp index 76a09bfb..2ca24e71 100644 --- a/src/pddl/axiom.cpp +++ b/src/pddl/axiom.cpp @@ -28,11 +28,16 @@ namespace loki { -AxiomImpl::AxiomImpl(size_t identifier, std::string derived_predicate_name, ParameterList parameters, Condition condition) : +AxiomImpl::AxiomImpl(size_t identifier, + std::string derived_predicate_name, + ParameterList parameters, + Condition condition, + size_t num_parameters_to_ground_head) : Base(identifier), m_derived_predicate_name(std::move(derived_predicate_name)), m_parameters(std::move(parameters)), - m_condition(std::move(condition)) + m_condition(std::move(condition)), + m_num_parameters_to_ground_head(num_parameters_to_ground_head) { } @@ -68,4 +73,6 @@ const Condition& AxiomImpl::get_condition() const { return m_condition; } const ParameterList& AxiomImpl::get_parameters() const { return m_parameters; } +size_t AxiomImpl::get_num_parameters_to_ground_head() const { return m_num_parameters_to_ground_head; } + } diff --git a/src/pddl/parser/structure.cpp b/src/pddl/parser/structure.cpp index 36a2d40e..e374435a 100644 --- a/src/pddl/parser/structure.cpp +++ b/src/pddl/parser/structure.cpp @@ -113,13 +113,14 @@ Axiom parse(const ast::Axiom& node, Context& context) variables.erase(axiom_parameter->get_variable()); } // Turn free variables not mentioned in the parameter list into parameters + // Those parameters must be appended to the parameter list for (const auto variable : variables) { const auto base_types = TypeList { context.factories.get_or_create_type("object", TypeList {}) }; parameters.push_back(context.factories.get_or_create_parameter(variable, base_types)); } - const auto axiom = context.factories.get_or_create_axiom(predicate_name, parameters, condition); + const auto axiom = context.factories.get_or_create_axiom(predicate_name, parameters, condition, parameters.size()); context.positions.push_back(axiom, node); return axiom; }