-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Visitor Templates for BGL Solver (#80)
* Created header for event visitors * Added event visitor as template argument to solver base classes * Revised implementations of Dijkstra search to use event visitor template parameter * Revised explicit template instantiations of BGL solver classes * Updated unit test solver factory to work with new BGL event visitor template parameter * Updated unit test * Updated benchmarks * Removed unnecessary FloatType template parameter from visitors * Implemented macro to simplify explicit template instantiation of BGL solvers * Clang formatting * Added check of target vertex cost to Dijkstra search method
- Loading branch information
Showing
13 changed files
with
304 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
descartes_light/solvers/include/descartes_light/solvers/bgl/event_visitor.h
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
descartes_light/solvers/include/descartes_light/solvers/bgl/event_visitors.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_EVENT_VISITORS | ||
#define DESCARTES_LIGHT_SOLVERS_BGL_EVENT_VISITORS | ||
|
||
#include <descartes_light/solvers/bgl/boost_graph_types.h> | ||
|
||
#include <descartes_light/descartes_macros.h> | ||
DESCARTES_IGNORE_WARNINGS_PUSH | ||
#include <boost/graph/visitors.hpp> | ||
DESCARTES_IGNORE_WARNINGS_POP | ||
|
||
namespace descartes_light | ||
{ | ||
/** | ||
* @brief Event visitor that terminates the search when a vertex in the last rung of the graph is examined | ||
* @details Throws the vertex descriptor that is the termination of the path once a vertex in the last rung of | ||
* the graph is operated on | ||
*/ | ||
template <typename EventType> | ||
struct early_terminator : public boost::base_visitor<early_terminator<EventType>> | ||
{ | ||
/** @brief Event filter typedef defining the events for which this visitor can be used */ | ||
typedef EventType event_filter; | ||
|
||
early_terminator(long last_rung_idx); | ||
|
||
template <typename FloatType> | ||
void operator()(VertexDesc<FloatType> u, const BGLGraph<FloatType>& g); | ||
|
||
const long last_rung_idx_; | ||
}; | ||
|
||
/** | ||
* @brief Event visitor that adds all edges to each vertex dynamically as the vertex is discovered during the graph | ||
* search | ||
*/ | ||
template <typename FloatType, typename EventType> | ||
struct add_all_edges_dynamically : public boost::base_visitor<add_all_edges_dynamically<FloatType, EventType>> | ||
{ | ||
/** @brief Event filter typedef defining the events for which this visitor can be used */ | ||
typedef EventType event_filter; | ||
|
||
add_all_edges_dynamically(std::vector<typename EdgeEvaluator<FloatType>::ConstPtr> edge_eval, | ||
std::vector<std::vector<VertexDesc<FloatType>>> ladder_rungs); | ||
|
||
void operator()(VertexDesc<FloatType> u, const BGLGraph<FloatType>& g); | ||
|
||
const std::vector<typename EdgeEvaluator<FloatType>::ConstPtr> eval_; | ||
const std::vector<std::vector<VertexDesc<FloatType>>> ladder_rungs_; | ||
}; | ||
|
||
/** | ||
* @brief Event visitor for updating vertex cost | ||
*/ | ||
struct cost_recorder : public boost::base_visitor<cost_recorder> | ||
{ | ||
/** @brief Event filter typedef defining the events for which this visitor can be used */ | ||
typedef boost::on_tree_edge event_filter; | ||
|
||
template <typename FloatType> | ||
void operator()(EdgeDesc<FloatType> e, const BGLGraph<FloatType>& g); | ||
}; | ||
|
||
} // namespace descartes_light | ||
|
||
#endif // DESCARTES_LIGHT_SOLVERS_BGL_EVENT_VISITORS_H |
Oops, something went wrong.