-
Notifications
You must be signed in to change notification settings - Fork 2
Bugfix/uds #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Bugfix/uds #60
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
|
|
||
| #include "search_metrics.h" | ||
| #include <warthog/io/log.h> | ||
| #include <warthog/util/template.h> | ||
|
|
||
| namespace warthog::search | ||
| { | ||
|
|
@@ -133,7 +134,7 @@ enum class reopen_policy | |
|
|
||
| // decide whether to renopen nodes already expanded (when their g-value | ||
| // can be improved). we handle the positive case via specialisation. | ||
| template<reopen_policy RO> | ||
| template<reopen_policy RP> | ||
| inline bool | ||
| reopen() | ||
| { | ||
|
|
@@ -147,6 +148,108 @@ reopen<reopen_policy::yes>() | |
| return true; | ||
| } | ||
|
|
||
| struct uds_default_traits | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No description of what the traits do? |
||
| { | ||
| // using node = std::tuple<>; | ||
| // using observer = std::tuple<>; | ||
| static constexpr admissibility_criteria ac = admissibility_criteria::any; | ||
| static constexpr feasibility_criteria fc | ||
| = feasibility_criteria::until_exhaustion; | ||
| static constexpr reopen_policy rp = reopen_policy::no; | ||
| }; | ||
|
|
||
| template< | ||
| typename N = search_node, typename L = std::tuple<>, | ||
| admissibility_criteria AC = admissibility_criteria::any, | ||
| feasibility_criteria FC = feasibility_criteria::until_exhaustion, | ||
| reopen_policy RP = reopen_policy::no> | ||
| struct uds_traits | ||
| { | ||
| using node = N; | ||
| using observer = L; | ||
| static constexpr admissibility_criteria ac = AC; | ||
| static constexpr feasibility_criteria fc = FC; | ||
| static constexpr reopen_policy rp = RP; | ||
| }; | ||
|
|
||
| namespace details | ||
| { | ||
|
|
||
| template<typename Traits> | ||
| struct uds_trait_node | ||
| { | ||
| using type = search_node; | ||
| }; | ||
| template<typename Traits> | ||
| requires requires { typename Traits::node; } | ||
| struct uds_trait_node<Traits> | ||
| { | ||
| using type = typename Traits::node; | ||
| }; | ||
|
|
||
| template<typename Traits> | ||
| struct uds_trait_observer | ||
| { | ||
| using type = search_node; | ||
| }; | ||
| template<typename Traits> | ||
| requires requires { typename Traits::observer; } | ||
| struct uds_trait_observer<Traits> | ||
| { | ||
| using type = typename Traits::observer; | ||
| }; | ||
|
|
||
| } // namespace details | ||
|
|
||
| template<typename Traits> | ||
| using uds_trait_node = typename details::uds_trait_node<Traits>::type; | ||
|
|
||
| template<typename Traits> | ||
| using uds_trait_observer = typename details::uds_trait_observer<Traits>::type; | ||
|
|
||
| template<typename Traits> | ||
| inline consteval admissibility_criteria | ||
| uds_trait_ac() noexcept | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a description. what does this do? (please add comments similar to reopen policy) |
||
| { | ||
| if constexpr(requires { | ||
| { | ||
| Traits::ac | ||
| } -> util::same_as_rmref<admissibility_criteria>; | ||
| }) | ||
| { | ||
| return Traits::ac; | ||
| } | ||
| else { return admissibility_criteria::any; } | ||
| } | ||
|
|
||
| template<typename Traits> | ||
| inline consteval feasibility_criteria | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments to describe what this does |
||
| uds_trait_fc() noexcept | ||
| { | ||
| if constexpr(requires { | ||
| { | ||
| Traits::fc | ||
| } -> util::same_as_rmref<feasibility_criteria>; | ||
| }) | ||
| { | ||
| return Traits::fc; | ||
| } | ||
| else { return feasibility_criteria::until_exhaustion; } | ||
| } | ||
|
|
||
| template<typename Traits> | ||
| inline consteval reopen_policy | ||
| uds_trait_rp() noexcept | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments to describe what this does |
||
| { | ||
| if constexpr(requires { | ||
| { Traits::rp } -> util::same_as_rmref<reopen_policy>; | ||
| }) | ||
| { | ||
| return Traits::rp; | ||
| } | ||
| else { return reopen_policy::no; } | ||
| } | ||
|
|
||
| } // namespace warthog::search | ||
|
|
||
| #endif // WARTHOG_SEARCH_UDS_TRAITS_H | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,20 +41,30 @@ namespace warthog::search | |
| // (default: search for any solution, until OPEN is exhausted) | ||
| template< | ||
| typename H, typename E, typename Q = util::pqueue_min, | ||
| typename L = std::tuple<>, | ||
| admissibility_criteria AC = admissibility_criteria::any, | ||
| feasibility_criteria FC = feasibility_criteria::until_exhaustion, | ||
| reopen_policy RP = reopen_policy::no> | ||
| class unidirectional_search | ||
| typename Traits = uds_default_traits> | ||
| class unidirectional_search_full | ||
| { | ||
| public: | ||
| unidirectional_search( | ||
| using traits = Traits; | ||
| using search_node = uds_trait_node<Traits>; | ||
| using L = uds_trait_observer<Traits>; | ||
|
|
||
| static constexpr admissibility_criteria AC = uds_trait_ac<Traits>(); | ||
| static constexpr feasibility_criteria FC = uds_trait_fc<Traits>(); | ||
| static constexpr reopen_policy RP = uds_trait_rp<Traits>(); | ||
|
|
||
| unidirectional_search_full( | ||
| H* heuristic, E* expander, Q* queue, L listeners = L{}) | ||
| : heuristic_(heuristic), expander_(expander), open_(queue), | ||
| listeners_(listeners) | ||
| { } | ||
| unidirectional_search_full(const unidirectional_search_full& other) | ||
| = delete; | ||
| ~unidirectional_search_full() = default; | ||
|
|
||
| ~unidirectional_search() { } | ||
| unidirectional_search_full& | ||
| operator=(const unidirectional_search_full& other) | ||
| = delete; | ||
|
|
||
| void | ||
| get_pathcost(problem_instance* pi, search_parameters* par, solution* sol) | ||
|
|
@@ -138,14 +148,6 @@ class unidirectional_search | |
| Q* open_; | ||
| [[no_unique_address]] L listeners_; | ||
|
|
||
| // no copy ctor | ||
| unidirectional_search(const unidirectional_search& other) { } | ||
| unidirectional_search& | ||
| operator=(const unidirectional_search& other) | ||
| { | ||
| return *this; | ||
| } | ||
|
|
||
| /** | ||
| * Initialise a new 'search_node' for the ongoing search given the parent | ||
| * node (@param current). | ||
|
|
@@ -315,6 +317,25 @@ class unidirectional_search | |
| } | ||
| }; | ||
|
|
||
| // Keep for backward compatibility. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's not much point to backwards compatibility at this point. The only affected project is warthog-jps, which we maintain. Might as well fix both. |
||
| // Done as class instead of using to support user-defined deduction | ||
| template< | ||
| typename H, typename E, typename Q = util::pqueue_min, | ||
| typename L = std::tuple<>, | ||
| admissibility_criteria AC = admissibility_criteria::any, | ||
| feasibility_criteria FC = feasibility_criteria::until_exhaustion, | ||
| reopen_policy RP = reopen_policy::no> | ||
| class unidirectional_search | ||
| : public unidirectional_search_full< | ||
| H, E, Q, uds_traits<search_node, L, AC, FC, RP>> | ||
| { | ||
| public: | ||
| using unidirectional_search_full = unidirectional_search_full< | ||
| H, E, Q, uds_traits<search_node, L, AC, FC, RP>>; | ||
|
|
||
| using unidirectional_search_full::unidirectional_search_full; | ||
| }; | ||
|
|
||
| template< | ||
| typename H, typename E, typename Q = util::pqueue_min, | ||
| typename L = std::tuple<>> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,6 +108,13 @@ choose_integer_sequence(auto value, TemplateFunc&& tfunc) | |
| value, std::forward<TemplateFunc>(tfunc)); | ||
| } | ||
|
|
||
| template<typename T, typename T2> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not clear what we're doing here. please add some comments |
||
| concept same_as_rmref | ||
| = std::same_as<std::remove_reference_t<T>, std::remove_reference_t<T2>>; | ||
| template<typename T, typename T2> | ||
| concept same_as_rmcvref | ||
| = std::same_as<std::remove_cvref_t<T>, std::remove_cvref_t<T2>>; | ||
|
|
||
| } // namespace warthog::util | ||
|
|
||
| #endif // WARTHOG_UTIL_CAST_H | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No header, no description of what is being implemented.