Skip to content

Commit

Permalink
rework Hash and EqualTo. Generalized PDDLFactory to UniqueValueTypeFa…
Browse files Browse the repository at this point in the history
…ctory
  • Loading branch information
drexlerd committed Aug 11, 2024
1 parent baa9362 commit 14850d3
Show file tree
Hide file tree
Showing 50 changed files with 389 additions and 275 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.21)
# Language setup
##############################################################

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Loki

Loki is a C++17 library for efficient syntactic and semantic parsing of PDDL files. Loki implements exhaustive error handling to provide meaningful clang-style messages for syntactic, semantic, and modeling errors. The resulting PDDL objects are structurally uniquely constructed immutable pointer objects stored in persistent and continuous memory to enable hashing in constant time, equality comparison in constant time, and cache-efficient data access.
Loki is a C++20 library for syntactic and semantic parsing of PDDL files.

## Supported PDDL Requirements

Expand Down Expand Up @@ -53,9 +53,7 @@ cmake --install build --prefix=<path/to/installation-directory>

## Integration Instructions

We provide a CMake Superbuild project [here](https://github.com/drexlerd/Loki/tree/main/tests/integration/dependencies) that takes care of downloading, building, and installing Loki together and its dependencies. You can simply copy it to your project or integrate it in your own Superbuild and run it similarly to the Superbuild project from above.

TODO
We provide a CMake Superbuild project [here](https://github.com/drexlerd/Loki/tree/main/tests/integration/dependencies) that takes care of downloading, building, and installing Loki together and its dependencies. You can simply copy it to your project or integrate it in your own Superbuild and run it similarly to the Superbuild project from above. An example planning library based on Loki is available [here](https://github.com/simon-stahlberg/mimir).


## Running the Examples
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <optional>
#include <string>
Expand All @@ -45,7 +45,7 @@ class ActionImpl : public Base<ActionImpl>
std::optional<Effect> effect);

// Give access to the constructor.
friend class PDDLFactory<ActionImpl, Hash<ActionImpl*>, EqualTo<ActionImpl*>>;
friend class UniqueValueTypeFactory<ActionImpl, Hash<const ActionImpl*, true>, EqualTo<const ActionImpl*, true>>;

/// @brief Test for structural equivalence
bool is_structurally_equivalent_to_impl(const ActionImpl& other) const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/atom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -35,7 +35,7 @@ class AtomImpl : public Base<AtomImpl>
AtomImpl(size_t identifier, Predicate predicate, TermList terms);

// Give access to the constructor.
friend class PDDLFactory<AtomImpl, Hash<AtomImpl*>, EqualTo<AtomImpl*>>;
friend class UniqueValueTypeFactory<AtomImpl, Hash<const AtomImpl*, true>, EqualTo<const AtomImpl*, true>>;

/// @brief Test for semantic equivalence
bool is_structurally_equivalent_to_impl(const AtomImpl& other) const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/axiom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -37,7 +37,7 @@ class AxiomImpl : public Base<AxiomImpl>
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*>>;
friend class UniqueValueTypeFactory<AxiomImpl, Hash<const AxiomImpl*, true>, EqualTo<const AxiomImpl*, true>>;

/// @brief Test for structural equivalence
bool is_structurally_equivalent_to_impl(const AxiomImpl& other) const;
Expand Down
16 changes: 8 additions & 8 deletions include/loki/details/pddl/conditions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -36,7 +36,7 @@ class ConditionLiteralImpl : public Base<ConditionLiteralImpl>
ConditionLiteralImpl(size_t identifier, Literal literal);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionLiteralImpl& other) const;
size_t hash_impl() const;
Expand All @@ -58,7 +58,7 @@ class ConditionAndImpl : public Base<ConditionAndImpl>
ConditionAndImpl(size_t identifier, ConditionList conditions);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionAndImpl& other) const;
size_t hash_impl() const;
Expand All @@ -80,7 +80,7 @@ class ConditionOrImpl : public Base<ConditionOrImpl>
ConditionOrImpl(size_t identifier, ConditionList conditions);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionOrImpl& other) const;
size_t hash_impl() const;
Expand All @@ -102,7 +102,7 @@ class ConditionNotImpl : public Base<ConditionNotImpl>
ConditionNotImpl(size_t identifier, Condition condition);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionNotImpl& other) const;
size_t hash_impl() const;
Expand All @@ -125,7 +125,7 @@ class ConditionImplyImpl : public Base<ConditionImplyImpl>
ConditionImplyImpl(size_t identifier, Condition condition_left, Condition condition_right);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionImplyImpl& other) const;
size_t hash_impl() const;
Expand All @@ -149,7 +149,7 @@ class ConditionExistsImpl : public Base<ConditionExistsImpl>
ConditionExistsImpl(size_t identifier, ParameterList parameters, Condition condition);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionExistsImpl& other) const;
size_t hash_impl() const;
Expand All @@ -173,7 +173,7 @@ class ConditionForallImpl : public Base<ConditionForallImpl>
ConditionForallImpl(size_t identifier, ParameterList parameters, Condition condition);

