Loading...
Searching...
No Matches
Pagani2016filter.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12License
13 This file is part of ITHACA-FV
14 ITHACA-FV is free software: you can redistribute it and/or modify
15 it under the terms of the GNU Lesser General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18 ITHACA-FV is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
24Class
25 Pagani2016filter
26Description
27 A class that implements the Ensamble Kalman Filter in the version by Pagani et al. 2016
28SourceFiles
29 Pagani2016filter.C
30\*---------------------------------------------------------------------------*/
31
36
37#ifndef pagani2016filter_H
38#define pagani2016filter_H
39
40#include "ITHACAutilities.H"
41#include "muq2ithaca.H"
42#include "ensembleClass.H"
43
44
45
46
47namespace ITHACAmuq
48{
49//--------------------------------------------------------------------------
52class Pagani2016filter
53{
54 int Nseeds = 0;
55
56 int timeSampI = 0;
57 int stateSize = 0;
58 int parameterSize = 0;
59 int observationSize = 0;
60
61 int timeStepI = 0;
62 double startTime;
63 double deltaTime;
64 double endTime;
65 int Ntimes = 0;
66
67 bool initialStateFlag = 0;
68 bool parameterPriorFlag = 0;
69 bool modelErrorFlag = 0;
70 bool measurementNoiseFlag = 0;
71
73 Eigen::VectorXd initialStateMean;
74
76 Eigen::MatrixXd initialStateCov;
77
79 Eigen::VectorXd parameterPriorMean;
80
82 Eigen::MatrixXd parameterPriorCov;
83
85 Eigen::MatrixXd parameterMean;
86
88 Eigen::MatrixXd stateMean;
89
91 Eigen::VectorXd timeVector;
92
94 int observationStart;
95
97 int observationDelta;
98
100 Eigen::VectorXi observationBoolVec;
101
103 Eigen::MatrixXd trueObservations;
104
106 std::shared_ptr<muq::Modeling::Gaussian> initialStateDensity;
107
109 std::shared_ptr<muq::Modeling::Gaussian> parameterPriorDensity;
110
112 Eigen::MatrixXd parameterObservation_crossCov;
113
115 Eigen::MatrixXd stateObservation_crossCov;
116
118 Eigen::MatrixXd observation_Cov;
119
120
121 int innerLoopI = 0;
122
123
124 public:
125 // Constructors
126 Pagani2016filter();
127
128 Pagani2016filter(int _Nseeds);
129
130 virtual ~Pagani2016filter() = default;
131
133 std::shared_ptr<muq::Modeling::Gaussian> measNoiseDensity;
134
136 std::shared_ptr<muq::Modeling::Gaussian> parameterErrorDensity;
137
140
143
146
149
151 Eigen::MatrixXd state_maxConf;
152
154 Eigen::MatrixXd state_minConf;
155
157 Eigen::MatrixXd parameter_maxConf;
158
160 Eigen::MatrixXd parameter_minConf;
161
162 // Functions
163
164 //--------------------------------------------------------------------------
166 int getNumberOfSamples();
167
168 //--------------------------------------------------------------------------
170 int getObservationSize();
171
172 //--------------------------------------------------------------------------
174 double getTime();
175
176 //--------------------------------------------------------------------------
178 double getTime(int _timeStepI);
179
180 //--------------------------------------------------------------------------
182 int getTimeStep();
183
184 //--------------------------------------------------------------------------
186 Eigen::VectorXd getTimeVector();
187
188 //--------------------------------------------------------------------------
190 Eigen::MatrixXd getStateMean();
191
192 //--------------------------------------------------------------------------
194 Eigen::MatrixXd getParameterMean();
195
196 //--------------------------------------------------------------------------
198 void computeStateMean(int _index);
199
200 //--------------------------------------------------------------------------
202 void computeParameterMean(int _index);
203
204 //--------------------------------------------------------------------------
207
208 //--------------------------------------------------------------------------
211 int getObservationTimestep(int _timeSampleI);
212
213 //--------------------------------------------------------------------------
215 void setTrueObservations(Eigen::MatrixXd _observations);
216
217 //--------------------------------------------------------------------------
219 void setTime(double _startTime, double _deltaTime, double _endTime);
220
221 //--------------------------------------------------------------------------
223 void setObservationTime(int _observationStart, int _observationDelta);
224
225 //--------------------------------------------------------------------------
227 void setMeasNoise(double cov);
228
229 //--------------------------------------------------------------------------
231 void setParameterError(double cov);
232
233 //--------------------------------------------------------------------------
235 void setInitialStateDensity(Eigen::VectorXd _mean, Eigen::MatrixXd _cov);
236
237 //--------------------------------------------------------------------------
239 void sampleInitialState();
240
241 //--------------------------------------------------------------------------
244
245 //--------------------------------------------------------------------------
247 void setParameterPriorDensity(Eigen::VectorXd _mean, Eigen::MatrixXd _cov);
248
249 //--------------------------------------------------------------------------
251 Eigen::MatrixXd ensembleFromDensity(std::shared_ptr<muq::Modeling::Gaussian>
252 _density);
253
254 //--------------------------------------------------------------------------
259 virtual void stateProjection() = 0;
260
261 //--------------------------------------------------------------------------
263 virtual void observeState() = 0;
264
265 //--------------------------------------------------------------------------
267 void setObservationSize(int _size);
268
269 //--------------------------------------------------------------------------
271 void setStateSize(int _size);
272
273 //--------------------------------------------------------------------------
275 int getStateSize();
276
277 //--------------------------------------------------------------------------
279 void setParameterSize(int _size);
280
281 //--------------------------------------------------------------------------
283 int getParameterSize();
284
285 //--------------------------------------------------------------------------
287 void update();
288
289 //--------------------------------------------------------------------------
291 void run(word outputFolder);
292};
293}
294#endif
Header file of the ITHACAutilities namespace.
Eigen::MatrixXd getParameterMean()
Return parameter mean.
void setTime(double _startTime, double _deltaTime, double _endTime)
Setup the time vector.
int getTimeStep()
Return timestep.
void update()
Perform Kalman filter update.
void setParameterPriorDensity(Eigen::VectorXd _mean, Eigen::MatrixXd _cov)
Create parameter ensemble.
void setMeasNoise(double cov)
Setup of the measurement noise distribution.
int getObservationTimestep(int _timeSampleI)
Return timestep at corresponding to the input observation step.
Eigen::VectorXd getTimeVector()
Return time vector.
void sampleInitialState()
Create initial state ensemble.
void setObservationTime(int _observationStart, int _observationDelta)
Setup the observation vector.
ensemble observationEns
Observation ensemble.
Eigen::MatrixXd parameter_minConf
parameter minimum confidence level
std::shared_ptr< muq::Modeling::Gaussian > measNoiseDensity
Measurement noise density.
void computeStateMean(int _index)
Compute state mean.
std::shared_ptr< muq::Modeling::Gaussian > parameterErrorDensity
Parameter error density.
void setParameterError(double cov)
Setup of the parameter error distribution.
Eigen::MatrixXd state_maxConf
State maximum confidence level.
Eigen::MatrixXd ensembleFromDensity(std::shared_ptr< muq::Modeling::Gaussian > _density)
General class to sample from an input density.
int getObservationSize()
Return the size of the observation vector.
Eigen::MatrixXd state_minConf
State minimum confidence level.
ensemble parameterEns
Parameter ensemble.
double getTime()
Return time.
void computeParameterMean(int _index)
Compute parameter mean.
int getNumberOfSamples()
Return number of samples per ensamble.
virtual void stateProjection()=0
Project the state in between two sampling steps and fills the state and parameter mean and confidence...
Eigen::MatrixXd getStateMean()
Return state mean.
void setTrueObservations(Eigen::MatrixXd _observations)
Set the observations matrix.
ensemble oldStateEns
Old state ensemble.
void run(word outputFolder)
Run the filtering.
void setInitialStateDensity(Eigen::VectorXd _mean, Eigen::MatrixXd _cov)
Create initial state ensemble.
void sampleInitialParameter()
Create initial parameter ensemble.
Eigen::MatrixXd parameter_maxConf
parameter maximum confidence level
ensemble stateEns
State ensemble.
Class for ensembles, each column is a sample.
Header file of the muq2ithaca namespace.