@@ -258,13 +258,16 @@ Anomalies ADOutlierHBOS::run(int step) {
258258 }
259259 if (runtimes.size () > 0 ) {
260260 if (!g.find (func_id)) { // If func_id does not exist
261- param[func_id].create_histogram (runtimes);
261+ const int r = param[func_id].create_histogram (runtimes);
262+ if (r < 0 ) {return outliers;}
262263 }
263264 else { // merge with exisiting func_id, not overwrite
264265
265- param[func_id].merge_histograms (g[func_id], runtimes);
266+ const int r = param[func_id].merge_histograms (g[func_id], runtimes);
267+ if (r < 0 ) {return outliers;}
266268 }
267269 }
270+ else { return outliers;}
268271 }
269272
270273 // Update temp runstats to include information collected previously (synchronizes with the parameter server if connected)
@@ -332,7 +335,7 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
332335 verboseStream << " min_score = " << min_score << std::endl;
333336 verboseStream << " max_score = " << max_score << std::endl;
334337
335- if (out_scores_i.size () == 0 ) return 0 ;
338+ if (out_scores_i.size () <= 0 ) { return 0 ;}
336339
337340 // compute threshold
338341 verboseStream << " Global threshold before comparison with local threshold = " << param[func_id].get_threshold () << std::endl;
@@ -359,28 +362,32 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
359362 double ad_score;
360363
361364 const int bin_ind = ADOutlierHBOS::np_digitize_get_bin_inds (runtime_i, param[func_id].bin_edges ());
362- verboseStream << " bin_ind: " << bin_ind << " for runtime_i: " << runtime_i << std::endl;
365+ verboseStream << " bin_ind: " << bin_ind << " for runtime_i: " << runtime_i << " , where bin_edges Size: " << param[func_id]. bin_edges (). size () << " & num_bins: " << num_bins << std::endl;
363366 /* *
364367 * If the sample does not belong to any bins
365368 * bin_ind == 0 (fall outside since it is too small)
366369 */
367370 if ( bin_ind == 0 ){
368371 const double first_bin_edge = param[func_id].bin_edges ().at (0 );
369372 const double dist = first_bin_edge - runtime_i;
373+ verboseStream << " First_bin_edge: " << first_bin_edge << std::endl;
370374 if ( dist <= (bin_width * 0.05 ) ){
371375 verboseStream << runtime_i << " is on left of histogram but NOT outlier" << std::endl;
376+ if (param[func_id].counts ().size () < 1 ) {return 0 ;}
372377 if (param[func_id].counts ().at (0 ) == 0 ) { /* *< Ignore zero counts */
373-
378+
374379 ad_score = l_threshold - 1 ;
375380 verboseStream << " corrected ad_score: " << ad_score << std::endl;
376381 }
377382 else {
378383 ad_score = out_scores_i.at (0 );
384+ verboseStream << " ad_score: " << ad_score << std::endl;
379385 }
380386 }
381387 else {
382388 verboseStream << runtime_i << " is on left of histogram and an outlier" << std::endl;
383389 ad_score = max_score;
390+ verboseStream << " ad_score(max_score): " << ad_score << std::endl;
384391 }
385392
386393 }
@@ -391,21 +398,23 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
391398 const int last_idx = param[func_id].bin_edges ().size () - 1 ;
392399 const double last_bin_edge = param[func_id].bin_edges ().at (last_idx);
393400 const double dist = runtime_i - last_bin_edge;
394-
401+ verboseStream << " last_indx: " << last_idx << " , last_bin_edge: " << last_bin_edge << std::endl;
395402 if (dist <= (bin_width * 0.05 )) {
396- if (param[func_id].counts ().at (bin_ind) == 0 ) { /* *< Ignore zero counts */
403+ if (param[func_id].counts ().at (num_bins - 1 ) == 0 ) { // bin_ind) == 0) { /**< Ignore zero counts */
397404
398405 ad_score = l_threshold - 1 ;
399406 verboseStream << " corrected ad_score: " << ad_score << std::endl;
400407 }
401408 else {
402409 verboseStream << runtime_i << " is on right of histogram but NOT outlier" << std::endl;
403410 ad_score = out_scores_i.at (num_bins - 1 );
411+ verboseStream << " ad_score: " << ad_score << " , num_bins: " << num_bins << " , out_scores_i size: " << out_scores_i.size () << std::endl;
404412 }
405413 }
406414 else {
407415 verboseStream << runtime_i << " is on right of histogram and an outlier" << std::endl;
408416 ad_score = max_score;
417+ verboseStream << " ad_score(max_score): " << ad_score << " , num_bins: " << num_bins << " , out_scores_i size: " << out_scores_i.size () << std::endl;
409418 }
410419
411420 }
@@ -419,6 +428,7 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
419428 else {
420429 verboseStream << runtime_i << " maybe be an outlier" << std::endl;
421430 ad_score = out_scores_i.at ( bin_ind - 1 );
431+ verboseStream << " ad_score(else): " << ad_score << " , bin_ind: " << bin_ind << " , num_bins: " << num_bins << " , out_scores_i size: " << out_scores_i.size () << std::endl;
422432 }
423433
424434 }
0 commit comments