Skip to content

Commit

Permalink
added hashing and comparison of identifiabl members through a proxy t…
Browse files Browse the repository at this point in the history
…o make the design more robust
  • Loading branch information
drexlerd committed Dec 23, 2024
1 parent 4ddafa6 commit ca7e3c9
Show file tree
Hide file tree
Showing 36 changed files with 732 additions and 1,190 deletions.
11 changes: 10 additions & 1 deletion include/loki/details/pddl/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ActionImpl
std::optional<Effect> effect);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -60,6 +60,15 @@ class ActionImpl
const ParameterList& get_parameters() const;
const std::optional<Condition>& get_condition() const;
const std::optional<Effect>& get_effect() const;

auto identifiable_members() const
{
return std::forward_as_tuple(std::as_const(m_name),
std::as_const(m_original_arity),
std::as_const(m_parameters),
std::as_const(m_condition),
std::as_const(m_effect));
}
};

extern std::ostream& operator<<(std::ostream& out, const ActionImpl& element);
Expand Down
4 changes: 3 additions & 1 deletion include/loki/details/pddl/atom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AtomImpl
AtomImpl(size_t index, Predicate predicate, TermList terms);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -47,6 +47,8 @@ class AtomImpl
size_t get_index() const;
const Predicate& get_predicate() const;
const TermList& get_terms() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_predicate), std::as_const(m_terms)); }
};

extern std::ostream& operator<<(std::ostream& out, const AtomImpl& element);
Expand Down
10 changes: 9 additions & 1 deletion include/loki/details/pddl/axiom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AxiomImpl
AxiomImpl(size_t index, std::string derived_predicate_name, ParameterList parameters, Condition condition, size_t num_parameters_to_ground_head);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -51,6 +51,14 @@ class AxiomImpl
const ParameterList& get_parameters() const;
const Condition& get_condition() const;
size_t get_num_parameters_to_ground_head() const;

auto identifiable_members() const
{
return std::forward_as_tuple(std::as_const(m_derived_predicate_name),
std::as_const(m_parameters),
std::as_const(m_condition),
std::as_const(m_num_parameters_to_ground_head));
}
};

extern std::ostream& operator<<(std::ostream& out, const AxiomImpl& element);
Expand Down
32 changes: 24 additions & 8 deletions include/loki/details/pddl/conditions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConditionLiteralImpl
ConditionLiteralImpl(size_t index, Literal literal);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -47,6 +47,8 @@ class ConditionLiteralImpl

size_t get_index() const;
const Literal& get_literal() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_literal)); }
};

/* And */
Expand All @@ -59,7 +61,7 @@ class ConditionAndImpl
ConditionAndImpl(size_t index, ConditionList conditions);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -71,6 +73,8 @@ class ConditionAndImpl

size_t get_index() const;
const ConditionList& get_conditions() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_conditions)); }
};

/* Or */
Expand All @@ -83,7 +87,7 @@ class ConditionOrImpl
ConditionOrImpl(size_t index, ConditionList conditions);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -95,6 +99,8 @@ class ConditionOrImpl

size_t get_index() const;
const ConditionList& get_conditions() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_conditions)); }
};

/* Not */
Expand All @@ -107,7 +113,7 @@ class ConditionNotImpl
ConditionNotImpl(size_t index, Condition condition);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -119,6 +125,8 @@ class ConditionNotImpl

size_t get_index() const;
const Condition& get_condition() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_condition)); }
};

/* Imply */
Expand All @@ -132,7 +140,7 @@ class ConditionImplyImpl
ConditionImplyImpl(size_t index, Condition condition_left, Condition condition_right);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -145,6 +153,8 @@ class ConditionImplyImpl
size_t get_index() const;
const Condition& get_condition_left() const;
const Condition& get_condition_right() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_condition_left), std::as_const(m_condition_right)); }
};

/* Exists */
Expand All @@ -158,7 +168,7 @@ class ConditionExistsImpl
ConditionExistsImpl(size_t index, ParameterList parameters, Condition condition);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -171,6 +181,8 @@ class ConditionExistsImpl
size_t get_index() const;
const ParameterList& get_parameters() const;
const Condition& get_condition() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_parameters), std::as_const(m_condition)); }
};

/* Forall */
Expand All @@ -184,7 +196,7 @@ class ConditionForallImpl
ConditionForallImpl(size_t index, ParameterList parameters, Condition condition);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -197,6 +209,8 @@ class ConditionForallImpl
size_t get_index() const;
const ParameterList& get_parameters() const;
const Condition& get_condition() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_parameters), std::as_const(m_condition)); }
};

/* Condition */
Expand All @@ -210,7 +224,7 @@ class ConditionImpl
std::variant<ConditionLiteral, ConditionAnd, ConditionOr, ConditionNot, ConditionImply, ConditionExists, ConditionForall> condition);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -222,6 +236,8 @@ class ConditionImpl

