PBeFS
Parallel Best-First Search
Loading...
Searching...
No Matches
SlowDomain.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*--------------------------- File SlowDomain.h ----------------------------*/
3/*--------------------------------------------------------------------------*/
15/*--------------------------------------------------------------------------*/
16/*------------------------------ DEFINITIONS -------------------------------*/
17/*--------------------------------------------------------------------------*/
18
19#ifndef __PBeFS_SlowDomain
20 #define __PBeFS_SlowDomain
21 /* self-identification: #endif at the end of the file */
22
23/*--------------------------------------------------------------------------*/
24/*-------------------------------- INCLUDES --------------------------------*/
25/*--------------------------------------------------------------------------*/
26
27#include <cstddef>
28
29#include <cstdint>
30
31#include <utility>
32
33#include "PBeFS/astar/Domain.h"
34
35/*--------------------------------------------------------------------------*/
36/*------------------------------- NAMESPACE --------------------------------*/
37/*--------------------------------------------------------------------------*/
38
40namespace PBeFS_di_unipi_it
41{
42
43/*--------------------------------------------------------------------------*/
44/*---------------------------- CLASS SlowDomain ----------------------------*/
45/*--------------------------------------------------------------------------*/
47
53
54template< class D >
56
57 public:
58
61
63
64 SlowDomain( const D & d , unsigned long work ) : f_d( d ) , f_work( work ) {}
65
66 [[nodiscard]] state_type initial_state( void ) const {
67 return( f_d.initial_state() );
68 }
69
70 [[nodiscard]] bool is_goal( const state_type & s ) const {
71 return( f_d.is_goal( s ) );
72 }
73
74 [[nodiscard]] std::uint64_t hash( const state_type & s ) const {
75 return( f_d.hash( s ) );
76 }
77
78 [[nodiscard]] cost_type heuristic( const state_type & s ) const {
79 return( f_d.heuristic( s ) );
80 }
81
83
84 template< class F >
85 void for_each_successor( const state_type & s , cost_type h , F && f ) const
86 {
87 work();
88 f_d.for_each_successor( s , h , std::forward< F >( f ) );
89 }
90
91 template< class F >
93 std::uint8_t op , F && f ) const
94 requires OperatorDomain< D > {
95 work();
96 f_d.for_each_successor( s , h , op , std::forward< F >( f ) );
97 }
98
99 // the other methods of D, when D has them
100
101 [[nodiscard]] std::size_t num_features( void ) const
102 requires FeatureDomain< D > { return( f_d.num_features() ); }
103
104 template< class F >
105 void for_each_feature( const state_type & s , F && f ) const
106 requires FeatureDomain< D > {
107 f_d.for_each_feature( s , std::forward< F >( f ) );
108 }
109
110 [[nodiscard]] std::size_t num_abstract_features( void ) const
112 return( f_d.num_abstract_features() );
113 }
114
115 [[nodiscard]] std::size_t abstract_feature( std::size_t i ) const
116 requires AbstractFeatureDomain< D > { return( f_d.abstract_feature( i ) ); }
117
118 [[nodiscard]] std::uint64_t abstract_state( const state_type & s ) const
119 requires AbstractStateDomain< D > { return( f_d.abstract_state( s ) ); }
120
121 [[nodiscard]] std::uint64_t perfect_hash( const state_type & s ) const
122 requires PerfectHashDomain< D > { return( f_d.perfect_hash( s ) ); }
123
124 [[nodiscard]] std::size_t num_nblocks( void ) const
125 requires NBlockDomain< D > { return( f_d.num_nblocks() ); }
126
127 [[nodiscard]] std::size_t nblock( const state_type & s ) const
128 requires NBlockDomain< D > { return( f_d.nblock( s ) ); }
129
130 template< class F >
131 void for_each_nblock_successor( std::size_t b , F && f ) const
132 requires NBlockDomain< D > {
133 f_d.for_each_nblock_successor( b , std::forward< F >( f ) );
134 }
135
136 [[nodiscard]] cost_type pairwise_heuristic( const state_type & s ,
137 const state_type & t ) const
138 requires PairwiseDomain< D > { return( f_d.pairwise_heuristic( s , t ) ); }
139
140 private:
141
142 // the busy work of an expansion
143 void work( void ) const {
144 std::uint64_t i = 7;
145 for( unsigned long k = 0 ; k < f_work ; ++k )
146 i = ( 11 * i ) % 9999943;
147 c_sink += i;
148 }
149
150 const D & f_d;
151 unsigned long f_work;
152 inline static thread_local std::uint64_t c_sink = 0;
153
154 }; // end( class( SlowDomain ) )
155
156/*--------------------------------------------------------------------------*/
157
158} // end( namespace PBeFS_di_unipi_it )
159
160/*--------------------------------------------------------------------------*/
161
162#endif /* __PBeFS_SlowDomain */
163
164/*--------------------------------------------------------------------------*/
165/*------------------------- End File SlowDomain.h --------------------------*/
166/*--------------------------------------------------------------------------*/
Header file for the concepts a search problem has to satisfy in order to be searched by the algorithm...
std::size_t num_nblocks(void) const
Definition SlowDomain.h:124
std::size_t nblock(const state_type &s) const
Definition SlowDomain.h:127
cost_type pairwise_heuristic(const state_type &s, const state_type &t) const
Definition SlowDomain.h:136
bool is_goal(const state_type &s) const
Definition SlowDomain.h:70
std::size_t num_abstract_features(void) const
Definition SlowDomain.h:110
SlowDomain(const D &d, unsigned long work)
constructor, taking the Domain (which must outlive this) and the work
Definition SlowDomain.h:64
state_type initial_state(void) const
Definition SlowDomain.h:66
void for_each_successor(const state_type &s, cost_type h, F &&f) const
the successors of D, after work iterations of busy work
Definition SlowDomain.h:85
std::uint64_t hash(const state_type &s) const
Definition SlowDomain.h:74
void for_each_successor(const state_type &s, cost_type h, std::uint8_t op, F &&f) const
Definition SlowDomain.h:92
std::uint64_t abstract_state(const state_type &s) const
Definition SlowDomain.h:118
std::size_t num_features(void) const
Definition SlowDomain.h:101
void for_each_feature(const state_type &s, F &&f) const
Definition SlowDomain.h:105
std::size_t abstract_feature(std::size_t i) const
Definition SlowDomain.h:115
cost_type heuristic(const state_type &s) const
Definition SlowDomain.h:78
std::uint64_t perfect_hash(const state_type &s) const
Definition SlowDomain.h:121
void for_each_nblock_successor(std::size_t b, F &&f) const
Definition SlowDomain.h:131
state_t< D > state_type
the state type
Definition SlowDomain.h:59
cost_t< D > cost_type
the cost type
Definition SlowDomain.h:60
a FeatureDomain that also provides a feature projection
Definition Domain.h:155
a Domain with a state abstraction
Definition Domain.h:168
a Domain whose states are described by a set of features
Definition Domain.h:127
a Domain whose state space is partitioned into nblocks
Definition Domain.h:182
a Domain that knows the operator by which a state was generated
Definition Domain.h:217
a Domain with a heuristic between any two states
Definition Domain.h:196
a Domain with a perfect hash of its states
Definition Domain.h:230
namespace for the Parallel Best-First Search library
Definition AStar.h:83
typename D::cost_type cost_t
the cost type of a Domain
Definition Domain.h:245
typename D::state_type state_t
the state type of a Domain
Definition Domain.h:241