n-Dimensional Fast Methods  0.7
 All Classes Functions Variables Typedefs Pages
test_fm_benchmark.cpp
1 /* Configure a Fast Methods benchmark from code. Compare this code with test_fm.cpp */
2 
3 #include <iostream>
4 #include <array>
5 
6 #include <fast_methods/ndgridmap/fmcell.h>
7 #include <fast_methods/ndgridmap/ndgridmap.hpp>
8 
9 #include <fast_methods/fm/fmm.hpp>
10 #include <fast_methods/fm/sfmm.hpp>
11 #include <fast_methods/fm/fmmstar.hpp>
12 #include <fast_methods/fm/sfmmstar.hpp>
13 #include <fast_methods/datastructures/fmfibheap.hpp>
14 #include <fast_methods/datastructures/fmpriorityqueue.hpp>
15 #include <fast_methods/fm/fim.hpp>
16 #include <fast_methods/fm/gmm.hpp>
17 #include <fast_methods/fm/ufmm.hpp>
18 #include <fast_methods/fm/fsm.hpp>
19 #include <fast_methods/fm/lsm.hpp>
20 #include <fast_methods/fm/ddqm.hpp>
21 
22 #include <fast_methods/benchmark/benchmark.hpp>
23 
24 using namespace std;
25 using namespace std::chrono;
26 
27 int main()
28 {
29  // A bit of shorthand.
30  typedef nDGridMap<FMCell, 2> FMGrid2D;
31  typedef array<unsigned int, 2> Coord2D;
32 
33  // Grid, start and goal definition. The grid can be initialized form an image as well.
34  Coord2D dimsize {300,300};
35  FMGrid2D grid (dimsize);
36  Coord2D init_point = {150, 150};
37  Coord2D goal_point = {250, 250};
38 
39  // Configuring benchmark metadata
40  Benchmark<FMGrid2D> benchmark;
41  benchmark.setSaveLog(false); // Shows output in terminal.
42  benchmark.setName("Testing_Benchmark");
43  benchmark.setNRuns(3);
44  benchmark.setEnvironment(&grid);
45 
46  // Setting initial point.
47  unsigned int startIdx;
48  std::vector<unsigned int> startIndices;
49  grid.coord2idx(init_point, startIdx);
50  startIndices.push_back(startIdx);
51 
52  // Setting goal point (can be omitted)
53  unsigned int goalIdx;
54  grid.coord2idx(goal_point, goalIdx);
55  benchmark.setInitialAndGoalPoints(startIndices, goalIdx);
56 
57  // Call this if goal point is omitted.
58  //benchmark.setInitialPoints(startIndices);
59 
60  // Adding solvers.
61  benchmark.addSolver(new FMM<FMGrid2D>);
62  benchmark.addSolver(new FMMStar<FMGrid2D>);
63  benchmark.addSolver(new FMMStar<FMGrid2D>("FMM*_Dist", DISTANCE));
64  benchmark.addSolver(new FMM<FMGrid2D, FMFibHeap<FMCell> >("FMFib"));
65  benchmark.addSolver(new FMMStar<FMGrid2D, FMFibHeap<FMCell> >("FMM*Fib"));
66  benchmark.addSolver(new FMMStar<FMGrid2D, FMFibHeap<FMCell> >("FMM*Fib_Dist", DISTANCE));
67  benchmark.addSolver(new SFMM<FMGrid2D>);
68  benchmark.addSolver(new SFMMStar<FMGrid2D>);
69  benchmark.addSolver(new SFMMStar<FMGrid2D>("SFMM*_Dist", DISTANCE));
70  benchmark.addSolver(new GMM<FMGrid2D>);
71  benchmark.addSolver(new FIM<FMGrid2D>);
72  benchmark.addSolver(new UFMM<FMGrid2D>);
73  benchmark.addSolver(new FSM<FMGrid2D>);
74  benchmark.addSolver(new LSM<FMGrid2D>);
75  benchmark.addSolver(new DDQM<FMGrid2D>);
76 
77  // Run benchmark
78  benchmark.run();
79 
80  return 0;
81 }
Implements Fast Sweeping Method.
Definition: fsm.hpp:41
Fast Marching Method using a untidy priority queue (UFMM).
Definition: ufmm.hpp:37
Encapsulates the calls to FMM with heuristics enabled.
Definition: fmmstar.hpp:61
This class provides the utilities to benchmark Fast Marching Solvers (configuration, running and logging). It works for FMM (any heap and SFMM), FIM and UFMM. It has not been tested with FM2 solvers.
Definition: benchmark.hpp:33
Implements the Simplified Fast Marching Method, encapsulating FMM with a priority queue...
Definition: sfmm.hpp:44
void setEnvironment(grid_t *grid)
Sets the environment (grid map) the benchmark will be run on.
Definition: benchmark.hpp:72
Templated class which represents a n-dimensional grid map. Its cells are assumed to be cubic...
Definition: ndgridmap.hpp:47
void addSolver(Solver< grid_t > *solver)
Adds a new solver to be benchmarked.
Definition: benchmark.hpp:60
Implements Double Dynamic Queue Method.
Definition: ddqm.hpp:41
Implements Lock Sweeping Method.
Definition: lsm.hpp:40
Implements Fast Iterative Method.
Definition: fim.hpp:36
void setNRuns(unsigned int n)
Set number of runs for each solver.
Definition: benchmark.hpp:78
Templated class which computes Group Marching Method (GMM).
Definition: gmm.hpp:33
Implements the Fast Marching Method (FMM).
Definition: fmm.hpp:64
void setInitialAndGoalPoints(const std::vector< unsigned int > &init_points, unsigned int goal_idx)
Sets the initial and goal points (indices) for the solvers.
Definition: benchmark.hpp:96
void setSaveLog(bool s)
Sets the flag to save the log to a file (true) or output in terminal (false).
Definition: benchmark.hpp:90
void run()
Automatically runs all the solvers.
Definition: benchmark.hpp:109
void setName(const std::string &n)
Sets the name of the benchmark.
Definition: benchmark.hpp:189