Hybrid Query Processing Engine for Coprocessing in Database Systems
HyPE
report.cpp
Go to the documentation of this file.
00001 
00002 #include <core/report.hpp>
00003 #include <config/configuration.hpp>
00004 #include <core/scheduler.hpp>
00005 
00006 #include <cmath>
00007 
00008 //using namespace std;
00009 
00010 namespace hype
00011 {
00012    namespace core{
00013 
00014 
00015          Report& Report::instance(){
00016             static Report r;
00017             return r;
00018          }
00019          
00020          double Report::getRelativeEstimationError(const std::string& algorithm_name) const throw(std::invalid_argument){
00021             AlgorithmPtr ptr = Scheduler::instance().getAlgorithm(algorithm_name);
00022             if(!ptr){
00023                std::string error_message="Could not find Algorithm '";
00024                error_message+=algorithm_name+"'!";
00025                throw new std::invalid_argument(error_message);
00026             }
00027             
00028             double sum=0;
00029             unsigned int length_of_initial_training_phase=Runtime_Configuration::instance().getTrainingLength(); //Configuration::period_for_periodic_recomputation;
00030             for(unsigned int i=length_of_initial_training_phase+1;i<ptr->getAlgorithmStatistics().relative_errors_.size();i++){
00031                sum+=std::abs(ptr->getAlgorithmStatistics().relative_errors_[i]);
00032                //std::cout << "sum " << sum << " " << ptr->getAlgorithmStatistics().relative_errors_[i] << std::endl;
00033             }
00034             return sum/ptr->getAlgorithmStatistics().relative_errors_.size();
00035             //return ptr->getAlgorithmStatistics().average_relative_error_;
00036          }
00037          
00038 
00039          Report::Report(){
00040 
00041          }
00042 
00043 
00044 
00045    };//end namespace core
00046 }; //end namespace hype 
00047 
00048 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines