34 #include <boost/concept_check.hpp>
36 #include <fast_methods/console/console.h>
39 template <
class gr
id_t>
58 (
const std::vector<unsigned int> & init_points,
unsigned int goal_idx) {
65 (
const std::vector<unsigned int> & init_points)
72 (
const std::array<
unsigned int, grid_t::getNDims()> & init_coord,
const std::array<
unsigned int, grid_t::getNDims()> & goal_coord) {
73 std::vector<unsigned int> init_points;
75 grid_->coord2idx(init_coord, idx);
76 init_points.push_back(idx);
77 grid_->coord2idx(goal_coord, idx);
83 (
const std::array<
unsigned int, grid_t::getNDims()> & init_coord)
85 std::vector<unsigned int> init_points;
87 grid_->coord2idx(init_coord, idx);
88 init_points.push_back(idx);
123 grid_->setClean(
false);
130 start_ = std::chrono::steady_clock::now();
132 end_ = std::chrono::steady_clock::now();
133 time_ = std::chrono::duration_cast<std::chrono::milliseconds>(end_-
start_).count();
145 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, Solver*>));
146 return static_cast<T*
>(
this);
155 BOOST_CONCEPT_ASSERT((boost::Convertible<T*, Solver*>));
156 return static_cast<const T*
>(
this);
187 virtual double getTime
192 virtual void printRunInfo
201 if (
grid_ == NULL)
return 1;
202 if (!
grid_->isClean())
return 2;
234 std::chrono::time_point<std::chrono::steady_clock>
start_, end_;
double time_
Time elapsed by the compute method.
virtual void setEnvironment(grid_t *g)
Sets and cleans the grid in which operations will be performed.
virtual void computeInternal()=0
Actual compute function to be implemented in each solver.
virtual void setup()
Checks that the solver is ready to run. Sets the grid unclean.
T * as()
Cast this instance to a desired type.
static void error(const std::string &val)
const std::string & getName() const
Returns name of the solver.
void compute()
Computes the distances map. Will call setup() if not done already.
int sanityChecks()
Performs different check before a solver can proceed.
grid_t * grid_
Grid container.
virtual void setInitialAndGoalPoints(const std::vector< unsigned int > &init_points, unsigned int goal_idx)
Sets the initial and goal points by the indices of the grid.
std::vector< unsigned int > init_points_
Initial index.
virtual void clear()
Clears the solver, it is not recommended to be used out of the destructor.
std::string name_
Solver name.
virtual void setInitialPoints(const std::vector< unsigned int > &init_points)
Sets the initial points by the indices of the grid.
Abstract class that serves as interface for the actual solvers implemented. It requires (at least) th...
std::chrono::time_point< std::chrono::steady_clock > start_
Time measurement variables.
unsigned int goal_idx_
Goal index.
static void warning(const std::string &val)
grid_t * getGrid() const
Returns a pointer to the grid used.
virtual void reset()
Clears temporal data, so it is ready to run again.