Skip to content
Snippets Groups Projects
NormalizationStrategy.cpp 1.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include <cmath>
    #include <stdexcept>
    #include <boost/serialization/export.hpp>
    
    
    #include "NormalizationStrategySerialization.h"
    
    #include "exceptions.h"
    
    BOOST_CLASS_EXPORT_IMPLEMENT(NormalizationStrategy)
    BOOST_CLASS_EXPORT_IMPLEMENT(DoubleUnitStrategy)
    
    //NormalizationStrategy::~NormalizationStrategy() = def
    
    
    double NormalizationStrategy::get_max_value() {
    
    }
    
    double NormalizationStrategy::get_min_value() {
    
    Martin Beseda's avatar
    Martin Beseda committed
    double DoubleUnitStrategy::normalize(double n,
                                         double max,
                                         double min) {
        if (this->max_min_inp_val.empty()) {
    
            this->max_min_inp_val.emplace_back(max);
            this->max_min_inp_val.emplace_back(min);
        } else {
            this->max_min_inp_val.at(0) = max;
            this->max_min_inp_val.at(1) = min;
        }
    
    //    return 2 * (n - min) / (max - min) - 1;
        return n / (this->get_max_value() - this->get_min_value());
    
    double DoubleUnitStrategy::de_normalize(double n) {
    
    Martin Beseda's avatar
    Martin Beseda committed
        if (this->max_min_inp_val.empty()) {
    
            THROW_RUNTIME_ERROR("Data were not normalized, so de-normalization cannot progress!");
    
        //return 0.5 * ((1 + n) * (this->get_max_value() - this->get_min_value())) + this->get_min_value();
        return n * (this->get_max_value() - this->get_min_value());