← Documentation
ADS-IDAC Engine 5.0.0
InformationLoadModule.cpp
Go to the documentation of this file.
1// InformationLoadModule.cpp: implementation of the InformationLoadModule class.
2//
4
6#include <boost/serialization/export.hpp>
7#include <boost/archive/binary_oarchive.hpp>
8#include <boost/archive/binary_iarchive.hpp>
9BOOST_CLASS_EXPORT_IMPLEMENT(InformationLoadModule)
10using namespace std;
11
13// Construction/Destruction
15
17{
19 max_history_size = 120;
20}
21
23{
24
25}
26
28 this->info_load_history.clear();
29 this->time_history.clear();
30}
31
40
41void InformationLoadModule::addInformationLoadData(double _time, double _load){
42 this->time_history.push_back(_time);
43 this->info_load_history.push_back(_load);
44 while ( this->info_load_history.size() > this->max_history_size) {
45 this->info_load_history.pop_front();
46 this->time_history.pop_front();
47 }
48}
50 int size = this->time_history.size();
51 double delta_time = 0.0;
52 double load_sum = 0.0;
53 double average_load;
54 double new_info_load_pif_value = 0.0;
55 std::deque<double>::iterator load_itr;
56 if (size > 0) {
57 delta_time = this->time_history.at(size-1) - this->time_history.at(0);
58 } else {
59 delta_time = 0.0;
60 }
61 for (load_itr = this->info_load_history.begin() ; load_itr != this->info_load_history.end() ; load_itr ++) {
62 load_sum += (*load_itr);
63 }
64 if (delta_time > 0.001) {
65 average_load = 60.0 * load_sum/delta_time; // info items per minute
66 } else {
67 average_load = 0.0;
68 }
69 if (average_load > upper_info_load_threshold) {
70 new_info_load_pif_value = 10.0;
71 } else if (average_load < lower_info_load_threshold) {
72 new_info_load_pif_value = 0.0;
73 } else {
74 new_info_load_pif_value = 10.0*(average_load - lower_info_load_threshold)/(upper_info_load_threshold-lower_info_load_threshold);
75 }
76 // apply lag filter to info load to smooth pif factor
77 info_load_pif_value += (new_info_load_pif_value - info_load_pif_value)/10.0;
78 //
79 // ensure PIF value is in the range of 0.0 - 10.0
80 info_load_pif_value = std::max<double>(0.0, info_load_pif_value);
81 info_load_pif_value = std::min<double>(10.0,info_load_pif_value);
83}
84
85void InformationLoadModule::outputInformationLoadModuleLabelToFile(std::string _str, std::ofstream &fout) {
86 fout << '\t'<< _str << "Info_Load_PIF_Value";
87}
89 fout << "\t Range:_0-10";
90}
91
97 for (int i = 0 ; i != _ilm.info_load_history.size() ; i++) {
98 this->info_load_history.push_back( _ilm.info_load_history.at(i));
99 this->time_history.push_back( _ilm.time_history.at(i));
100 }
101}
103 fout << "InfoLoadPIF" << '\n';
104 fout << info_load_pif_value << ' ' << max_history_size << ' '
106 fout << this->info_load_history.size() << '\n';
107 for (int i = 0 ; i != this->info_load_history.size() ; i++) {
108 fout << this->time_history.at(i) << ' ' << this->info_load_history.at(i) << '\n';
109 }
110}
112 int i, num;
113 double x_time, x_info_load;
114 std::string str;
115 fin >> str;
118 fin >> num;
119 for (i = 0 ; i != num ; i++) {
120 fin >> x_time >> x_info_load;
121 this->time_history.push_back(x_time);
122 this->info_load_history.push_back(x_info_load);
123 }
124}
double calculateAverageInformationLoadPIFValue()
void outputInformationLoadModuleUnitsToFile(std::ofstream &)
std::deque< double > info_load_history
void retreiveInformationLoadModuleFromFile(std::ifstream &)
void saveInformationLoadModuleToFile(std::ofstream &)
void addInformationLoadData(double, double)
std::deque< double > time_history
void outputInformationLoadModuleLabelToFile(std::string, std::ofstream &)
void copyInformationLoadModule(InformationLoadModule &)
int size
Total number of MPI processes.