Skip to content

Commit

Permalink
added back function to encode number of head parameters in axiom
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed May 29, 2024
1 parent 3e4c3b6 commit c1b7e88
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion include/loki/details/pddl/axiom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class AxiomImpl : public Base<AxiomImpl>
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<AxiomImpl, Hash<AxiomImpl*>, EqualTo<AxiomImpl*>>;
Expand All @@ -50,6 +51,7 @@ class AxiomImpl : public Base<AxiomImpl>
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;
};

}
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/factories.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ class PDDLFactories
return actions.get_or_create<ActionImpl>(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<AxiomImpl>(std::move(derived_predicate_name), std::move(parameters), std::move(condition));
return axioms.get_or_create<AxiomImpl>(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)
Expand Down
11 changes: 9 additions & 2 deletions src/pddl/axiom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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; }

}
3 changes: 2 additions & 1 deletion src/pddl/parser/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c1b7e88

Please sign in to comment.