size_t get_index() const;
const std::variant<ConditionLiteral, ConditionAnd, ConditionOr, ConditionNot, ConditionImply, ConditionExists, ConditionForall>& get_condition() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_condition)); }
};

extern std::ostream& operator<<(std::ostream& out, const ConditionLiteralImpl& element);
Expand Down
5 changes: 5 additions & 0 deletions include/loki/details/pddl/declarations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef LOKI_INCLUDE_LOKI_PDDL_DECLARATIONS_HPP_
#define LOKI_INCLUDE_LOKI_PDDL_DECLARATIONS_HPP_

#include "loki/details/utils/concepts.hpp"

#include <cstddef>
#include <unordered_map>
#include <unordered_set>
Expand All @@ -33,6 +35,9 @@ namespace loki
template<typename T>
using PDDLElement = const T*;

template<HasIdentifiableMembers T>
class SegmentedRepository;

/**
* Domain
*/
Expand Down
15 changes: 14 additions & 1 deletion include/loki/details/pddl/domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DomainImpl
AxiomList axioms);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -73,6 +73,19 @@ class DomainImpl
const FunctionSkeletonList& get_functions() const;
const ActionList& get_actions() const;
const AxiomList& get_axioms() const;

auto identifiable_members() const
{
return std::forward_as_tuple(std::as_const(m_filepath),
std::as_const(m_name),
std::as_const(m_requirements),
std::as_const(m_types),
std::as_const(m_constants),
std::as_const(m_predicates),
std::as_const(m_functions),
std::as_const(m_actions),
std::as_const(m_axioms));
}
};

extern std::ostream& operator<<(std::ostream& out, const DomainImpl& element);
Expand Down
31 changes: 24 additions & 7 deletions include/loki/details/pddl/effects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EffectLiteralImpl
EffectLiteralImpl(size_t index, Literal literal);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -58,6 +58,8 @@ class EffectLiteralImpl

size_t get_index() const;
const Literal& get_literal() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_literal)); }
};

/* And */
Expand All @@ -70,7 +72,7 @@ class EffectAndImpl
EffectAndImpl(size_t index, EffectList effects);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -82,6 +84,8 @@ class EffectAndImpl

size_t get_index() const;
const EffectList& get_effects() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_effects)); }
};

/* EffectNumeric */
Expand All @@ -96,7 +100,7 @@ class EffectNumericImpl
EffectNumericImpl(size_t index, AssignOperatorEnum assign_operator, Function function, FunctionExpression function_expression);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -110,6 +114,11 @@ class EffectNumericImpl
AssignOperatorEnum get_assign_operator() const;
const Function& get_function() const;
const FunctionExpression& get_function_expression() const;

auto identifiable_members() const
{
return std::forward_as_tuple(std::as_const(m_assign_operator), std::as_const(m_function), std::as_const(m_function_expression));
}
};

/* CompositeForall */
Expand All @@ -123,7 +132,7 @@ class EffectCompositeForallImpl
EffectCompositeForallImpl(size_t index, ParameterList parameters, Effect effect);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -136,6 +145,8 @@ class EffectCompositeForallImpl
size_t get_index() const;
const ParameterList& get_parameters() const;
const Effect& get_effect() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_parameters), std::as_const(m_effect)); }
};

/* CompositeWhen */
Expand All @@ -149,7 +160,7 @@ class EffectCompositeWhenImpl
EffectCompositeWhenImpl(size_t index, Condition condition, Effect effect);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -162,6 +173,8 @@ class EffectCompositeWhenImpl
size_t get_index() const;
const Condition& get_condition() const;
const Effect& get_effect() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_condition), std::as_const(m_effect)); }
};

class EffectCompositeOneofImpl
Expand All @@ -173,7 +186,7 @@ class EffectCompositeOneofImpl
EffectCompositeOneofImpl(size_t index, EffectList effects);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -185,6 +198,8 @@ class EffectCompositeOneofImpl

size_t get_index() const;
const EffectList& get_effects() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_effects)); }
};

/* EffectImpl */
Expand All @@ -197,7 +212,7 @@ class EffectImpl
EffectImpl(size_t index, std::variant<EffectLiteral, EffectAnd, EffectNumeric, EffectCompositeForall, EffectCompositeWhen, EffectCompositeOneof> effect);

// Give access to the constructor.
template<typename HolderType, typename Hash, typename EqualTo>
template<HasIdentifiableMembers T>
friend class SegmentedRepository;

public:
Expand All @@ -209,6 +224,8 @@ class EffectImpl

size_t get_index() const;
const std::variant<EffectLiteral, EffectAnd, EffectNumeric, EffectCompositeForall, EffectCompositeWhen, EffectCompositeOneof>& get_effect() const;

auto identifiable_members() const { return std::forward_as_tuple(std::as_const(m_effect)); }
};

extern std::ostream& operator<<(std::ostream& out, const EffectLiteralImpl& element);
Expand Down
Loading

0 comments on commit ca7e3c9

Please sign in to comment.