101# include <type_traits>
122template <
class GT,
class Distance = Dft_Dist<GT>>
132 auto dx = std::abs(f.x - t.x);
133 auto dy = std::abs(f.y - t.y);
181 static_assert(std::is_arithmetic_v<Distance_Type>,
182 "IDA* requires arithmetic distance type");
190 std::numeric_limits<Distance_Type>::max();
209 <<
"IDA*: heuristic must be non-negative, got " <<
h;
211 std::numeric_limits<Distance_Type>::max() -
h)
212 <<
"IDA*: overflow computing g_cost + heuristic";
223 Node * node =
nullptr;
242 auto arc = it.get_current_arc();
250 <<
"IDA*: negative weight " <<
w <<
" not allowed";
252 <<
"IDA*: overflow computing g_cost + w";
343 threshold =
res.value;
A* shortest path algorithm.
Exception handling system with formatted messages for Aleph-w.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Default distance accessor for arc weights.
IDA* algorithm for memory-efficient shortest path search.
typename Distance::Distance_Type Distance_Type
IDA_Star(Distance dist=Distance(), Heuristic h=Heuristic(), SA _sa=SA())
Constructor.
Distance_Type operator()(const GT &g, Node *start, Node *end, Path< GT > &path)
Finds shortest path (operator interface).
Distance_Type find_path(const GT &g, Node *start, Node *end, Path< GT > &path)
Finds the shortest path from start to end using IDA*.
static constexpr Distance_Type Inf
SearchResult search(const GT &g, Node *curr, Node *end, Distance_Type g_cost, Distance_Type threshold, Path< GT > &path)
Recursive DFS bounded by threshold.
Graph_Node< Node_Info > Node
The graph type.
Graph_Arc< Arc_Info > Arc
The node class type.
void empty()
Clean the path: all the nodes and arc are removed.
void set_graph(const GT &__g, Node *start_node=nullptr)
Set the graph of the path.
void append(Arc *arc)
Append an arc to the path.
Node * remove_last_node()
Remove the last node of path.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
void reset_bit_nodes(int bit) const noexcept
Reset bit to zero for all the nodes of graph.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Return the adjacent node to node through arc.
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
#define NODE_BITS(p)
Get the control bits of a node.
Main namespace for Aleph-w library functions.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Chebyshev (L-infinity) distance heuristic for 8-connected grids.
Distance_Type operator()(typename GT::Node *from, typename GT::Node *to) const
typename Distance::Distance_Type Distance_Type
Default filter for filtered iterators on arcs.
Filtered iterator of adjacent arcs of a node.
Default heuristic for A* (zero heuristic, degrades to Dijkstra).
Utility algorithms and operations for graphs.