// Give access to the constructor.
friend class PDDLFactory<ConditionImpl, Hash<ConditionImpl*>, EqualTo<ConditionImpl*>>;
friend class UniqueValueTypeFactory<ConditionImpl, Hash<const ConditionImpl*, true>, EqualTo<const ConditionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const ConditionForallImpl& other) const;
size_t hash_impl() const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"
#include "loki/details/pddl/requirements.hpp"
#include "loki/details/utils/filesystem.hpp"

Expand Down Expand Up @@ -55,7 +55,7 @@ class DomainImpl : public Base<DomainImpl>
AxiomList axioms);

// Give access to the constructor.
friend class PDDLFactory<DomainImpl, Hash<DomainImpl*>, EqualTo<DomainImpl*>>;
friend class UniqueValueTypeFactory<DomainImpl, Hash<const DomainImpl*, true>, EqualTo<const DomainImpl*, true>>;

/// @brief Test for structural equivalence
bool is_structurally_equivalent_to_impl(const DomainImpl& other) const;
Expand Down
12 changes: 6 additions & 6 deletions include/loki/details/pddl/effects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -47,7 +47,7 @@ class EffectLiteralImpl : public Base<EffectLiteralImpl>
EffectLiteralImpl(size_t identifier, Literal literal);

// Give access to the constructor.
friend class PDDLFactory<EffectImpl, Hash<EffectImpl*>, EqualTo<EffectImpl*>>;
friend class UniqueValueTypeFactory<EffectImpl, Hash<const EffectImpl*, true>, EqualTo<const EffectImpl*, true>>;

// Give access to the private interface implementations.
friend class Base<EffectLiteralImpl>;
Expand All @@ -69,7 +69,7 @@ class EffectAndImpl : public Base<EffectAndImpl>
EffectAndImpl(size_t identifier, EffectList effects);

// Give access to the constructor.
friend class loki::PDDLFactory<EffectImpl, loki::Hash<EffectImpl*>, loki::EqualTo<EffectImpl*>>;
friend class UniqueValueTypeFactory<EffectImpl, Hash<const EffectImpl*, true>, EqualTo<const EffectImpl*, true>>;

// Give access to the private interface implementations.
friend class Base<EffectAndImpl>;
Expand All @@ -93,7 +93,7 @@ class EffectNumericImpl : public Base<EffectNumericImpl>
EffectNumericImpl(size_t identifier, AssignOperatorEnum assign_operator, Function function, FunctionExpression function_expression);

// Give access to the constructor.
friend class loki::PDDLFactory<EffectImpl, loki::Hash<EffectImpl*>, loki::EqualTo<EffectImpl*>>;
friend class UniqueValueTypeFactory<EffectImpl, Hash<const EffectImpl*, true>, EqualTo<const EffectImpl*, true>>;

// Give access to the private interface implementations.
friend class Base<EffectNumericImpl>;
Expand All @@ -118,7 +118,7 @@ class EffectConditionalForallImpl : public Base<EffectConditionalForallImpl>
EffectConditionalForallImpl(size_t identifier, ParameterList parameters, Effect effect);

// Give access to the constructor.
friend class loki::PDDLFactory<EffectImpl, loki::Hash<EffectImpl*>, loki::EqualTo<EffectImpl*>>;
friend class UniqueValueTypeFactory<EffectImpl, Hash<const EffectImpl*, true>, EqualTo<const EffectImpl*, true>>;

