Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationGroupRequestStatisticsCSVComparisonAnalyser.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_TEST_EVALUATION_CREASONEREVALUATIONGROUPREQUESTSTATISTICSCSVCOMPARISONANALYSER_H
22 #define KONCLUDE_TEST_EVALUATION_CREASONEREVALUATIONGROUPREQUESTSTATISTICSCSVCOMPARISONANALYSER_H
23
24 // Libraries includes
25 #include <QMap>
26 #include <QSet>
27 #include <QFile>
28 #include <QDir>
29 #include <qglobal.h>
30 #include <qmath.h>
31
32 // Namespace includes
33 #include "EvaluationSettings.h"
34 #include "CReasonerEvaluationGNUPlotPlotter.h"
35 #include "CReasonerEvaluationHighchartPlotter.h"
36 #include "CReasonerEvaluationAnalyseContext.h"
37 #include "CReasonerEvaluationGroupRequestReasonerComparisonAnalyser.h"
38 #include "CReasonerEvaluationDataValueGroupCollectionReasonerComparison.h"
39 #include "CReasonerEvaluationDoubleDataValue.h"
40 #include "CReasonerEvaluationTableMultiFormatOutputWriter.h"
41 #include "CReasonerEvaluationFiltering.h"
42 #include "CReasonerEvaluationStringListValue.h"
43
44
45 // Other includes
46 #include "Config/CConfiguration.h"
47
48 // Logger includes
49 #include "Logger/CLogger.h"
50
51
52
53 namespace Konclude {
54
55 using namespace Config;
56
57 namespace Test {
58
59 namespace Evaluation {
60
61
62
63 class CRequestStatisticsData {
64 public:
65 CRequestStatisticsData() {
66 mInitialized = false;
67 mCalculated = false;
68 mMinValue = DOUBLE_MAX;
69 mMaxValue = DOUBLE_MIN;
70 mSumValue = 0.;
71 mMeanValue = 0.;
72 mValueCount = 0.;
73 mStandardDerivationValue = 0.;
74 mMedianValue = 0.;
75 }
76
77 CRequestStatisticsData* setDataName(const QString& dataName) {
78 mDataName = dataName;
79 return this;
80 }
81
82 CRequestStatisticsData* addData(double value, const QString& requestString) {
83 mDataRequestStringMap.insertMulti(value,requestString);
84 return this;
85 }
86
87 bool calculateStatistics() {
88 if (!mCalculated) {
89 mCalculated = true;
90 for (QMap<double,QString>::const_iterator it = mDataRequestStringMap.constBegin(), itEnd = mDataRequestStringMap.constEnd(); it != itEnd; ++it) {
91 double value(it.key());
92 mMinValue = qMin(mMinValue,value);
93 mMaxValue = qMax(mMaxValue,value);
94 mSumValue += value;
95 mValueCount += 1;
96 }
97 if (mValueCount > 0) {
98 mMeanValue = mSumValue/mValueCount;
99 cint64 medianCounter = mValueCount/2.;
100 for (QMap<double,QString>::const_iterator it = mDataRequestStringMap.constBegin(), itEnd = mDataRequestStringMap.constEnd(); it != itEnd; ++it) {
101 double value(it.key());
102 mStandardDerivationValue += (value-mMeanValue)*(value-mMeanValue);
103 if (medianCounter >= 0) {
104 mMedianValue = value;
105 medianCounter = medianCounter-1.;
106 }
107 }
108 mStandardDerivationValue = qSqrt(mStandardDerivationValue/(mValueCount+1.0));
109 }
110 }
111 return mCalculated;
112 }
113
114 public:
115 QMap<double,QString> mDataRequestStringMap;
116 QString mDataName;
117 bool mInitialized;
118 bool mCalculated;
119 double mMinValue;
120 double mMaxValue;
121 double mMeanValue;
122 double mStandardDerivationValue;
123 double mSumValue;
124 double mMedianValue;
125 double mValueCount;
126 };
127
128
129 /*!
130 *
131 * \class CReasonerEvaluationGroupRequestStatisticsCSVComparisonAnalyser
132 * \author Andreas Steigmiller
133 * \version 0.1
134 * \brief TODO
135 *
136 */
137 class CReasonerEvaluationGroupRequestStatisticsCSVComparisonAnalyser : public CReasonerEvaluationGroupRequestReasonerComparisonAnalyser {
138 // public methods
139 public:
140 //! Constructor
141 CReasonerEvaluationGroupRequestStatisticsCSVComparisonAnalyser(CReasonerEvaluationFiltering* filtering);
142
143 //! Destructor
144 virtual ~CReasonerEvaluationGroupRequestStatisticsCSVComparisonAnalyser();
145
146
147
148 QString getPrettyTitleFromOutputFile(const QString& outputFile);
149
150
151 // protected methods
152 protected:
153 virtual bool analyseGroupedEvaluationData(const QStringList& groubList, const QStringList& requestList, const QStringList& reasonerList, const QString& outputDirectory, CReasonerEvaluationAnalyseContext* context, CReasonerEvaluationGroupRequestSelector* selector);
154
155 // protected variables
156 protected:
157 CReasonerEvaluationFiltering* mFiltering;
158 QString mOutputFileName;
159
160 // private methods
161 private:
162
163 // private variables
164 private:
165
166 };
167
168 }; // end namespace Evaluation
169
170 }; // end namespace Test
171
172 }; // end namespace Konclude
173
174 #endif // KONCLUDE_TEST_EVALUATION_CREASONEREVALUATIONGROUPREQUESTSTATISTICSCSVCOMPARISONANALYSER_H