Skip to content

Commit 7c52aa0

Browse files
author
Sandeep Mittal
committed
passing unit tests: fixed indexing (copod) and detection loop
1 parent aa7aa49 commit 7c52aa0

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/ad/ADOutlier.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,17 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
593593
std::vector<double> recon_p_runtimes = std::vector<double>(tot_runtimes, 0.0);
594594
std::vector<double> recon_n_runtimes = std::vector<double>(tot_runtimes, 0.0);
595595
int recon_idx = 0;
596+
//verboseStream << "Unwrapping Merged Histogram. Size: " << param[func_id].counts().size() << std::endl;
596597
for(int i=0; i < param[func_id].counts().size(); i++){
597598
int count = param[func_id].counts().at(i);
599+
//verboseStream << "Count: " << count << ", Value: " << param[func_id].bin_edges().at(i) << std::endl;
598600
for(int j=0; j<count; j++){
599-
recon_p_runtimes.at(recon_idx++) = param[func_id].bin_edges().at(i);
600-
recon_n_runtimes.at(recon_idx++) = -1 * param[func_id].bin_edges().at(i);
601+
602+
recon_p_runtimes.at(recon_idx) = param[func_id].bin_edges().at(i);
603+
recon_n_runtimes.at(recon_idx) = -1 * param[func_id].bin_edges().at(i);
604+
//verboseStream << "recon_p_runtimes.at(recon_idx): " << recon_p_runtimes.at(recon_idx) << ", recon_n_runtimes.at(recon_idx): " << recon_n_runtimes.at(recon_idx) << std::endl;
605+
//verboseStream << "recon_idx: " << recon_idx << std::endl;
606+
recon_idx++;
601607
}
602608
}
603609

@@ -666,7 +672,8 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
666672
const double runtime_i = this->getStatisticValue(*itt); //runtimes.push_back(this->getStatisticValue(*itt));
667673
double ad_score;
668674

669-
if (mean_pn_ecdf.at(running_idx++) > 0)
675+
//verboseStream << "mean_pn_ecdf.at(running_idx++): " << mean_pn_ecdf.at(running_idx) << std::endl;
676+
if (mean_pn_ecdf.at(running_idx++) < 0.99)
670677
ad_score = l_threshold + 1;
671678
else
672679
ad_score = l_threshold - 1;
@@ -678,7 +685,7 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
678685
if (ad_score >= l_threshold) {
679686

680687
itt->set_label(-1);
681-
std::cout << "!!!!!!!Detected outlier on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
688+
verboseStream << "!!!!!!!Detected outlier on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
682689
outliers.insert(itt, Anomalies::EventType::Outlier, runtime_i, ad_score, l_threshold); //insert into data structure containing captured anomalies
683690
n_outliers += 1;
684691

@@ -687,7 +694,7 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
687694
//Capture maximum of one normal execution per io step
688695
itt->set_label(1);
689696
if(outliers.nFuncEvents(func_id, Anomalies::EventType::Normal) == 0) {
690-
std::cout << "Detected normal event on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
697+
verboseStream << "Detected normal event on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
691698
outliers.insert(itt, Anomalies::EventType::Normal);
692699

693700
}

src/param.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "chimbuko/param.hpp"
22
#include "chimbuko/param/sstd_param.hpp"
33
#include "chimbuko/param/hbos_param.hpp"
4+
#include "chimbuko/param/copod_param.hpp"
45
#include <chrono>
56

67
using namespace chimbuko;
@@ -17,6 +18,9 @@ ParamInterface *ParamInterface::set_AdParam(const std::string & ad_algorithm) {
1718
else if (ad_algorithm == "sstd" || ad_algorithm == "SSTD") {
1819
return new SstdParam();
1920
}
21+
else if (ad_algorithm == "copod" || ad_algorithm == "COPOD") {
22+
return new CopodParam();
23+
}
2024
else {
2125
return nullptr;
2226
}

0 commit comments

Comments
 (0)