Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser.cpp

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 #include "CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31
32 CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser::CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser() {
33 }
34
35
36 CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser::~CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser() {
37 }
38
39
40 bool CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser::analyseGroupedEvaluationData(const QStringList& groubList, const QStringList& requestList, const QStringList& reasonerList, const QString& outputDirectory, CReasonerEvaluationAnalyseContext* context, CReasonerEvaluationGroupRequestSelector* selector) {
41
42 mOutputFileName = QString("%1").arg(selector->getOutputString());
43
44 QDir outDir(outputDirectory);
45 outDir.mkpath(mOutputFileName);
46 QString outputFileString(outputDirectory+mOutputFileName+context->getAdditionalFileString()+"values");
47
48
49 QStringList titleList;
50 titleList.append("Requests");
51 titleList.append(reasonerList);
52 titleList.append("Average");
53 titleList.append("Min");
54 titleList.append("Max");
55
56 CReasonerEvaluationTableMultiFormatOutputWriter<double> tableMultiFormatOutputWriter;
57 tableMultiFormatOutputWriter.addColumnTitles(titleList);
58
59
60 bool hasSelectedRequestFile = false;
61
62 foreach (QString groupString, groubList) {
63
64 if (selector->isGroupSelected(groupString)) {
65
66 QSet<QString>* groupRequestList = getGroupRequests(groupString);
67 foreach (QString requestString, *groupRequestList) {
68
69 if (selector->isRequestSelected(groupString,requestString)) {
70
71
72
73 bool allDataAvailable = true;
74 foreach (QString reasonerString, reasonerList) {
75 CReasonerEvaluationDataValue* evalData = getGroupRequestReasonerEvaluationData(groupString,requestString,reasonerString);
76 if (!evalData || evalData->hasDataNotAvailableFlag()) {
77 allDataAvailable = false;
78 }
79 }
80
81
82 if (allDataAvailable) {
83
84
85 hasSelectedRequestFile = true;
86 double min = DOUBLE_MAX;
87 double max = DOUBLE_MIN;
88 double mean = 0.;
89 cint64 count = 0;
90
91 tableMultiFormatOutputWriter.addNewTableRow(requestString);
92
93 foreach (QString reasonerString, reasonerList) {
94 CReasonerEvaluationDataValue* evalData = getGroupRequestReasonerEvaluationData(groupString,requestString,reasonerString);
95 CReasonerEvaluationDoubleDataValue* doubleDataValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(evalData);
96 if (doubleDataValue) {
97
98 double tmpValue = doubleDataValue->getValue();
99 tableMultiFormatOutputWriter.addValuesToLastTableRow(QList<double>()<<tmpValue);
100
101 mean += tmpValue;
102 min = qMin(min,tmpValue);
103 max = qMax(max,tmpValue);
104 count++;
105 } else {
106 tableMultiFormatOutputWriter.addValuesToLastTableRow(QList<double>()<<0);
107 }
108 }
109 mean /= (double)count;
110 tableMultiFormatOutputWriter.addValuesToLastTableRow(QList<double>()<<mean<<min<<max);
111
112 }
113 }
114 }
115 }
116 }
117
118 if (hasSelectedRequestFile) {
119
120 QStringList reasonerCompGNUPlotFileList;
121 QStringList reasonerCompHighchartPlotFileList;
122
123 tableMultiFormatOutputWriter.buildSortedIndex();
124 reasonerCompHighchartPlotFileList += tableMultiFormatOutputWriter.writeCVSTable(outputFileString);
125
126
127 if (context->isGNUPlottingActivated()) {
128 reasonerCompGNUPlotFileList += tableMultiFormatOutputWriter.writeGNUPlotDataTable(outputFileString);
129 foreach (QString plotFileString, reasonerCompGNUPlotFileList) {
130 if (true /*plotFileString.contains("-by-Average-")*/) {
131 QString outputFile = plotFileString;
132 outputFile.remove(".dat");
133 QString title = getPrettyTitleFromOutputFile(outputFile);
134 context->getGNUPlotPlotter()->createReasonerComparisonPlot(plotFileString,title,reasonerList,outputFile);
135 }
136 }
137 }
138 if (context->isHighchartPlottingActivated()) {
139 foreach (QString plotFileString, reasonerCompHighchartPlotFileList) {
140 if (true /*plotFileString.contains("-by-Average-")*/) {
141 QString outputFile = plotFileString;
142 outputFile.remove(".csv");
143 QString title = getPrettyTitleFromOutputFile(outputFile);
144 context->getHighchartPlotter()->createReasonerComparisonPlot(plotFileString,title,reasonerList,outputFile,selector->getNameString()+" :: "+context->getAdditionalTitleString());
145 }
146 }
147 }
148
149
150
151
152 QStringList mmmExtendedReasonerListGNU(reasonerList);
153 mmmExtendedReasonerListGNU<<"Average"<<"Max"<<"Min";
154 QStringList reasonerOverPlotFileList;
155 if (context->isGNUPlottingActivated()) {
156 reasonerOverPlotFileList = tableMultiFormatOutputWriter.writeGNUPlotDataTablesSeparateSorted(outputFileString);
157 foreach (QString plotFileString, reasonerOverPlotFileList) {
158 if (true) {
159 QString outputFile = plotFileString;
160 outputFile.remove(".dat");
161 QString title = getPrettyTitleFromOutputFile(outputFile);
162 context->getGNUPlotPlotter()->createReasonerOverviewPlot(plotFileString,title,reasonerList,outputFile);
163 context->getGNUPlotPlotter()->createReasonerOverviewPlot(plotFileString,title,mmmExtendedReasonerListGNU,outputFile+"-mmm");
164 }
165 }
166 }
167
168 QStringList mmmExtendedReasonerListHC(reasonerList);
169 mmmExtendedReasonerListHC<<"Max"<<"Min";
170 QStringList reasonerHCOverPlotFileList;
171 if (context->isHighchartPlottingActivated()) {
172 reasonerHCOverPlotFileList = tableMultiFormatOutputWriter.writeCVSTablesSeparateSorted(outputFileString);
173 foreach (QString plotFileString, reasonerHCOverPlotFileList) {
174 if (true) {
175 QString outputFile = plotFileString;
176 outputFile.remove(".csv");
177 QString title = getPrettyTitleFromOutputFile(outputFile);
178 context->getHighchartPlotter()->createReasonerOverviewPlot(plotFileString,title,reasonerList,outputFile,selector->getNameString()+" :: "+context->getAdditionalTitleString());
179 context->getHighchartPlotter()->createReasonerOverviewPlot(plotFileString,title,mmmExtendedReasonerListHC,outputFile+"-mmm",selector->getNameString()+" :: "+context->getAdditionalTitleString());
180 }
181 }
182 }
183 }
184
185 return true;
186 }
187
188
189 QString CReasonerEvaluationGroupRequestReasonerStatisticValueCSVComparisonAnalyser::getPrettyTitleFromOutputFile(const QString& outputFile) {
190 QString title = outputFile;
191 title.remove("table");
192 cint64 slashPos = title.lastIndexOf("/");
193 if (slashPos >= 0) {
194 title = title.mid(slashPos+1);
195 }
196 title.replace("-"," ");
197 title.replace("mmm","Comparision,");
198 title.replace("sorted","Sorted");
199 title.replace("separate","Separate");
200
201 return title;
202 }
203
204
205 }; // end namespace Evaluation
206
207 }; // end namespace Test
208
209 }; // end namespace Konclude