Tester.cpp
Go to the documentation of this file.
1 
18 #include "Tester.hpp"
19 
20 #include <boost/thread.hpp>
21 
22 #include "../typedef.hpp"
23 #include "../utility/LogHelper.hpp"
24 
25 namespace ISM
26 {
28  {
30 
31  mObjectSetValidator->setISM(ism);
32 
34 
35  std::vector<ISM::ObjectSetPtr> invalidTestSets = mInvalidTestSetsPerPattern.at(patternName);
36  std::vector<ISM::ObjectSetPtr> validTestSets = mValidTestSetsPerPattern.at(patternName);
37 
38  mNumTestsDone = 0;
39  mNumTests = invalidTestSets.size();
40 
42  {
43  mNumTests += validTestSets.size();
44  }
45 
47  unsigned falsePositives = evaluateTestSets(invalidTestSets, patternName, false);
48 
49  unsigned falseNegatives = 0;
51  {
52  falseNegatives = evaluateTestSets(validTestSets, patternName, true);
53  }
55 
56  double averageEvaluationDuration = mEvaluationRuntime / mNumTests;
57 
58  EvaluationResult er = {falsePositives,
59  falseNegatives,
60  averageEvaluationDuration};
61 
62  LogHelper::logMessage("\n\nEvaluation result is: ", LOG_INFO, LogHelper::LOG_COLOR_BLUE);
64 
65  return er;
66  }
67 
68  unsigned Tester::evaluateTestSets(const std::vector<ISM::ObjectSetPtr>& testSets, const std::string& patternName,
69  bool expectedValue)
70  {
71  unsigned numUnexpectedResults = 0;
72 
73  for (unsigned i = 0; i < testSets.size(); ++i)
74  {
75  std::pair<bool, double> result = mObjectSetValidator->isSetValid(testSets[i], patternName);
76 
77  if (expectedValue != result.first)
78  {
79  numUnexpectedResults++;
80  }
81 
82  mEvaluationRuntime += result.second;
83 
84  mNumTestsDone++;
86  }
87 
88  return numUnexpectedResults;
89  }
90 
91  std::string Tester::getDescription() {
92  std::stringstream s;
93  s << "Evaluator is Tester.cpp:" << std::endl
94  << "- Calcualtes the number of false positives and false negatives and the average evaluation runtime."
95  << std::endl;
96  return s.str();
97  }
98 }
99 
unsigned int mNumTestsDone
Definition: Tester.hpp:56
ISM::ObjectSetValidatorPtr mObjectSetValidator
Definition: Tester.hpp:49
PatternNameToObjectSet mInvalidTestSetsPerPattern
Definition: Tester.hpp:51
EvaluationResult evaluate(std::string patternName, const IsmPtr &ism)
Definition: Tester.cpp:27
static void displayProgress(double progress)
Definition: LogHelper.cpp:147
std::string patternName
std::string getDescription()
Definition: Tester.cpp:91
static void logMessage(const std::string &message, LogLevel logLevel=LOG_INFO, const char *logColor=LOG_COLOR_DEFAULT)
Definition: LogHelper.cpp:96
bool mTestForFalseNegatives
Definition: Tester.hpp:54
boost::shared_ptr< ImplicitShapeModel > IsmPtr
unsigned evaluateTestSets(const std::vector< ISM::ObjectSetPtr > &testSets, const std::string &patternName, bool expectedValue)
Definition: Tester.cpp:68
unsigned int mNumTests
Definition: Tester.hpp:55
static const char * LOG_COLOR_BLUE
Definition: LogHelper.hpp:44
double mEvaluationRuntime
Definition: Tester.hpp:58
this namespace contains all generally usable classes.
std::string getDescription()
PatternNameToObjectSet mValidTestSetsPerPattern
Definition: Tester.hpp:52


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41