19 #include<utils/CmdInterface.hh> 34 string description=
"Usage:\t history_compare --help\n\t history_compare hist1.archv hist2.archv\n\n\t Produce a set of data files with the evolution of performance indicators through the histories.";
44 const History & history2,
const string & prefix);
46 int main(
int argc,
char * argv[])
54 printError(
"Wrong command line. Try option --help.");
60 if(getOption<Option>(argv[index],
options,currentOption))
62 if(
isSet[currentOption])
68 isSet[currentOption] =
true;
74 if((index!=1) || (argc !=2))
86 printError(
"Unrecognized option: " +
string(argv[index]));
94 vector<string>::const_iterator it =
98 printError(
"Unrecognized file extension in file name: " +
string(argv[index]));
100 if(histFile1.empty())
102 histFile1 = string(argv[index]);
106 if(histFile2.empty())
108 histFile2 = string(argv[index]);
112 printError(
"Expecting two history files but get at least three.");
118 if(histFile1.empty() || histFile2.empty())
120 printError(
"Cannot get two history file from the command line.");
123 { verbose<VbOutput>(
"Loading the history %1%...") % histFile1; }
126 std::ifstream ifs(histFile1);
127 boost::archive::text_iarchive ia(ifs);
135 { verbose<VbOutput>(
"Done.\n"); }
136 { verbose<VbOutput>(
"Loading the history %1%...") % histFile2; }
139 std::ifstream ifs(histFile2);
140 boost::archive::text_iarchive ia(ifs);
144 Diagnosis diag1 = history1.getDiagnosis(history1.lastTimePoint());
145 Diagnosis diag2 = history2.getDiagnosis(history2.lastTimePoint());
148 if( (history1.lastTimePoint()-history1.initialTimePoint()) > (history2.lastTimePoint()-history2.initialTimePoint()) )
150 history2.publishDiagnosis(history2.initialTimePoint() + (history1.lastTimePoint()-history1.initialTimePoint()),history2.getDiagnosis(history2.lastTimePoint()));
154 if ((history2.lastTimePoint()-history2.initialTimePoint()) > (history1.lastTimePoint()-history1.initialTimePoint()))
156 history1.publishDiagnosis(history1.initialTimePoint() + (history2.lastTimePoint()-history2.initialTimePoint()),history1.getDiagnosis(history1.lastTimePoint()));
165 { verbose<VbOutput>(
"Done.\n"); }
167 { verbose<VbOutput>(
"Comparison... History 1 (%1%) History 2 (%2%)\n") % histFile1 % histFile2 ; }
173 { verbose<VbOutput>(
"Comparison... History 1 Perfect\n"); }
175 { verbose<VbOutput>(
"Comparison... History 2 Perfect\n"); }
179 perfect2.publishDiagnosis(perfect2.initialTimePoint() + (history2.lastTimePoint()-history2.initialTimePoint()), diag2);
190 const History & history2,
const string & prefix)
192 list< pair<ptime,int> > results;
195 file.open(prefix +
"Distance.data");
196 for(
const pair<ptime,int> & point : results)
198 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
204 file.open(prefix +
"FcDistance.data");
205 for(
const pair<ptime,int> & point : results)
207 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
213 file.open(prefix +
"CommonFaults.data");
214 for(
const pair<ptime,int> & point : results)
216 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
222 file.open(prefix +
"NonCommonFaults.data");
223 for(
const pair<ptime,int> & point : results)
225 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
231 file.open(prefix +
"BsDistance.data");
232 for(
const pair<ptime,int> & point : results)
234 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
238 list< pair<ptime,double> > results2;
240 file.open(prefix +
"Accuracy.data");
241 for(
const pair<ptime,double> & point : results2)
243 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
249 file.open(prefix +
"BsAccuracy.data");
250 for(
const pair<ptime,double> & point : results2)
252 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
258 file.open(prefix +
"FcAccuracy.data");
259 for(
const pair<ptime,double> & point : results2)
261 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
267 file.open(prefix +
"Precision.data");
268 for(
const pair<ptime,double> & point : results2)
270 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
276 file.open(prefix +
"BsPrecision.data");
277 for(
const pair<ptime,double> & point : results2)
279 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
285 file.open(prefix +
"FcPrecision.data");
286 for(
const pair<ptime,double> & point : results2)
288 file << (point.first - history1.
initialTimePoint()).total_seconds() <<
'\t' << point.second << endl;
void publishDiagnosis(ptime t, const Diagnosis &d)
InputIterator getFileExtension(const std::basic_string< CharType, CharTraits > &fileName, InputIterator begin, InputIterator end)
vector< string > fileExtensions(numberOfFileExtensions)
void setVerboseLevel(Diades::Utils::VerboseLevel level)
vector< bool > isSet(numberOfOptions, false)
unsigned numberOfFileExtensions
int main(int argc, char *argv[])
ptime initialTimePoint() const
void makeComparison(const History &history1, const History &history2, const string &prefix)
vector< string > options(numberOfOptions)
void printError(string parameter, string message)
void historyCompare(const History &history1, const History &history2, DiagnosisComparisonFunctor compare, list< pair< ptime, typename DiagnosisComparisonFunctor::ValueType > > &result)
void printUsage(const po::options_description &desc)