52#ifndef __PBeFS_IDAStar
53 #define __PBeFS_IDAStar
115 : f_domain( domain ) , f_options( options ) {}
123 Run r( f_domain , f_options.node_limit );
124 const State s0 = f_domain.initial_state();
125 const Cost h0 = f_domain.heuristic( s0 );
126 r.path.push_back( s0 );
131 if( r.dfs( s0 ,
Cost( 0 ) , h0 ,
no_op , bound ) ) {
150 sol.
stats = std::move( r.st );
163 std::vector< State > path;
169 Run(
const D & domain , std::size_t
node_limit )
175 bool dfs(
const State & u ,
Cost g ,
Cost h , std::uint8_t op ,
177 if( d.is_goal( u ) ) {
181 if( limit && ( st.expanded >= limit ) ) {
187 const auto child = [ & ](
const State & v ,
Cost c ,
Cost hv ,
190 if( g + c + hv > bound ) {
191 next = std::min( next , g + c + hv );
195 st.stored = std::max< std::uint64_t >( st.stored , path.size() );
196 if( dfs( v , g + c , hv , opv , bound ) )
201 if constexpr( OperatorDomain< D > )
202 d.for_each_successor( u , h , op , [ & ](
const State & v ,
Cost c ,
203 Cost hv , std::uint8_t opv ) {
204 if( ! found && ! stop )
205 child( v , c , hv , opv );
208 d.for_each_successor( u , h , [ & ](
const State & v ,
Cost c ,
212 if( ( path.size() >= 2 ) && ( v == path[ path.size() - 2 ] ) ) {
216 child( v , c , hv ,
no_op );
226 SearchOptions f_options;
239 return( IDAStar< D >( domain , options ).solve() );
Header file for the concepts a search problem has to satisfy in order to be searched by the algorithm...
Header file for the class template Node, a node of the search graph, for the class template NodePool,...
Header file for the small helpers shared by the searches: a stopwatch, the placement of the workers o...
Header file for the outcome of a search: the class template Solution, the statistics SearchStats coll...
IDAStar(const D &domain, const SearchOptions &options={})
constructor, taking the Domain (which must outlive the IDAStar)
Definition IDAStar.h:114
state_t< D > State
the state type
Definition IDAStar.h:106
Solution< State, Cost > SolutionT
the solution type
Definition IDAStar.h:108
cost_t< D > Cost
the cost type
Definition IDAStar.h:107
SolutionT solve(void) const
searches the Domain, returning the Solution
Definition IDAStar.h:120
a wall-clock stopwatch, started at construction
Definition SearchUtils.h:175
double seconds(void) const
the seconds elapsed since the construction
Definition SearchUtils.h:182
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
Solution< state_t< D >, cost_t< D > > idastar(const D &domain, const SearchOptions &options={})
searches a Domain with IDA*
Definition IDAStar.h:236
@ unsolvable
OPEN emptied without reaching a goal.
Definition Solution.h:48
@ solved
an optimal path has been found
Definition Solution.h:47
@ node_limit
the limit on the stored nodes was reached first
Definition Solution.h:49
constexpr Cost infinite_cost(void) noexcept
the largest value of a cost type, used as "no incumbent yet"
Definition Node.h:100
typename D::state_type state_t
the state type of a Domain
Definition Domain.h:241
constexpr std::uint8_t no_op
the operator of the root, which no state was generated by
Definition Domain.h:205
the options shared by all the searches
Definition Solution.h:119
std::vector< std::uint64_t > expanded_by
expansions of each worker
Definition Solution.h:75
std::uint64_t stored
distinct nodes stored at the end
Definition Solution.h:73
double seconds
wall-clock time of the search
Definition Solution.h:74
std::vector< std::uint64_t > stored_by
nodes stored by each worker
Definition Solution.h:76
std::uint64_t expanded
expansions, re-expansions included
Definition Solution.h:66
a path from the initial state to a goal, and its cost
Definition Solution.h:100
std::vector< State > path
the states along the path
Definition Solution.h:104
Cost cost
the cost of the path
Definition Solution.h:103
SearchStats stats
the counters of the search
Definition Solution.h:105
Status status
how the search ended
Definition Solution.h:102