Skip to content

Commit

Permalink
undo last change
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed May 28, 2024
1 parent 596a4ea commit 3da459a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 36 deletions.
9 changes: 1 addition & 8 deletions include/loki/details/pddl/axiom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ class AxiomImpl : public Base<AxiomImpl>
ParameterList m_parameters;
Condition m_condition;

// Since translations might add additional parameters,
// we allow keeping track of parameters that are needed
// to ground the atom in the head of the axiom
size_t m_num_parameters_to_ground_head;

AxiomImpl(size_t identifier, std::string derived_predicate_name, ParameterList parameters, Condition condition, size_t num_parameters_to_ground_head);
AxiomImpl(size_t identifier, std::string derived_predicate_name, ParameterList parameters, Condition condition);

// Give access to the constructor.
friend class PDDLFactory<AxiomImpl, Hash<AxiomImpl*>, EqualTo<AxiomImpl*>>;
Expand All @@ -55,8 +50,6 @@ 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, size_t num_parameters_to_ground_head)
Axiom get_or_create_axiom(std::string derived_predicate_name, ParameterList parameters, Condition condition)
{
return axioms.get_or_create<AxiomImpl>(std::move(derived_predicate_name), std::move(parameters), std::move(condition), num_parameters_to_ground_head);
return axioms.get_or_create<AxiomImpl>(std::move(derived_predicate_name), std::move(parameters), std::move(condition));
}

OptimizationMetric get_or_create_optimization_metric(OptimizationMetricEnum metric, FunctionExpression function_expression)
Expand Down
11 changes: 2 additions & 9 deletions src/pddl/axiom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@

namespace loki
{
AxiomImpl::AxiomImpl(size_t identifier,
std::string derived_predicate_name,
ParameterList parameters,
Condition condition,
size_t num_parameters_to_ground_head) :
AxiomImpl::AxiomImpl(size_t identifier, std::string derived_predicate_name, ParameterList parameters, Condition condition) :
Base(identifier),
m_derived_predicate_name(std::move(derived_predicate_name)),
m_parameters(std::move(parameters)),
m_condition(std::move(condition)),
m_num_parameters_to_ground_head(num_parameters_to_ground_head)
m_condition(std::move(condition))
{
}

Expand Down Expand Up @@ -73,6 +68,4 @@ 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; }

}
21 changes: 4 additions & 17 deletions src/pddl/parser/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,13 @@ Axiom parse(const ast::Axiom& node, Context& context)
}

auto result_parameters = ParameterList {};
// Create parameters for head.
for (const auto variable : variables)
{
if (parameter_variable_to_types.count(variable))
{
const auto base_types = parameter_variable_to_types.at(variable);
result_parameters.push_back(context.factories.get_or_create_parameter(variable, base_types));
}
}
const auto num_parameters_to_ground_head = result_parameters.size();
// Create parameters for remaining free variables
for (const auto variable : variables)
{
if (!parameter_variable_to_types.count(variable))
{
const auto base_types = TypeList { context.factories.get_or_create_type("object", TypeList {}) };
result_parameters.push_back(context.factories.get_or_create_parameter(variable, base_types));
}
const auto base_types = parameter_variable_to_types.count(variable) ? parameter_variable_to_types.at(variable) :
TypeList { context.factories.get_or_create_type("object", TypeList {}) };
result_parameters.push_back(context.factories.get_or_create_parameter(variable, base_types));
}
const auto axiom = context.factories.get_or_create_axiom(predicate_name, result_parameters, condition, num_parameters_to_ground_head);
const auto axiom = context.factories.get_or_create_axiom(predicate_name, result_parameters, condition);
context.positions.push_back(axiom, node);
return axiom;
}
Expand Down

0 comments on commit 3da459a

Please sign in to comment.