20 #include "../typedef.hpp" 31 double elapsedRuntime,
const std::string&
patternName)
33 unsigned int numEvaluatedTopologies = 0;
34 std::vector<TopologyPtr> selectedTopologies;
36 for (
unsigned int i = 0; i < history.size(); ++i) {
37 std::vector<std::pair<TopologyPtr, unsigned int>> round = history[i];
39 numEvaluatedTopologies += round.size();
40 for (
unsigned int j = 0; j < round.size(); ++j) {
41 if (round[j].second != 0)
43 selectedTopologies.push_back(round[j].first);
50 mSVGHelper->processHistory(history, globalCostFunction, patternName);
63 for (
unsigned int i = 0; i < selectedTopologies.size(); ++i) {
64 s << i <<
", " << selectedTopologies[i]->evaluationResult.falsePositives
65 <<
", " << selectedTopologies[i]->evaluationResult.averageRecognitionRuntime << std::endl;
73 double elapsedRuntime,
const std::string&
patternName)
76 s << numEvaluatedTopologies <<
" , " << numOptimizationRounds <<
" , " << elapsedRuntime;
83 const std::string& topologyName, std::map<std::string, std::vector<ISM::VoteSpecifierPtr>> objectDefinitons)
86 if(!boost::filesystem::exists(filePath))
87 boost::filesystem::create_directories(filePath);
89 filePath /= topologyName;
90 if(!boost::filesystem::exists(filePath))
91 boost::filesystem::create_directories(filePath);
94 std::ostringstream os;
97 for (ObjectRelations::iterator it = objectRelations.begin(); it != objectRelations.end(); ++it)
99 os <<
":" << std::to_string(it->first);
106 os <<
"False Positives, False Negatives, Average Evaluation Duration" << std::endl;
108 writeToFile(filePath /
"evaluationResult.csv", os.str());
110 mDotHelper->storeISMToDot(filePath, patternName, topologyName, objectDefinitons);
114 mDotHelper->storeRelationsToDot(filePath, patternName, topologyName,
119 mDotHelper->storeRelationsToDot(filePath, patternName, topologyName, objectRelations);
127 std::ios_base::iostate exceptionMask = file.exceptions() | std::ios::failbit | std::ios::badbit;
128 file.exceptions(exceptionMask);
131 file.open(filePath.string());
136 catch (std::ios_base::failure& e)
138 std::cerr << e.what() <<
"\n";
147 if(!boost::filesystem::exists(dbPath.parent_path()))
148 boost::filesystem::create_directories(dbPath.parent_path());
150 if (!boost::filesystem::exists(dbPath))
158 localTableHelper->createTablesIfNecessary();
162 for (
const std::string& typeIt : ism->objectTypes)
164 localTableHelper->ensureModelObjectType(typeIt);
166 for (
const std::pair<std::string, PatternPtr>& patternIt : ism->patternDefinitions)
168 localTableHelper->upsertModelPattern(patternIt.second->name,
169 patternIt.second->expectedMaxWeight);
172 unsigned int numVotes = 0;
173 unsigned int numVotesInserted = 0;
175 for (
const std::pair<std::string, std::vector<VoteSpecifierPtr> >& objectTypeIt : ism->voteSpecifiersPerObject)
177 numVotes += objectTypeIt.second.size();
180 for (std::pair<
const std::string, std::vector<VoteSpecifierPtr> >& objectTypeIt : ism->voteSpecifiersPerObject)
182 if (objectTypeIt.second.size() == 0)
188 localTableHelper->insertModelVoteSpecifier(voteIt);
197 std::cerr<<
"soci error\n"<<e.what()<<std::endl;
210 path dbPath =
mOutputPath /
"SQL" / (filename +
".sqlite");
219 if(!boost::filesystem::exists(filePath))
220 boost::filesystem::create_directories(filePath);
224 mDotHelper->storeRelationsToDot(filePath, patternName, topologyName,
229 mDotHelper->storeRelationsToDot(filePath, patternName, topologyName, topology->objectRelations);
double averageRecognitionRuntime
boost::shared_ptr< CostFunction< InstanceType >> CostFunctionPtr
unsigned int falseNegatives
void storeTopologiesToCSV(std::vector< TopologyPtr > selectedTopologies, const std::string &patternNames)
void writeIsmToDB(path dbPath, const IsmPtr &ism)
void writeToFile(path filePath, const std::string &content)
unsigned int falsePositives
void storeTopology(TopologyPtr toStore, const std::string &patternName, const std::string &topologyName, std::map< std::string, std::vector< ISM::VoteSpecifierPtr >> objectDefinitons)
static void displayProgress(double progress)
void storeMetadataToCSV(unsigned int numEvaluatedTopologies, unsigned int numOptimizationRounds, double elapsedRuntime, const std::string &patternName)
boost::shared_ptr< TableHelper > TableHelperPtr
boost::shared_ptr< Topology > TopologyPtr
unsigned int mSelectedTopologyCounter
static void logMessage(const std::string &message, LogLevel logLevel=LOG_INFO, const char *logColor=LOG_COLOR_DEFAULT)
void storeOptimizationRun(std::vector< std::vector< std::pair< TopologyPtr, unsigned int >>> &history, CostFunctionPtr< TopologyPtr > globalCostFunction, double elapsedRuntime, const std::string &patternName)
std::map< unsigned int, ISM::ObjectRelationPtr, std::less< unsigned > > ObjectRelations
boost::shared_ptr< ImplicitShapeModel > IsmPtr
const std::string SELECTED_TOPOLOGIES_FOLDER
const std::string CSV_SUBFOLDER_NAME
boost::shared_ptr< VoteSpecifier > VoteSpecifierPtr
const std::string TOPOLOGIES_SUBFOLDER_NAME
this namespace contains all generally usable classes.
TopologyPtr mReferenceTopology
void storeIsm(const std::string &filename, const IsmPtr &ism)
void setReferenceTopology(TopologyPtr topology, const std::string &patternName)