-
Notifications
You must be signed in to change notification settings - Fork 4
/
simple_hello_world_cv_2.cpp
119 lines (82 loc) · 3.3 KB
/
simple_hello_world_cv_2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "simple_hello_world.hpp"
#include "evt/evtapproach_cv.hpp"
#include "statistical/estimator_cv.hpp"
#include "statistical/test_ks.hpp"
#include "statistical/test_ljung_box.hpp"
#include "input/generator_null.hpp"
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace chronovise;
using exit_code_t = AbstractExecutionContext<unsigned int, double>::exit_code_t;
SimpleHelloWorld::SimpleHelloWorld() noexcept {
// Nothing to do...
}
exit_code_t SimpleHelloWorld::onSetup() noexcept {
/* ********** PRE-RUN SECTION ********** */
// In this simple example we are not interested in multi-input programs, so let's define a
// a Null input generator.
std::unique_ptr<chronovise::NullInputGenerator> null_input_gen(new chronovise::NullInputGenerator());
this->set_input_source(std::move(null_input_gen));
/* ********** POST-RUN SECTION ********** */
// Set LjungBox test as the test to be used after the sampling phase.
// 1st parameter: significance level
// 2nd parameter: number of lags for the test
this->use_LjungBox_as_sample_test(0.01, 10);
// Select ENVELOPE as merging technique. The possible values are:
// ENVELOPE: different inputs provide different pWCETs estimation
// MERGER: different inputs generating samples that are merged and only 1 pWCET estimation
// is performed.
this->set_merging_technique(merger_type_e::ENVELOPE);
// Select the EVT approach to use:
// - Block Maxima -> It will generate a GEV
// - PoT -> It will generate a GPD
this->use_evt_approach_CV(0.1);
//this->use_evt_approach_PoT(13.5, 0.1);
// Select the estimator. Currently the only one available is the Maximum-Likelihood-Estimator
this->use_estimator_CV();
// Let's print some debug information
this->print_configuration_info();
this->print_legend();
// Gather input values from file
this->use_file_as_source("test_cv_values.txt");
return AEC_OK;
}
exit_code_t SimpleHelloWorld::onConfigure() noexcept
{
// Since no input generation is provided, we want to execute the estimation only 1 time.
if (get_input_iteration() > 0)
return AEC_OK;
return AEC_CONTINUE;
}
exit_code_t SimpleHelloWorld::onRun() noexcept {
// std::cout << get_iteration() << std::endl;
try {
// Get a sample from the file specified
// in onSetup().
this->add_sample_from_file();
} catch(const std::ios::failure &ex) {
std::cout << std::endl << "INPUT ERROR: "
<< ex.what() << std::endl;
return AEC_INPUT_ERROR;
}
return AEC_OK;
}
exit_code_t SimpleHelloWorld::onMonitor() noexcept {
if (get_iteration() >= 10000) {
return AEC_OK;
} else {
return AEC_CONTINUE;
}
}
exit_code_t SimpleHelloWorld::onRelease() noexcept {
this->print_evt_info();
// Print of the results, etc.
this->print_distributions_summary();
this->print_wcots();
std::cout << "pWCET(p=0.999999) is: " << this->get_pwcet_wcet(0.999999) << std::endl;
std::cout << "pWCET(p=1-10^(-9)) is: " << this->get_pwcet_wcet(1 - std::pow(10., -9.)) << std::endl;
double prob= this->get_pwcet_probability(16.8);
std::cout << "pWCET(WCET=16.8) is: " << std::setprecision(16) << prob << std::endl;
return AEC_OK;
}