Digitalisierte Elektroverteilung zur permanenten Verbraucherüberwachung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Evaluator.cpp 1.0KB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637
  1. #include "Evaluator.h"
  2. #include <easylogging++.h>
  3. #include "SystemConfig.h"
  4. Evaluator::Evaluator()
  5. {
  6. //initialize Linear Regression Analysis on Residual Current Register
  7. CappedStorage* storageP = DataModel::Instance()->getPermanentData(ModbusRegister::BENDER_Residual_current);
  8. if(storageP != nullptr){
  9. MLAlgorithms.push_back(std::make_unique<MLLinReg>(storageP));
  10. }
  11. else
  12. LOG(ERROR) << "Tried to invoke ML-Algorithm on non permanent or non existing parameter storage";
  13. }
  14. inline std::ostream& operator<<(std::ostream& os, std::vector<float>& vec) {
  15. std::for_each(vec.begin(), vec.end(), [&os](float a) {os << a << " "; });
  16. return os;
  17. }
  18. //update all registered models
  19. std::vector<MLAlert> Evaluator::evaluate()
  20. {
  21. std::vector<MLAlert> alerts;
  22. for(auto &a: MLAlgorithms){
  23. MLAlert alert = a->updateModel();
  24. if(alert.type != CustomAlertTypes::NO_ALERT)
  25. alerts.push_back(alert);
  26. }
  27. for(auto &a: alerts)
  28. LOG(WARNING) << a.message;
  29. return alerts;
  30. }