Page MenuHomePhorge

No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None
diff --git a/include/rosa/agent/Reliability.h b/include/rosa/agent/Reliability.h
index 9425a37..43d5413 100644
--- a/include/rosa/agent/Reliability.h
+++ b/include/rosa/agent/Reliability.h
@@ -1,30 +1,83 @@
//===-- rosa/agent/Reliability.h --------------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/agent/Reliability.h
///
/// \author Daniel Schnoell (danielschnoell@tuwien.ac.at)
///
/// \date 2019
///
/// \brief Declaration of `rosa::Reliability` base-class.
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_AGENT_RELIABILITY_H
#define ROSA_AGENT_RELIABILITY_H
#include "rosa/agent/Functionality.h"
+#include "rosa/agent/LinearFunction.h"
+
+#include <vector>
namespace rosa {
namespace agent {
-class Reliability : public Functionality {};
+template <typename Type> class Reliability_LowLevel : public Functionality {
+
+ std::vector<Type> Sensor_History;
+
+
+ float getRelibility(
+ float actualValue, float lastValue,
+ unsigned int valueSetCounter /*, int actualScore, int lastScore*/) {
+
+ float rel, relAbs, relSlo;
+
+ relAbs = getAbsoluteReliability(actualValue);
+ relSlo = getSlopeReliability(actualValue, lastValue,
+ valueSetCounter /*, actualScore, lastScore*/);
+
+ // calculate signal input reliability
+ // NOTE: options would be multiply, average, AND (best to worst:
+ // average = AND > multiply) rel = relAbs * relSlo; rel = (relAbs +
+ // relSlo)/2;
+ rel = std::min(relAbs, relSlo);
+
+ return rel;
+
+ /*
+ if (relAbs <= relSlo)
+ return relAbs;
+ else
+ return relSlo;
+ */
+ }
+
+ Type getInputReliability(float actualSensorValue) {
+
+ float inputReliability;
+ float previousSensorValue;
+
+ if (Sensor_History.size() > 0) {
+ inputReliability = reliabilityModule->getRelibility(
+ actualSensorValue, previousSensorValue,
+ mountedAgent->getValueSetCounter());
+ } else {
+ inputReliability =
+ reliabilityModule->getAbsoluteReliability(actualSensorValue);
+ }
+#ifdef PRINT
+ printf("rel = %f\n", inputReliability);
+#endif // PRINT
+
+ return inputReliability;
+ }
+};
} // namespace agent
} // namespace rosa
#endif // !ROSA_AGENT_RELIABILITY_H
diff --git a/include/rosa/agent/bs_file.h b/include/rosa/agent/bs_file.h
new file mode 100644
index 0000000..1e1007e
--- /dev/null
+++ b/include/rosa/agent/bs_file.h
@@ -0,0 +1,91 @@
+class Reliability_LowLevel : public Functionality {
+ float Agent::getInputReliability(SensorSlotOfAgent *mountedAgent,
+ float actualSensorValue) {
+ float inputReliability;
+ float previousSensorValue;
+
+// calculate input reliability
+#ifdef PRINT
+ printf("%s - ", name.c_str());
+#endif // PRINT
+ if (mountedAgent->getPreviousSensorValue(&previousSensorValue)) {
+ inputReliability = reliabilityModule->getRelibility(
+ actualSensorValue, previousSensorValue,
+ mountedAgent->getValueSetCounter());
+ } else {
+ inputReliability =
+ reliabilityModule->getAbsoluteReliability(actualSensorValue);
+ }
+#ifdef PRINT
+ printf("rel = %f\n", inputReliability);
+#endif // PRINT
+
+ return inputReliability;
+ }
+
+ void Agent::combineConfidenceAndReliabilityOfActualPossibleScores(
+ vector<PossibleScore *> *actualPossibleScores, float inputReliability) {
+ for (auto &pS : *actualPossibleScores) {
+ // combine input reliability with score confidence
+ // NOTE: multiplication, AND, or average would be alternatives (best to
+ // worst: AND = Multiplication >> Avg) pS->confOrRel = pS->confOrRel *
+ // inputReliability; pS->confOrRel = (pS->confOrRel + inputReliability) /
+ // 2;
+ pS->confOrRel = std::min(pS->confOrRel, inputReliability);
+ combineConfidenceAndReliabilityOfActualPossibleScores(
+ actualPossibleScores, inputReliability);
+
+ for (auto &sS : *suggestedScores) {
+ for (auto &aPs : *actualPossibleScores) {
+ if (aPs->score == sS->score) {
+ // combine suggested score with actual score
+ // NOTE: multiplication, AND, or average would be alternatives (best
+ // to worst: AND > multiplication >> average) aPs->confOrRel =
+ // std::min(aPs->confOrRel, sS->confOrRel);
+ aPs->confOrRel = (aPs->confOrRel + sS->confOrRel);
+ // aPs->confOrRel = aPs->confOrRel * sS->confOrRel;
+ }
+ }
+ }
+
+ // save actual possible scores in history
+ saveActualPossibleScoresInHistory(actualPossibleScores);
+
+ // evaluate all possible scores (based on the history)
+ vector<PossibleScore *> possibleScores;
+
+ // printf("SIZE BEFORE: %u\n", possibleScores.size());
+
+ getAllPossibleScoresBasedOnHistory(&possibleScores);
+
+ // printf("SIZE AFTER: %u\n", possibleScores.size());
+
+ // sort all possible scores so that outputRel_i >= outputRel_i+1
+ std::sort(possibleScores.begin(), possibleScores.end(), compareByConfRel);
+
+ // send possible scores to high level agent
+ // sendPossibleScoresToMaster(&possibleScores);
+
+ for (auto &pS : possibleScores) {
+#ifdef PRINT
+ printf(" > possible Score %i / %f\n", pS->score, pS->confOrRel);
+#endif // PRINT
+ }
+
+ // send most likely score to high level agent
+ sendMostLikelyScoreToMaster(&possibleScores);
+ }
+ }
+
+ void run() { mountedAgent->get_sensorValue(&actualSensorValue);
+ vector<PossibleScore *> *actualPossibleScores =
+ scoreConfidenceModule->getScoresWithConfidences(actualSensorValue);
+ inputReliability = getInputReliability(mountedAgent, actualSensorValue);
+
+ masterAgentHandlerOfAgent->clearSuggestedScores();
+ masterAgentHandlerOfAgent->read_masterAgentValues();
+
+ vector<PossibleScore *> *suggestedScores =
+ masterAgentHandlerOfAgent->getSuggestedScores();
+ }
+};
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 17, 7:22 AM (19 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
141514
Default Alt Text
(6 KB)

Event Timeline