29 classType =
"LeakyIntegrator";
30 preProcessingType = classType;
31 debugLog.setProceedingText(
"[DEBUG LeakyIntegrator]");
32 errorLog.setProceedingText(
"[ERROR LeakyIntegrator]");
33 warningLog.setProceedingText(
"[WARNING LeakyIntegrator]");
34 init(leakRate,numDimensions);
39 classType =
"LeakyIntegrator";
40 preProcessingType = classType;
41 debugLog.setProceedingText(
"[DEBUG LeakyIntegrator]");
42 errorLog.setProceedingText(
"[ERROR LeakyIntegrator]");
43 warningLog.setProceedingText(
"[WARNING LeakyIntegrator]");
66 if( preProcessing == NULL )
return false;
80 errorLog <<
"clone(const PreProcessing *preProcessing) - PreProcessing Types Do Not Match!" << std::endl;
88 errorLog <<
"process(const VectorFloat &inputVector) - Not initialized!" << std::endl;
92 if( inputVector.size() != numInputDimensions ){
93 errorLog <<
"process(const VectorFloat &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << std::endl;
99 if( processedData.size() == numOutputDimensions )
return true;
104 if( initialized )
return init(
leakRate, numInputDimensions);
110 if( !file.is_open() ){
111 errorLog <<
"saveModelToFile(fstream &file) - The file is not open!" << std::endl;
115 file <<
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" << std::endl;
118 errorLog <<
"savePreProcessingSettingsToFile(fstream &file) - Failed to save preprocessing settings to file!" << std::endl;
122 file <<
"LeakRate: " <<
leakRate << std::endl;
129 if( !file.is_open() ){
130 errorLog <<
"loadModelFromFile(fstream &file) - The file is not open!" << std::endl;
139 if( word !=
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" ){
140 errorLog <<
"loadModelFromFile(fstream &file) - Invalid file format!" << std::endl;
145 errorLog <<
"loadPreProcessingSettingsFromFile(fstream &file) - Failed to load preprocessing settings from file!" << std::endl;
151 if( word !=
"LeakRate:" ){
152 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read LeakRate header!" << std::endl;
158 return init(leakRate,numInputDimensions);
165 if( leakRate < 0 || leakRate > 1 ){
166 errorLog <<
"init(const Float leakRate,const UINT numDimensions) - leakRate must be between [0 1]!" << std::endl;
170 if( numDimensions == 0 ){
171 errorLog <<
"init(const Float leakRate,const UINT numDimensions) - NumDimensions must be greater than 0!" << std::endl;
176 this->numInputDimensions = numDimensions;
177 this->numOutputDimensions = numDimensions;
180 processedData.clear();
181 processedData.
resize(numDimensions,0);
188 if( numInputDimensions != 1 ){
189 errorLog <<
"update(const Float x) - The Number Of Input Dimensions is not 1! NumInputDimensions: " << numInputDimensions << std::endl;
195 if(
y.size() == 0 )
return 0 ;
203 errorLog <<
"update(const VectorFloat &x) - Not Initialized!" << std::endl;
207 if( x.size() != numInputDimensions ){
208 errorLog <<
"update(const VectorFloat &x) - The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.size() <<
")!" << std::endl;
212 for(UINT n=0; n<numInputDimensions; n++){
217 return processedData;
221 if( leakRate >= 0 && leakRate <= 1 ){
223 if( initialized )
init(leakRate, numInputDimensions);
226 errorLog <<
"setLeakRate(const Float leakRate) - The leak rate must be between [0 1]!" << std::endl;
LeakyIntegrator & operator=(const LeakyIntegrator &rhs)
virtual ~LeakyIntegrator()
bool savePreProcessingSettingsToFile(std::fstream &file) const
bool loadPreProcessingSettingsFromFile(std::fstream &file)
virtual bool resize(const unsigned int size)
Float update(const Float x)
LeakyIntegrator(const Float leakRate=0.99, const UINT numDimensions=1)
VectorFloat y
A buffer holding the previous input value(s)
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
bool setLeakRate(const Float leakRate)
std::string getPreProcessingType() const
virtual bool loadModelFromFile(std::fstream &file)
virtual bool saveModelToFile(std::fstream &file) const
bool copyBaseVariables(const PreProcessing *preProcessingModule)
The LeakyIntegrator class computes the following signal: y = y*z + x, where x is the input...
virtual bool process(const VectorFloat &inputVector)
Float leakRate
The current leak rate.