// Give access to the private interface implementations.
friend class Base<EffectConditionalForallImpl>;
Expand All @@ -142,7 +142,7 @@ class EffectConditionalWhenImpl : public Base<EffectConditionalWhenImpl>
EffectConditionalWhenImpl(size_t identifier, Condition condition, Effect effect);

// Give access to the constructor.
friend class loki::PDDLFactory<EffectImpl, loki::Hash<EffectImpl*>, loki::EqualTo<EffectImpl*>>;
friend class UniqueValueTypeFactory<EffectImpl, Hash<const EffectImpl*, true>, EqualTo<const EffectImpl*, true>>;

bool is_structurally_equivalent_to_impl(const EffectConditionalWhenImpl& other) const;
size_t hash_impl() 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 @@ -25,7 +25,7 @@
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/domain.hpp"
#include "loki/details/pddl/effects.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"
#include "loki/details/pddl/function.hpp"
#include "loki/details/pddl/function_expressions.hpp"
#include "loki/details/pddl/function_skeleton.hpp"
Expand All @@ -44,7 +44,7 @@

namespace loki
{
using VariadicPDDLFactories = VariadicPDDLFactory<RequirementsImpl,
using VariadicPDDLFactories = VariadicUniqueValueTypeFactory<RequirementsImpl,
TypeImpl,
VariableImpl,
TermImpl,
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -35,7 +35,7 @@ class FunctionImpl : public Base<FunctionImpl>
FunctionImpl(size_t identifier, FunctionSkeleton function_skeleton, TermList terms);

// Give access to the constructor.
friend class PDDLFactory<FunctionImpl, Hash<FunctionImpl*>, EqualTo<FunctionImpl*>>;
friend class UniqueValueTypeFactory<FunctionImpl, Hash<const FunctionImpl*, true>, EqualTo<const FunctionImpl*, true>>;

/// @brief Test for semantic equivalence
bool is_structurally_equivalent_to_impl(const FunctionImpl& other) const;
Expand Down
12 changes: 6 additions & 6 deletions include/loki/details/pddl/function_expressions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand Down Expand Up @@ -55,7 +55,7 @@ class FunctionExpressionNumberImpl : public Base<FunctionExpressionNumberImpl>
FunctionExpressionNumberImpl(size_t identifier, double number);

// Give access to the constructor.
friend class PDDLFactory<FunctionExpressionImpl, Hash<FunctionExpressionImpl*>, EqualTo<FunctionExpressionImpl*>>;
friend class UniqueValueTypeFactory<FunctionExpressionImpl, Hash<const FunctionExpressionImpl*, true>, EqualTo<const FunctionExpressionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const FunctionExpressionNumberImpl& other) const;
size_t hash_impl() const;
Expand All @@ -82,7 +82,7 @@ class FunctionExpressionBinaryOperatorImpl : public Base<FunctionExpressionBinar
FunctionExpression right_function_expression);

// Give access to the constructor.
friend class PDDLFactory<FunctionExpressionImpl, Hash<FunctionExpressionImpl*>, EqualTo<FunctionExpressionImpl*>>;
friend class UniqueValueTypeFactory<FunctionExpressionImpl, Hash<const FunctionExpressionImpl*, true>, EqualTo<const FunctionExpressionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const FunctionExpressionBinaryOperatorImpl& other) const;
size_t hash_impl() const;
Expand All @@ -107,7 +107,7 @@ class FunctionExpressionMultiOperatorImpl : public Base<FunctionExpressionMultiO
FunctionExpressionMultiOperatorImpl(size_t identifier, MultiOperatorEnum multi_operator, FunctionExpressionList function_expressions);

// Give access to the constructor.
friend class PDDLFactory<FunctionExpressionImpl, Hash<FunctionExpressionImpl*>, EqualTo<FunctionExpressionImpl*>>;
friend class UniqueValueTypeFactory<FunctionExpressionImpl, Hash<const FunctionExpressionImpl*, true>, EqualTo<const FunctionExpressionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const FunctionExpressionMultiOperatorImpl& other) const;
size_t hash_impl() const;
Expand All @@ -130,7 +130,7 @@ class FunctionExpressionMinusImpl : public Base<FunctionExpressionMinusImpl>
FunctionExpressionMinusImpl(size_t identifier, FunctionExpression function_expression);

