General Purpose Geodetic Library
SgEstimator.h
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef SG_ESTIMATOR_H
24 #define SG_ESTIMATOR_H
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 
32 #include <QtCore/QMap>
33 #include <QtCore/QStack>
34 #include <QtCore/QString>
35 
36 
37 
38 #include <SgMJD.h>
39 
40 
41 
42 class SgVector;
43 class SgMatrix;
44 class SgUtMatrix;
45 class SgSymMatrix;
46 
47 class SgParameter;
48 class SgPwlStorage;
49 class SgArcStorage;
50 class SgTaskConfig;
51 
52 
53 struct arg4Prc_01;
54 struct arg4Prc_02;
55 
56 
57 
58 /***===================================================================================================*/
65 {
66 public:
68  {
73  };
74  //
75  //
76  // constructors/destructors:
77  //
82 
86  ~SgEstimator();
87 
88 
89  //
90  // Interfaces:
91  //
93 
95 
97 
98  inline QList<SgParameter*>* listPwl();
99 
101 
102  inline QMap<QString, SgPwlStorage*> *pwlStorageByName();
103 
105 
106  inline SgSymMatrix* mPall();
107 
108  inline int numOfProcessedObs() const {return numOfProcessedObs_;};
109 
110  inline const QMap<QString, StochasticSolutionCarrier>& stcSolutions() {return stcSolutions_;};
111 
112 
113  //
114  // Functions:
115  //
118  static const QString className();
119 
122  void addParameter(SgParameter*, bool=false);
123 
126  void addParametersList(QList<SgParameter*>*, bool=false);
127 
131 
135 
139  void prepare2Run(int numOfExpectedObs, const SgMJD&, const SgMJD&, const SgMJD&);
140 
146  void processObs(const SgMJD& t, const SgVector& o_c, const SgVector& sigma);
147 
152  void processConstraint(double o_c, double sigma);
153 
156  void finisRun();
157 
158 //
159 // void prepareRegSolution4Epoch(const SgMJD&, QList<SgParameter*>*);
160 //
162 //
163  void clearPartials();
164 //
165  double calcAX(const SgMJD&, bool);
166 //
167  double calc_aT_P_a(const SgMJD&);
168  double calc_aT_P_a_opt(const SgMJD&);
169  double calc_aT_P_a_opt(const SgMJD&, const QList<SgParameter*>&);
170 //
171  inline double maxConditionNumber() const {return maxConditionNumber_;};
172 
173  //
174  // Friends:
175  //
176 
177  //
178  // I/O:
179  //
180  // ...
181 
182 private:
184  {
191  };
192  struct RPCarrier
193  {
201  };
203  {
212  {tLeft_=tRight_=tZero; list_=listOthers_=NULL; x_=NULL; P_=NULL; Pxx_=NULL;};
213  };
214 
215  //
217 
218  //
222 
223  // regular parameters:
226  QMap<QString, SgParameter*> *xAllByName_;
227  //
228  unsigned int nX_;
230  QMap<QString, SgParameter*> *xByName_;
235  QStack<RPCarrier> rpStack_;
236 
237 
238  // stochastic parameters:
239  unsigned int nP_;
241  QMap<QString, SgParameter*> *pByName_;
248  // stochastic smoothing:
253  QStack<SmoothCarrier> scStack_;
254 //------------------------------------------------------------
255 // // maps of solutions of regular and stochastic parameters:
256 // QMap<QString, RegularSolutionCarrier*> regSolutions_;
257 // QMap<QString, RegularSolutionCarrier*> regSolByName_;
258 // QMap<QString, SgParameter*> regParByName_;
259  QMap<QString, StochasticSolutionCarrier> stcSolutions_;
260 
261  //
262  // special types of parameters:
263  // arc parameters:
265  QMap<QString, SgParameter*> *aByName_;
267  // PWL parameters:
269  QMap<QString, SgParameter*> *pwlParByName_;
270  QMap<QString, SgPwlStorage*> *pwlStorageByName_;
272 
273 
274  //
275  // data:
276  unsigned int nZ_;
283 
284  // threadisation:
286  pthread_attr_t pthreadAttr_;
288  // proc01:
290  pthread_t *th4Prc_01_;
291  pthread_mutex_t *pthMutexes4Prc_01_;
292  pthread_mutex_t pthMutL4Prc_01_;
294  // proc02:
296  pthread_t *th4Prc_02_;
297  pthread_mutex_t *pthMutexes4Prc_02_;
298  pthread_mutex_t pthMutL4Prc_02_;
300 
301  // tmp:
302 
307 
312 
313 
314 
315  // private functions:
316  void dataUpdate();
317  void dataUpdate_th();
318  void propagateStochasticParameters(double);
320 
322  void save4Smoothing(const SgMJD&);
323 
324  // tst:
325  void saveProcessedParameters(const SgMJD&);
326  void insertNewParameters(const SgMJD&);
327  //
328  void deployArcParameters(const SgMJD&, const SgMJD&, const SgMJD&);
329  void propagateArcPartials(const SgMJD&);
330  //
331  void deployPwlParameters(const SgMJD&, const SgMJD&, const SgMJD&);
332  void propagatePwlPartials(const SgMJD&);
333  void calcPwlTraces(const QList<SgParameter*> *listX, const SgSymMatrix& mPx);
334  // tst:
338  SgMatrix* =NULL, QList<SgParameter*>* =NULL);
339 
340  // some private math:
341  // solves equation "R*x = z", x -- unknown.
342  SgVector& solveEquation(const SgUtMatrix& R, SgVector& x, const SgVector& z);
343  // evaluate R*R^T product:
345 
346  SgSymMatrix calcQForm(const SgSymMatrix&, const SgMatrix&);
347 
349 
350  void calcConditionNumber(const SgUtMatrix& R, const SgUtMatrix& RInv);
351 };
352 /*=====================================================================================================*/
353 
354 
355 
356 
357 
358 
359 
360 
361 /*=====================================================================================================*/
362 /* */
363 /* SgEstimator inline members: */
364 /* */
365 /*=====================================================================================================*/
366 
367 
368 
369 //
370 // INTERFACES:
371 //
372 //
374 {
375  return listX_;
376 };
377 
378 
379 
381 {
382  return listXAll_;
383 };
384 
385 
386 
387 //
389 {
390  return listP_;
391 };
392 
393 
394 
395 //
397 {
398  return listPwl_;
399 };
400 
401 
402 
403 //
405 {
406  return pwlStorage_;
407 };
408 
409 
410 
411 //
412 inline QMap<QString, SgPwlStorage*>* SgEstimator::pwlStorageByName()
413 {
414  return pwlStorageByName_;
415 };
416 
417 
418 
419 //
421 {
422  return arcStorage_;
423 };
424 
425 
426 
427 //
429 {
430  return PxAll_;
431 };
432 
433 
434 //
435 // FRUNCTIONS:
436 //
437 //
438 //
439 
440 
441 
442 //
443 // FRIENDS:
444 //
445 //
446 //
447 /*=====================================================================================================*/
448 
449 
450 
451 
452 
453 /*=====================================================================================================*/
454 //
455 // aux functions:
456 //
457 
458 
459 /*=====================================================================================================*/
460 
461 
462 /*=====================================================================================================*/
463 #endif //SG_ESTIMATOR_H
const SgMJD tZero(1957, 10, 4)
QList< SgArcStorage * > * arcStorage()
Definition: SgEstimator.h:420
void solveStochasticParameters()
int lastPrcColumn4Prc_01_
Definition: SgEstimator.h:293
SgEstimator(SgTaskConfig *)
SgMJD tNextLeft_
Definition: SgEstimator.h:220
void insertNewParameters(const SgMJD &)
struct arg4Prc_01 * args4Prc_01_
Definition: SgEstimator.h:289
pthread_mutex_t * pthMutexes4Prc_02_
Definition: SgEstimator.h:297
QList< SgPwlStorage * > * pwlStorage()
Definition: SgEstimator.h:404
static const QString className()
int lastPrcColumn4Prc_02_
Definition: SgEstimator.h:299
QList< SgParameter * > * listPwl_
Definition: SgEstimator.h:268
double maxConditionNumber() const
Definition: SgEstimator.h:171
pthread_t * th4Prc_02_
Definition: SgEstimator.h:296
SgVector * zx_
Definition: SgEstimator.h:232
double time4DataUpdate_
Definition: SgEstimator.h:308
SgVector * x_
Definition: SgEstimator.h:231
SgUtMatrix * Rx_
Definition: SgEstimator.h:233
SgSymMatrix * mPall()
Definition: SgEstimator.h:428
void calcConditionNumber(const SgUtMatrix &R, const SgUtMatrix &RInv)
int numOfThreads_
Definition: SgEstimator.h:285
QStack< SmoothCarrier > scStack_
Definition: SgEstimator.h:253
SgVector * p_
Definition: SgEstimator.h:242
void dataUpdate()
unsigned int nZ_
Definition: SgEstimator.h:276
QList< SgPwlStorage * > * pwlStorage_
Definition: SgEstimator.h:271
SgUtMatrix * Rp_s_
Definition: SgEstimator.h:249
QMap< QString, SgParameter * > * xAllByName_
Definition: SgEstimator.h:226
int numOfProcessedObs() const
Definition: SgEstimator.h:108
SgMJD tLastProcessed_
Definition: SgEstimator.h:219
pthread_mutex_t * pthMutexes4Prc_01_
Definition: SgEstimator.h:291
QList< SgParameter * > * listP_
Definition: SgEstimator.h:240
SgMatrix * Rpp_s_
Definition: SgEstimator.h:250
double calcAX(const SgMJD &, bool)
void propagateStochasticParameters(double)
SgMatrix * SR_
Definition: SgEstimator.h:247
void removeParametersList(QList< SgParameter * > *)
void dataUpdate_th()
void submittSolution2GlobalStore(SgSymMatrix *, QList< SgParameter * > *, SgMatrix *=NULL, QList< SgParameter * > *=NULL)
SgMJD tWall4ProcObs0_
Definition: SgEstimator.h:305
void saveProcessedParameters(const SgMJD &)
SgVector * zp_
Definition: SgEstimator.h:243
QList< SgParameter * > * listA_
Definition: SgEstimator.h:264
unsigned int nP_
Definition: SgEstimator.h:239
SgVector * u_
Definition: SgEstimator.h:280
SgSymMatrix & calculateRRT(SgSymMatrix &, const SgUtMatrix &)
QList< SgArcStorage * > * arcStorage_
Definition: SgEstimator.h:266
SgVector * zp_s_
Definition: SgEstimator.h:252
SgMJD tNextRight_
Definition: SgEstimator.h:221
double time4PropagateStc_
Definition: SgEstimator.h:309
SgMJD tWall_
Definition: SgEstimator.h:304
void propagateStochasticParameters_th(double)
SgMatrix * Rpx_s_
Definition: SgEstimator.h:251
SgMJD tWall0_
Definition: SgEstimator.h:303
SgVector & solveEquation(const SgUtMatrix &R, SgVector &x, const SgVector &z)
SgSymMatrix calcQForm(const SgSymMatrix &, const SgMatrix &)
void prepareStochasticSolution4Epoch(const SgMJD &, QList< SgParameter * > *)
SgUtMatrix * Rp_
Definition: SgEstimator.h:244
SgMatrix * Rpx_
Definition: SgEstimator.h:245
double calc_aT_P_a(const SgMJD &)
void save4Smoothing(const SgMJD &)
void addParametersList(QList< SgParameter * > *, bool=false)
void propagateArcPartials(const SgMJD &)
SgMatrix * Ap_
Definition: SgEstimator.h:278
QList< SgParameter * > * listXAll_
Definition: SgEstimator.h:224
void prepareRegSolution4Epoch(const SgMJD &, QList< SgParameter * > *)
double time4SaveStc_
Definition: SgEstimator.h:310
QMap< QString, SgParameter * > * xByName_
Definition: SgEstimator.h:230
QMap< QString, SgParameter * > * pwlParByName_
Definition: SgEstimator.h:269
SgMatrix * u4pth_
Definition: SgEstimator.h:287
SgVector * z_
Definition: SgEstimator.h:277
void calcPwlTraces(const QList< SgParameter * > *listX, const SgSymMatrix &mPx)
void deployPwlParameters(const SgMJD &, const SgMJD &, const SgMJD &)
pthread_mutex_t pthMutL4Prc_01_
Definition: SgEstimator.h:292
void addParameter(SgParameter *, bool=false)
double calc_aT_P_a_opt(const SgMJD &)
SgMatrix * Ax_
Definition: SgEstimator.h:279
void prepare2Run(int numOfExpectedObs, const SgMJD &, const SgMJD &, const SgMJD &)
const QMap< QString, StochasticSolutionCarrier > & stcSolutions()
Definition: SgEstimator.h:110
QMap< QString, SgParameter * > * pByName_
Definition: SgEstimator.h:241
double time4ProcObs_
Definition: SgEstimator.h:311
SgMJD tWall4ProcObs_
Definition: SgEstimator.h:306
QList< SgParameter * > * stochasticParametersList()
Definition: SgEstimator.h:388
QList< SgParameter * > * allRegularParametersList()
Definition: SgEstimator.h:380
double maxConditionNumber_
Definition: SgEstimator.h:282
QMap< QString, SgParameter * > * aByName_
Definition: SgEstimator.h:265
void collectDependentInfArray(const RPCarrier &, SgVector *, SgSymMatrix *)
pthread_mutex_t pthMutL4Prc_02_
Definition: SgEstimator.h:298
QMap< QString, SgPwlStorage * > * pwlStorageByName_
Definition: SgEstimator.h:270
QList< SgParameter * > * regularParametersList()
Definition: SgEstimator.h:373
unsigned int nX_
Definition: SgEstimator.h:228
QMap< QString, StochasticSolutionCarrier > stcSolutions_
Definition: SgEstimator.h:259
SgSymMatrix * Pp_
Definition: SgEstimator.h:246
void processConstraint(double o_c, double sigma)
void removeParameter(SgParameter *)
void deployArcParameters(const SgMJD &, const SgMJD &, const SgMJD &)
void processObs(const SgMJD &t, const SgVector &o_c, const SgVector &sigma)
QList< SgParameter * > * listX_
Definition: SgEstimator.h:229
void propagatePwlPartials(const SgMJD &)
pthread_attr_t pthreadAttr_
Definition: SgEstimator.h:286
SgSymMatrix * PxAll_
Definition: SgEstimator.h:225
int numOfProcessedObs_
Definition: SgEstimator.h:281
QList< SgParameter * > * listPwl()
Definition: SgEstimator.h:396
QStack< RPCarrier > rpStack_
Definition: SgEstimator.h:235
void clearPartials()
pthread_t * th4Prc_01_
Definition: SgEstimator.h:290
SgSymMatrix * Px_
Definition: SgEstimator.h:234
QMap< QString, SgPwlStorage * > * pwlStorageByName()
Definition: SgEstimator.h:412
struct arg4Prc_02 * args4Prc_02_
Definition: SgEstimator.h:295
SgTaskConfig * config_
Definition: SgEstimator.h:216
Definition: SgMJD.h:59
QList< SgParameter * > * listOthers_
Definition: SgEstimator.h:197
QList< SgParameter * > * list_
Definition: SgEstimator.h:196
QList< SgParameter * > * listOthers_
Definition: SgEstimator.h:207
QList< SgParameter * > * list_
Definition: SgEstimator.h:206
QList< SgParameter * > * p_s_
Definition: SgEstimator.h:186
QList< SgParameter * > * list_
Definition: SgEstimator.h:70