WeightedSum.cpp
Go to the documentation of this file.
1 
19 
21 
22 WeightedSum::WeightedSum(unsigned int minFalsePositives, unsigned int maxFalsePositives,
23  unsigned int minFalseNegatives, unsigned int maxFalseNegatives,
24  double minAverageRecognitionRuntime, double maxAverageRecognitionRuntime,
25  double alpha, double beta, double gamma)
26  : mMinFalsePositives(minFalsePositives)
27  , mMaxFalsePositives(maxFalsePositives)
28  , mMinFalseNegatives(minFalseNegatives)
29  , mMaxFalseNegatives(maxFalseNegatives)
30  , mMinAverageRecognitionRuntime(minAverageRecognitionRuntime)
31  , mMaxAverageRecognitionRuntime(maxAverageRecognitionRuntime)
32  , mAlpha(alpha)
33  , mBeta(beta)
34  , mGamma(gamma)
35 {}
36 
38 { }
39 
40 // very similar to lib_ism:
42 {
43  std::string fromEarlier = "";
44  if (instance->isCostValid()) fromEarlier = " (from earlier)";
45  else
46  {
47  double normalisedFalsePositives = getNormalisedFalsePositives(instance->getFalsePositives());
48  double normalisedAverageRecognitionRuntime = getNormalisedAverageRecognitionRuntime(instance->getAverageRecognitionRuntime());
49  double normalisedFalseNegatives = getNormalisedFalseNegatives(instance->getFalseNegatives());
50 
51  double cost;
52  if (normalisedFalsePositives < 0 || normalisedFalseNegatives < 0 || normalisedAverageRecognitionRuntime < 0)
53  {
54  cost = std::numeric_limits<double>::infinity();
55  }
56  else
57  {
58  cost = mAlpha * normalisedFalsePositives + mBeta * normalisedAverageRecognitionRuntime + mGamma * normalisedFalseNegatives;
59  }
60 
61  instance->setCost(cost);
62  }
63  ROS_INFO_STREAM("Cost of topology " << instance->mIdentifier << " is " << instance->getCost() << fromEarlier);
64 
65  return instance->getCost();
66 }
67 
68 double WeightedSum::getNormalisedFalsePositives(unsigned int falsePositives)
69 {
70  if (falsePositives > mMaxFalsePositives)
71  {
72  //False Postivies are higher than the false positves of the worst star topology.
73  return -1;
74  }
75 
77  {
78  return 0;
79  }
80 
81  return ((double) (falsePositives - mMinFalsePositives)) / ((double) (mMaxFalsePositives - mMinFalsePositives));
82 }
83 
84 double WeightedSum::getNormalisedFalseNegatives(unsigned int falseNegatives)
85 {
86  if (falseNegatives > mMaxFalseNegatives)
87  {
88  return -1;
89  }
90 
92  {
93  return 0;
94  }
95 
96  return ((double) (falseNegatives - mMinFalseNegatives)) / ((double) (mMaxFalseNegatives - mMinFalseNegatives));
97 }
98 
99 
100 double WeightedSum::getNormalisedAverageRecognitionRuntime(double averageRecognitionRuntime)
101 {
102  if (averageRecognitionRuntime > mMaxAverageRecognitionRuntime)
103  {
104  //Average recognition runtime is longer than the average recognition runtime of the fully meshed topology.
105  return -1;
106  }
107 
108  if (mMaxAverageRecognitionRuntime == averageRecognitionRuntime)
109  {
110  //return 0;
111  return 1;
112  }
113 
114  return (averageRecognitionRuntime - mMinAverageRecognitionRuntime) /
116 }
117 
118 }
WeightedSum(unsigned int minFalsePositives, unsigned int maxFalsePositives, unsigned int minFalseNegatives, unsigned int maxFalseNegatives, double minAverageRecognitionRuntime, double maxAverageRecognitionRuntime, double alpha, double beta, double gamma)
Definition: WeightedSum.cpp:22
double getNormalisedFalseNegatives(unsigned int falseNegatives)
Definition: WeightedSum.cpp:84
double getNormalisedFalsePositives(unsigned int falsePositives)
Definition: WeightedSum.cpp:68
double getNormalisedAverageRecognitionRuntime(double averageRecognitionRuntime)
double calculateCost(boost::shared_ptr< SceneModel::Topology > instance)
Definition: WeightedSum.cpp:41
#define ROS_INFO_STREAM(args)


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 04:00:08