// Give access to the constructor.
friend class PDDLFactory<FunctionExpressionImpl, Hash<FunctionExpressionImpl*>, EqualTo<FunctionExpressionImpl*>>;
friend class UniqueValueTypeFactory<FunctionExpressionImpl, Hash<const FunctionExpressionImpl*, true>, EqualTo<const FunctionExpressionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const FunctionExpressionMinusImpl& other) const;
size_t hash_impl() const;
Expand All @@ -152,7 +152,7 @@ class FunctionExpressionFunctionImpl : public Base<FunctionExpressionFunctionImp
FunctionExpressionFunctionImpl(size_t identifier, Function function);

// Give access to the constructor.
friend class PDDLFactory<FunctionExpressionImpl, Hash<FunctionExpressionImpl*>, EqualTo<FunctionExpressionImpl*>>;
friend class UniqueValueTypeFactory<FunctionExpressionImpl, Hash<const FunctionExpressionImpl*, true>, EqualTo<const FunctionExpressionImpl*, true>>;

bool is_structurally_equivalent_to_impl(const FunctionExpressionFunctionImpl& other) const;
size_t hash_impl() const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/function_skeleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -36,7 +36,7 @@ class FunctionSkeletonImpl : public Base<FunctionSkeletonImpl>
FunctionSkeletonImpl(size_t identifier, std::string name, ParameterList parameters, Type type);

// Give access to the constructor.
friend class PDDLFactory<FunctionSkeletonImpl, Hash<FunctionSkeletonImpl*>, EqualTo<FunctionSkeletonImpl*>>;
friend class UniqueValueTypeFactory<FunctionSkeletonImpl, Hash<const FunctionSkeletonImpl*, true>, EqualTo<const FunctionSkeletonImpl*, true>>;

/// @brief Test for semantic equivalence
bool is_structurally_equivalent_to_impl(const FunctionSkeletonImpl& other) const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -35,7 +35,7 @@ class LiteralImpl : public Base<LiteralImpl>
LiteralImpl(size_t identifier, bool is_negated, Atom atom);

// Give access to the constructor.
friend class PDDLFactory<LiteralImpl, Hash<LiteralImpl*>, EqualTo<LiteralImpl*>>;
friend class UniqueValueTypeFactory<LiteralImpl, Hash<const LiteralImpl*, true>, EqualTo<const LiteralImpl*, true>>;

/// @brief Test for semantic equivalence
bool is_structurally_equivalent_to_impl(const LiteralImpl& other) const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -44,7 +44,7 @@ class OptimizationMetricImpl : public Base<OptimizationMetricImpl>
OptimizationMetricImpl(size_t identifier, OptimizationMetricEnum optimization_metric, FunctionExpression function_expression);

// Give access to the constructor.
friend class PDDLFactory<OptimizationMetricImpl, Hash<OptimizationMetricImpl*>, EqualTo<OptimizationMetricImpl*>>;
friend class UniqueValueTypeFactory<OptimizationMetricImpl, Hash<const OptimizationMetricImpl*, true>, EqualTo<const OptimizationMetricImpl*, true>>;

/// @brief Test for semantic equivalence
bool is_structurally_equivalent_to_impl(const OptimizationMetricImpl& other) const;
Expand Down
4 changes: 2 additions & 2 deletions include/loki/details/pddl/numeric_fluent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "loki/details/pddl/base.hpp"
#include "loki/details/pddl/declarations.hpp"
#include "loki/details/pddl/factory.hpp"
#include "loki/details/utils/value_type_factory.hpp"

#include <string>

Expand All @@ -33,7 +33,7 @@ class NumericFluentImpl : public Base<NumericFluentImpl>
double m_number;

// Give access to the constructor.
friend class PDDLFactory<NumericFluentImpl, Hash<NumericFluentImpl*>, EqualTo<NumericFluentImpl*>>;
friend class UniqueValueTypeFactory<NumericFluentImpl, Hash<const NumericFluentImpl*, true>, EqualTo<const NumericFluentImpl*, true>>;

NumericFluentImpl(size_t identifier, Function function, double number);

Expand Down
Loading

0 comments on commit 14850d3

Please sign in to comment.