Skip to content

Commit

Permalink
improved get_sorted_vector, rename are_equal to is_structurally_equiv…
Browse files Browse the repository at this point in the history
…alent_to
  • Loading branch information
drexlerd committed Jan 2, 2024
1 parent 52ceacf commit 8418cb9
Show file tree
Hide file tree
Showing 42 changed files with 75 additions and 73 deletions.
6 changes: 4 additions & 2 deletions include/common/collections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_COLLECTIONS_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_COLLECTIONS_HPP_

#include <boost/container/small_vector.hpp>

#include <algorithm>
#include <vector>

Expand All @@ -29,8 +31,8 @@ namespace loki {
/// @param vec
/// @return
template<typename Collection>
std::vector<typename Collection::value_type> get_sorted_vector(const Collection& collection) {
std::vector<typename Collection::value_type> result(collection.begin(), collection.end());
boost::container::small_vector<typename Collection::value_type,100> get_sorted_vector(const Collection& collection) {
boost::container::small_vector<typename Collection::value_type,100> result(collection.begin(), collection.end());
std::sort(result.begin(), result.end());
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion include/common/pddl/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Base {
constexpr const auto& self() const { return static_cast<Derived const&>(*this); }

bool operator==(const Base& other) const {
return self().are_equal_impl(other.self());
return self().is_structurally_equivalent_to_impl(other.self());
}

bool operator!=(const Base& other) const {
Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ActionImpl : public Base<ActionImpl> {

public:
/// @brief Test for structural equivalence
bool are_equal_impl(const ActionImpl& other) const;
bool is_structurally_equivalent_to_impl(const ActionImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/atom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AtomImpl : public Base<AtomImpl> {
AtomImpl(int identifier, Predicate predicate, TermList terms);

/// @brief Test for semantic equivalence
bool are_equal_impl(const AtomImpl& other) const;
bool is_structurally_equivalent_to_impl(const AtomImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
14 changes: 7 additions & 7 deletions include/domain/pddl/conditions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ConditionLiteralImpl : public Base<ConditionLiteralImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionLiteralImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionLiteralImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -65,7 +65,7 @@ class ConditionAndImpl : public Base<ConditionAndImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionAndImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionAndImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -84,7 +84,7 @@ class ConditionOrImpl : public Base<ConditionOrImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionOrImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionOrImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -103,7 +103,7 @@ class ConditionNotImpl : public Base<ConditionNotImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionNotImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionNotImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -123,7 +123,7 @@ class ConditionImplyImpl : public Base<ConditionNotImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionImplyImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionImplyImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -144,7 +144,7 @@ class ConditionExistsImpl : public Base<ConditionExistsImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionExistsImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionExistsImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -165,7 +165,7 @@ class ConditionForallImpl : public Base<ConditionForallImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const ConditionForallImpl& other) const;
bool is_structurally_equivalent_to_impl(const ConditionForallImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/derived_predicate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DerivedPredicateImpl : public Base<DerivedPredicateImpl> {

public:
/// @brief Test for structural equivalence
bool are_equal_impl(const DerivedPredicateImpl& other) const;
bool is_structurally_equivalent_to_impl(const DerivedPredicateImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DomainImpl : public Base<DomainImpl> {

public:
/// @brief Test for structural equivalence
bool are_equal_impl(const DomainImpl& other) const;
bool is_structurally_equivalent_to_impl(const DomainImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
10 changes: 5 additions & 5 deletions include/domain/pddl/effects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class EffectLiteralImpl : public Base<EffectLiteralImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const EffectLiteralImpl& other) const;
bool is_structurally_equivalent_to_impl(const EffectLiteralImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -74,7 +74,7 @@ class EffectAndImpl : public Base<EffectAndImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const EffectAndImpl& other) const;
bool is_structurally_equivalent_to_impl(const EffectAndImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -95,7 +95,7 @@ class EffectNumericImpl : public Base<EffectNumericImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const EffectNumericImpl& other) const;
bool is_structurally_equivalent_to_impl(const EffectNumericImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -117,7 +117,7 @@ class EffectConditionalForallImpl : public Base<EffectConditionalForallImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const EffectConditionalForallImpl& other) const;
bool is_structurally_equivalent_to_impl(const EffectConditionalForallImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -138,7 +138,7 @@ class EffectConditionalWhenImpl : public Base<EffectConditionalWhenImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const EffectConditionalWhenImpl& other) const;
bool is_structurally_equivalent_to_impl(const EffectConditionalWhenImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FunctionImpl : public Base<FunctionImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const FunctionImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
10 changes: 5 additions & 5 deletions include/domain/pddl/function_expressions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FunctionExpressionNumberImpl : public Base<FunctionExpressionNumberImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const FunctionExpressionNumberImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionExpressionNumberImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -86,7 +86,7 @@ class FunctionExpressionBinaryOperatorImpl : public Base<FunctionExpressionBinar
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const FunctionExpressionBinaryOperatorImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionExpressionBinaryOperatorImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -110,7 +110,7 @@ class FunctionExpressionMultiOperatorImpl : public Base<FunctionExpressionMultiO
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const FunctionExpressionMultiOperatorImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionExpressionMultiOperatorImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -130,7 +130,7 @@ class FunctionExpressionMinusImpl : public Base<FunctionExpressionMinusImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const FunctionExpressionMinusImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionExpressionMinusImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -149,7 +149,7 @@ class FunctionExpressionFunctionImpl : public Base<FunctionExpressionFunctionImp
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const FunctionExpressionFunctionImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionExpressionFunctionImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/function_skeleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FunctionSkeletonImpl : public Base<FunctionSkeletonImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const FunctionSkeletonImpl& other) const;
bool is_structurally_equivalent_to_impl(const FunctionSkeletonImpl& other) const;
size_t hash_impl() const;
/// @brief Returns a string representation where typing is assumed to be true.
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;
Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LiteralImpl : public Base<LiteralImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const LiteralImpl& other) const;
bool is_structurally_equivalent_to_impl(const LiteralImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ObjectImpl : public Base<ObjectImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const ObjectImpl& other) const;
bool is_structurally_equivalent_to_impl(const ObjectImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ParameterImpl : public Base<ParameterImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const ParameterImpl& other) const;
bool is_structurally_equivalent_to_impl(const ParameterImpl& other) const;
size_t hash_impl() const;
/// @brief Returns a string representation where typing is assumed to be true.
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;
Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/predicate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PredicateImpl : public Base<PredicateImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const PredicateImpl& other) const;
bool is_structurally_equivalent_to_impl(const PredicateImpl& other) const;
size_t hash_impl() const;
/// @brief Returns a string representation where typing is assumed to be true.
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;
Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/requirements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RequirementsImpl : public Base<RequirementsImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const RequirementsImpl& other) const;
bool is_structurally_equivalent_to_impl(const RequirementsImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
4 changes: 2 additions & 2 deletions include/domain/pddl/term.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TermObjectImpl : public Base<TermObjectImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const TermObjectImpl& other) const;
bool is_structurally_equivalent_to_impl(const TermObjectImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand All @@ -60,7 +60,7 @@ class TermVariableImpl : public Base<TermVariableImpl> {
friend class loki::PersistentFactory;

public:
bool are_equal_impl(const TermVariableImpl& other) const;
bool is_structurally_equivalent_to_impl(const TermVariableImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TypeImpl : public Base<TypeImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const TypeImpl& other) const;
bool is_structurally_equivalent_to_impl(const TypeImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/domain/pddl/variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VariableImpl : public Base<VariableImpl> {

public:
/// @brief Test for semantic equivalence
bool are_equal_impl(const VariableImpl& other) const;
bool is_structurally_equivalent_to_impl(const VariableImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/problem/pddl/metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OptimizationMetricImpl : public Base<OptimizationMetricImpl> {
OptimizationMetricImpl(int identifier, OptimizationMetricEnum optimization_metric, FunctionExpression function_expression);

/// @brief Test for semantic equivalence
bool are_equal_impl(const OptimizationMetricImpl& other) const;
bool is_structurally_equivalent_to_impl(const OptimizationMetricImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/problem/pddl/numeric_fluent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NumericFluentImpl : public Base<NumericFluentImpl> {
NumericFluentImpl(int identifier, Function function, double number);

/// @brief Test for semantic equivalence
bool are_equal_impl(const NumericFluentImpl& other) const;
bool is_structurally_equivalent_to_impl(const NumericFluentImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion include/problem/pddl/problem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ProblemImpl : public Base<ProblemImpl> {
ProblemImpl(int identifier, Domain domain, std::string name, Requirements requirements, ObjectList objects, LiteralList initial_literals, NumericFluentList numeric_fluents, Condition goal_condition, std::optional<OptimizationMetric> optimization_metric);

/// @brief Test for semantic equivalence
bool are_equal_impl(const ProblemImpl& other) const;
bool is_structurally_equivalent_to_impl(const ProblemImpl& other) const;
size_t hash_impl() const;
void str_impl(std::ostringstream& out, const FormattingOptions& options) const;

Expand Down
2 changes: 1 addition & 1 deletion src/domain/pddl/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ActionImpl::ActionImpl(int identifier, std::string name, ParameterList parameter
{
}

bool ActionImpl::are_equal_impl(const ActionImpl& other) const {
bool ActionImpl::is_structurally_equivalent_to_impl(const ActionImpl& other) const {
return (m_name == other.m_name)
&& (get_sorted_vector(m_parameters) == get_sorted_vector(other.m_parameters))
&& (*m_condition == *other.m_condition)
Expand Down
2 changes: 1 addition & 1 deletion src/domain/pddl/atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AtomImpl::AtomImpl(int identifier, Predicate predicate, TermList terms)
{
}

bool AtomImpl::are_equal_impl(const AtomImpl& other) const {
bool AtomImpl::is_structurally_equivalent_to_impl(const AtomImpl& other) const {
return (m_predicate == other.m_predicate)
&& (m_terms == other.m_terms);
}
Expand Down
Loading

0 comments on commit 8418cb9

Please sign in to comment.