Program Listing for File ExperienceSetup.h
↰ Return to documentation for file (src/ompl/tools/experience/ExperienceSetup.h)
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2014, University of Colorado, Boulder
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Univ of CO, Boulder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Dave Coleman
*/
#ifndef OMPL_TOOLS_EXPERIENCE__EXPERIENCE_SETUP_
#define OMPL_TOOLS_EXPERIENCE__EXPERIENCE_SETUP_
#include "ompl/geometric/SimpleSetup.h"
namespace ompl
{
namespace tools
{
OMPL_CLASS_FORWARD(ExperienceSetup);
class ExperienceSetup : public geometric::SimpleSetup
{
public:
struct ExperienceStats
{
ExperienceStats() = default;
double getAveragePlanningTime() const
{
if (numProblems_ == 0.0)
return 0.0;
return totalPlanningTime_ / numProblems_;
}
double getAverageInsertionTime() const
{
if (numProblems_ == 0.0)
return 0.0;
// Clean up output
double time = totalInsertionTime_ / numProblems_;
if (time < 1e-8)
return 0.0;
return totalInsertionTime_ / numProblems_;
}
double numSolutionsFromRecall_{0.};
double numSolutionsFromRecallSaved_{0.};
double numSolutionsFromScratch_{0.};
double numSolutionsFailed_{0.};
double numSolutionsTimedout_{0.};
double numSolutionsApproximate_{0.};
double numSolutionsTooShort_{0.}; // less than 3 states
double numProblems_{0.}; // input requests
double totalPlanningTime_{0.}; // of all input requests, used for averaging
double totalInsertionTime_{0.}; // of all input requests, used for averaging
};
struct ExperienceLog
{
ExperienceLog() = default;
// Times
double planning_time{0.0};
double insertion_time{0.0};
// Solution properties
std::string planner{"NA"};
std::string result{"NA"};
std::string is_saved{"NA"};
// Failure booleans
bool approximate{false};
bool too_short{false};
bool insertion_failed{false};
// Lightning properties
double score{0.0};
// Thunder (SPARS) properties
std::size_t num_vertices{0};
std::size_t num_edges{0};
std::size_t num_connected_components{0};
};
explicit ExperienceSetup(const base::SpaceInformationPtr &si);
explicit ExperienceSetup(const base::StateSpacePtr &space);
void logInitialize();
void convertLogToString(const ExperienceLog &log);
virtual void printResultsInfo(std::ostream &out = std::cout) const = 0;
virtual void printLogs(std::ostream &out = std::cout) const = 0;
virtual void saveDataLog(std::ostream &out = std::cout);
virtual void setRepairPlanner(const base::PlannerPtr &planner) = 0;
virtual bool save() = 0;
virtual bool saveIfChanged() = 0;
void enablePlanningFromRecall(bool enable);
void enablePlanningFromScratch(bool enable);
virtual void getAllPlannerDatas(std::vector<ompl::base::PlannerDataPtr> &plannerDatas) const = 0;
virtual std::size_t getExperiencesCount() const = 0;
virtual const std::string &getFilePath() const;
virtual bool setFilePath(const std::string &filePath);
const ExperienceStats &getStats() const
{
return stats_;
}
virtual bool doPostProcessing()
{
return true;
}
protected:
bool recallEnabled_{true};
bool scratchEnabled_{true};
std::string filePath_;
// output data to file to analyze performance externally
std::stringstream csvDataLogStream_;
ExperienceStats stats_;
};
}
}
#endif