26 RegisterPreProcessingModule< LeakyIntegrator > LeakyIntegrator::registerModule(
"LeakyIntegrator");
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!" << endl;
88 errorLog <<
"process(const VectorDouble &inputVector) - Not initialized!" << endl;
92 if( inputVector.size() != numInputDimensions ){
93 errorLog <<
"process(const VectorDouble &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << 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!" << endl;
115 file <<
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" << endl;
118 errorLog <<
"savePreProcessingSettingsToFile(fstream &file) - Failed to save preprocessing settings to file!" << endl;
122 file <<
"LeakRate: " <<
leakRate << endl;
129 if( !file.is_open() ){
130 errorLog <<
"loadModelFromFile(fstream &file) - The file is not open!" << endl;
139 if( word !=
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" ){
140 errorLog <<
"loadModelFromFile(fstream &file) - Invalid file format!" << endl;
145 errorLog <<
"loadPreProcessingSettingsFromFile(fstream &file) - Failed to load preprocessing settings from file!" << endl;
151 if( word !=
"LeakRate:" ){
152 errorLog <<
"loadModelFromFile(fstream &file) - Failed to read LeakRate header!" << endl;
158 return init(leakRate,numInputDimensions);
165 if( leakRate < 0 || leakRate > 1 ){
166 errorLog <<
"init(const double leakRate,const UINT numDimensions) - leakRate must be between [0 1]!" << endl;
170 if( numDimensions == 0 ){
171 errorLog <<
"init(const double leakRate,const UINT numDimensions) - NumDimensions must be greater than 0!" << endl;
176 this->numInputDimensions = numDimensions;
177 this->numOutputDimensions = numDimensions;
179 y.resize(numDimensions,0);
180 processedData.clear();
181 processedData.resize(numDimensions,0);
188 if( numInputDimensions != 1 ){
189 errorLog <<
"update(const double x) - The Number Of Input Dimensions is not 1! NumInputDimensions: " << numInputDimensions << endl;
193 y =
update( VectorDouble(1,x) );
195 if(
y.size() == 0 )
return 0 ;
203 errorLog <<
"update(const VectorDouble &x) - Not Initialized!" << endl;
204 return vector<double>();
207 if( x.size() != numInputDimensions ){
208 errorLog <<
"update(const VectorDouble &x) - The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.size() <<
")!" << endl;
209 return vector<double>();
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 double leakRate) - The leak rate must be between [0 1]!" << endl;
bool setLeakRate(const double leakRate)
double leakRate
The current leak rate.
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
virtual bool loadModelFromFile(fstream &file)
bool savePreProcessingSettingsToFile(fstream &file) const
string getPreProcessingType() const
virtual ~LeakyIntegrator()
virtual bool process(const VectorDouble &inputVector)
bool copyBaseVariables(const PreProcessing *preProcessingModule)
LeakyIntegrator(const double leakRate=0.99, const UINT numDimensions=1)
bool loadPreProcessingSettingsFromFile(fstream &file)
virtual bool saveModelToFile(fstream &file) const
The LeakyIntegrator class computes the following signal: y = y*z + x, where x is the input...
VectorDouble y
A buffer holding the previous input value(s)
double update(const double x)
LeakyIntegrator & operator=(const LeakyIntegrator &rhs)