00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef OMPL_BENCHMARK_BENCHMARK_
00038 #define OMPL_BENCHMARK_BENCHMARK_
00039
00040 #include "ompl/geometric/SimpleSetup.h"
00041 #include "ompl/control/SimpleSetup.h"
00042
00043 namespace ompl
00044 {
00045
00047 class Benchmark
00048 {
00049 public:
00050
00055 struct Status
00056 {
00057 Status(void)
00058 {
00059 running = false;
00060 activePlanner = "";
00061 activeRun = 0;
00062 progressPercentage = 0.0;
00063 }
00064
00066 bool running;
00067
00069 std::string activePlanner;
00070
00072 unsigned int activeRun;
00073
00075 double progressPercentage;
00076 };
00077
00080 typedef std::map<std::string, std::string> RunProperties;
00081
00083 struct PlannerExperiment
00084 {
00086 std::string name;
00087
00089 std::vector<RunProperties> runs;
00090
00092 RunProperties common;
00093 };
00094
00096 struct CompleteExperiment
00097 {
00099 std::string name;
00100
00102 std::vector<PlannerExperiment> planners;
00103
00105 double maxTime;
00106
00108 double maxMem;
00109
00111 time::point startTime;
00112
00114 double totalDuration;
00115
00117 std::string setupInfo;
00118
00120 boost::uint32_t seed;
00121
00123 std::string host;
00124 };
00125
00127 Benchmark(geometric::SimpleSetup &setup, const std::string &name = std::string()) : gsetup_(&setup), csetup_(NULL), msg_("Benchmark")
00128 {
00129 exp_.name = name;
00130 }
00131
00133 Benchmark(control::SimpleSetup &setup, const std::string &name = std::string()) : gsetup_(NULL), csetup_(&setup), msg_("Benchmark")
00134 {
00135 exp_.name = name;
00136 }
00137
00138 virtual ~Benchmark(void)
00139 {
00140 }
00141
00143 void setExperimentName(const std::string &name)
00144 {
00145 exp_.name = name;
00146 }
00147
00149 const std::string& getExperimentName(void) const
00150 {
00151 return exp_.name;
00152 }
00153
00158 void addPlanner(const base::PlannerPtr &planner)
00159 {
00160 if (planner && planner->getSpaceInformation().get() !=
00161 (gsetup_ ? gsetup_->getSpaceInformation().get() : csetup_->getSpaceInformation().get()))
00162 throw Exception("Planner instance does not match space information");
00163 planners_.push_back(planner);
00164 }
00165
00169 void addPlannerAllocator(const base::PlannerAllocator &pa)
00170 {
00171 planners_.push_back(pa(gsetup_ ? gsetup_->getSpaceInformation() : csetup_->getSpaceInformation()));
00172 }
00173
00175 void clearPlanners(void)
00176 {
00177 planners_.clear();
00178 }
00179
00195 virtual void benchmark(double maxTime, double maxMem, unsigned int runCount, bool displayProgress = false);
00196
00198 const Status& getStatus(void) const
00199 {
00200 return status_;
00201 }
00202
00207 const CompleteExperiment& getRecordedExperimentData(void) const
00208 {
00209 return exp_;
00210 }
00211
00213 virtual bool saveResultsToStream(std::ostream &out = std::cout) const;
00214
00216 bool saveResultsToFile(const char *filename) const;
00217
00219 bool saveResultsToFile(void) const;
00220
00221 protected:
00222
00224 std::string getResultsFilename(void) const;
00225
00227 geometric::SimpleSetup *gsetup_;
00228
00230 control::SimpleSetup *csetup_;
00231
00233 std::vector<base::PlannerPtr> planners_;
00234
00236 CompleteExperiment exp_;
00237
00239 Status status_;
00240
00242 msg::Interface msg_;
00243
00244 };
00245
00246 }
00247 #endif