English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Modeler: TGPBuilder.h Source File
Uranie / Modeler v4.9.0
/* @license-end */
TGPBuilder.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2024 CEA/DES
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as published
6// by the Free Software Foundation, either version 3 of the License, or any
7// later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
18// $Id$
19// $Author$
20// $Date$
21// $Revision$
22// $State$
24
56#ifndef TGPBUILDER_H
57#define TGPBUILDER_H
58
60#include "TObjArray.h"
61
64#include "TShareEval.h"
65#include "TDataServer.h"
66#include "TAttribute.h"
67#include "TKriging.h"
68
70extern "C"
71{
72int gpMod0(double *Kin, double *yin, int n, double *gamma, double *iL);
73int gpModh(double *Hin, double *Kin, double *yin, int n, int p, double *hbeta, double *vbeta, double *gamma, double *iL, double *iR, double *M);
74int gpModhBayes(double *BetaPrior, double *QPrior, double *Hin, double *Kin, double *yin, int n, int p, double *BetaPost, double *QPost, double *gamma, double *iL, double *iR, double *M);
75
76int gpLoo0Error(double *Kin, double *yin, int n, double *errorLoo, double *varLoo, double *eqmLoo);
77int gpLoohError(double *Hin, double *Kin, double *yin, int n, int p, double *errorLoo, double *varLoo, double *eqmLoo);
78int gpLoohBayesError(double *BetaPrior, double *Qprior, double *Hin, double *Kin, double *yin, int n, int p, double *errorLoo, double *varLoo, double *eqmLoo);
79}
80;
81
82namespace URANIE
83{
84 namespace Modeler
85 {
87 {
88
89 // Attributes
90 private:
91 Bool_t _blog;
92
93 void LSort(Double_t *costValues, Int_t *minIndexes, Int_t nbthreads, Int_t n);
94
95 public:
96 URANIE::DataServer::TDataServer *_tds;
97
100 Int_t _nX;
101 Int_t _nY;
102
107
108 Int_t _nS;
109 Int_t _nP;
110 Double_t reg;
111 Double_t tolerance;
112 Double_t sigma2;
113 Double_t alpha;
114 Double_t* Vmes;
115 Double_t* H;
116 Double_t* C;
117 Double_t* K;
118 Double_t* xObs;
119 Double_t* yObs;
120 Double_t* xNormParams;
121
122 Double_t _modlengthMax;
123 Double_t _modlengthMin;
125
126 TString trendString;
127 TObjArray* trendCoefList;
128 Bool_t bHas_trend;
130
131 Double_t* BetaPrior;
132 Double_t* QPrior;
133 Bool_t bUse_prior;
134 Int_t _nSeed;
135
136 Int_t _retOptim;
137
139
140 // Operations
141 public:
142 //---------------------------------------------
146
148
150
159 TGPBuilder(URANIE::DataServer::TDataServer *tdsObs,
160 const char *varexpinput,
161 const char *varexpoutput,
162 TCorrelationFunction* corrFunc,
163 const char *trend = "",
164 Option_t *option = "");
165
167
178 TGPBuilder(URANIE::DataServer::TDataServer *tdsObs,
179 const char *varexpinput,
180 const char *varexpoutput,
181 const char *corrFunc,
182 const char *trend = "",
183 Option_t *option = "");
184
186
198 TGPBuilder(URANIE::DataServer::TDataServer *tdsModelData);
199
201
204
207
209 void createTrend();
210
212 virtual ~TGPBuilder();
214
215 //---------------------------------------------
219
221 {
222 return bHas_corrFunction;
223 }
224
227 {
228 return bVariance_in_factor;
229 }
230
233 {
235 }
236
238 Bool_t hasTrend()
239 {
240 return bHas_trend;
241 }
242
244 Bool_t usePrior()
245 {
246 return bUse_prior;
247 }
248
251 {
252 return _retOptim;
253 }
254
260
263 {
264 return _nX;
265 }
266
268 Int_t getNObs()
269 {
270 return _nS;
271 }
272
275 {
276 return _nP;
277 }
278
280
284 Double_t* getObsInputs()
285 {
286 return xObs;
287 }
288
290 Double_t* getObsOutput()
291 {
292 return yObs;
293 }
294
296
302 {
303 return xNormParams;
304 }
305
308 {
309 return K;
310 }
311
312 void setKandCandCorrFunc(Double_t* inK, Double_t* inC, TCorrelationFunction* corrFunc)
313 {
314 K = inK;
315 C = inC;
316 correlationFunction = corrFunc;
318 }
319
322 {
323 return C;
324 }
325
328 {
329 return Vmes;
330 }
331
333 Double_t* getTrendMatrix()
334 {
335 return H;
336 }
337
339 TObjArray* getTrendFormula()
340 {
341 return trendCoefList;
342 }
343
346 {
347 return trendString;
348 }
349
352 {
353 return BetaPrior;
354 }
355
358 {
359 return QPrior;
360 }
361
363 Double_t getVariance()
364 {
365 return sigma2;
366 }
367
369 Double_t getTolerance()
370 {
371 return tolerance;
372 }
373
375 Double_t getAlpha()
376 {
377 return alpha;
378 }
379
382 {
383 return reg;
384 }
385
386
388 Int_t getSeed()
389 {
390 return _nSeed;
391 }
392
394
395 //---------------------------------------------
399
407 void setLengthRange(double themin, double themax);
408
410
417 void setLengthMaxScreeningSF(double sf);
418
420
427
429
436 void setCorrFunction(const char* corrFuncType);
437
439
442 void setVariance(Double_t var)
443 {
444 sigma2 = var;
445 }
446
448
451 void setTolerance(Double_t tol)
452 {
453 tolerance = tol;
454 }
455
457
465 void setRegularisation(Double_t regularisation)
466 {
467 reg = regularisation;
468 }
469
471
481 void setHasMeasurementError(Bool_t has_measurement_error = kTRUE)
482 {
483 bHas_measurement_error = has_measurement_error;
484 }
485
487
495 void setAlpha(Double_t a)
496 {
497 alpha = a;
499 bVariance_in_factor = kTRUE;
500 }
501
503
510 void setMeasurementErrorCovMatrix(Double_t* covMes);
511
513
520 void setMeasurementErrorVariance(Double_t varMes);
521
523
541 void setTrendString(const char* trend)
542 {
543 trendString = TString(trend);
544 }
545
547
556 void setPriorData(Double_t* betaPrior, Double_t* qPrior);
557
559
564 void setUsePrior(Bool_t use_prior = kTRUE);
565
567 void computeCovarianceMatrix(bool print = false);
568
570
575 void setSeed(Int_t nSeed = 0);
576
578
579 //---------------------------------------------
583
585
591
593
606 void exportGPData(const char* fileName);
607
608
610
674 void findOptimalParameters(TString criterion = "ML",
675 Int_t screeningSize = 100,
676 TString optimAlgo = "BFGS",
677 Int_t nbMaxOptimSteps = 1000,
678 Bool_t reset = kTRUE,
679 Option_t * option = "");
680
682
692 URANIE::Modeler::TKriging* buildGP(Bool_t computeLooErrors = kTRUE);
693
695 void cleanAttributeList(TList *inputlist);
697
698 //---------------------------------------------
704 void setLog()
705 {
706 _blog = kTRUE;
707 }
708
709 void unsetLog()
710 {
711 _blog = kFALSE;
712 }
713
715 {
716 _blog = !_blog;
717 }
718
719 Bool_t getLog()
720 {
721 return _blog;
722 }
723
724 virtual void printLog(Option_t *option = "");
726
727 ClassDef(URANIE::Modeler::TGPBuilder, ID_MODELER)
728 //Classe de
729 };
730 } // Fin du namespace Modeler
731} // Fin du namespace URANIE
732#endif
Interface de la classe URANIE::Modeler::TCorrelationFunction.
int gpLoohError(double *Hin, double *Kin, double *yin, int n, int p, double *errorLoo, double *varLoo, double *eqmLoo)
int gpLoohBayesError(double *BetaPrior, double *Qprior, double *Hin, double *Kin, double *yin, int n, int p, double *errorLoo, double *varLoo, double *eqmLoo)
int gpLoo0Error(double *Kin, double *yin, int n, double *errorLoo, double *varLoo, double *eqmLoo)
int gpModhBayes(double *BetaPrior, double *QPrior, double *Hin, double *Kin, double *yin, int n, int p, double *BetaPost, double *QPost, double *gamma, double *iL, double *iR, double *M)
int gpModh(double *Hin, double *Kin, double *yin, int n, int p, double *hbeta, double *vbeta, double *gamma, double *iL, double *iR, double *M)
int gpMod0(double *Kin, double *yin, int n, double *gamma, double *iL)
Interface de la classe URANIE::Modeler::TKriging.
Description of the class TCorrelationFunction.
Definition TCorrelationFunction.h:53
Description of the class TGPBuilder.
Definition TGPBuilder.h:87
void setTrendString(const char *trend)
Set the deterministic trend character string.
Definition TGPBuilder.h:541
Int_t getNObs()
Return the number of observations used to build the GP model.
Definition TGPBuilder.h:268
void initMatrices()
Initialisation of the matrices.
Double_t * BetaPrior
a priori mean vector for the deterministic trend parameters (size: _nP)
Definition TGPBuilder.h:131
Double_t * getMeasurementErrorCovMatrix()
Return the array of the covariance matrix of the measurement errors.
Definition TGPBuilder.h:327
TCorrelationFunction * getCorrFunction()
Return a pointer to the correlation function of the gaussian process.
Definition TGPBuilder.h:256
void setMeasurementErrorCovMatrix(Double_t *covMes)
Set the covariance matrix of the measurement errors.
Double_t * xNormParams
The matrix of normalisation parameters. Contains min and max value of each input variable: [x1Min,...
Definition TGPBuilder.h:120
Bool_t usePrior()
Return kTRUE if prior knowledge on the deterministic trend is used (bayesian approach).
Definition TGPBuilder.h:244
Bool_t bHas_corrFunction
kFALSE if correlationFunction == NULL, kTRUE otherwise
Definition TGPBuilder.h:104
TString _sInputAttributes
input attributes names separated by ":"
Definition TGPBuilder.h:98
void setPriorData(Double_t *betaPrior, Double_t *qPrior)
Set the a priori mean and variance of the trend coefficients.
Double_t * getTrendMatrix()
Return the array of the deterministic trend matrix.
Definition TGPBuilder.h:333
void setMeasurementErrorVariance(Double_t varMes)
Set the variance of the measurement errors.
Double_t getRegularisation()
Return the regularisation coefficient.
Definition TGPBuilder.h:381
void setCorrFunction(TCorrelationFunction *corrFunc)
Set the correlation function of the gaussian process.
Double_t sigma2
Variance of the gaussian process.
Definition TGPBuilder.h:112
Bool_t bVariance_in_factor
if kTRUE, GP variance is calculated analytically. Otherwise, it is a parameter of the cost function.
Definition TGPBuilder.h:105
void setVariance(Double_t var)
Set the variance of the gaussian process.
Definition TGPBuilder.h:442
Double_t _modlengthMin
Minimum value of the correlation length if default behaviour is requested to be changed by the user.
Definition TGPBuilder.h:123
Bool_t bHas_trend
kFALSE if no deterministic trend is defined, kTRUE otherwise.
Definition TGPBuilder.h:128
TString _sOutputAttributes
output attribute name
Definition TGPBuilder.h:99
TCorrelationFunction * correlationFunction
The correlation function.
Definition TGPBuilder.h:103
void setSeed(Int_t nSeed=0)
set a seed number
URANIE::DataServer::TDataServer * _tds
Pointer to the data server containing the observations.
Definition TGPBuilder.h:96
Double_t * xObs
The matrix of normalised inputs (dimension: _nX * _nS)
Definition TGPBuilder.h:118
Double_t * K
The covariance matrix (dimension: _nS * _nS)
Definition TGPBuilder.h:117
Int_t getSeed()
Return the seed number.
Definition TGPBuilder.h:388
Double_t reg
regularisation parameter, used to improve numerical stability of matrix operations
Definition TGPBuilder.h:110
Int_t getNTrendParams()
Return the number of parameters of the deterministic trend.
Definition TGPBuilder.h:274
void createTrend()
Create the matrices for the deterministic trend.
int getReturnOptim()
Return the return of the optimisation procedure.
Definition TGPBuilder.h:250
TObjArray * trendCoefList
List of the formulas of the trend coefficients (_nP elements)
Definition TGPBuilder.h:127
void exportGPData(const char *fileName)
Export the minimum information necessary to build a new TKriging object.
TGPBuilder(URANIE::DataServer::TDataServer *tdsModelData)
Construction from a data server containing model parameters.
Double_t * getCovarianceMatrix()
Return the array of the covariance matrix of the gaussian process.
Definition TGPBuilder.h:307
void setKandCandCorrFunc(Double_t *inK, Double_t *inC, TCorrelationFunction *corrFunc)
Definition TGPBuilder.h:312
Bool_t bUse_normalisation
if kFALSE, the matrix H will be computed with unormalised input data. This happens when the user is p...
Definition TGPBuilder.h:129
TGPBuilder(URANIE::DataServer::TDataServer *tdsObs, const char *varexpinput, const char *varexpoutput, TCorrelationFunction *corrFunc, const char *trend="", Option_t *option="")
Construction from a data server, a list of input and output variables and a correlation function obje...
TObjArray * getTrendFormula()
Return the deterministic trend list of formulas.
Definition TGPBuilder.h:339
void computeCovarianceMatrix(bool print=false)
Computes the covariance matrix of the observed data.
void cleanAttributeList(TList *inputlist)
Clean list of attribute.
void LSort(Double_t *costValues, Int_t *minIndexes, Int_t nbthreads, Int_t n)
Double_t alpha
Quotient of the variance of the measurment error and the variance of the gaussian process.
Definition TGPBuilder.h:113
Bool_t bUse_prior
kFALSE if no prior is used, kTRUE otherwise
Definition TGPBuilder.h:133
Double_t getAlpha()
Return the alpha parameter, quotient of the variance of the measurement error and the variance of the...
Definition TGPBuilder.h:375
TString getTrendString()
Return the deterministic trend character string.
Definition TGPBuilder.h:345
Double_t * QPrior
a priori variance matrix for the deterministic trend parameters (size: _nP x _nP)
Definition TGPBuilder.h:132
Int_t getNInputs()
Return the number of input variables.
Definition TGPBuilder.h:262
Bool_t _blog
Boolean for edit the log.
Definition TGPBuilder.h:91
void setTolerance(Double_t tol)
Set the tolerance used to stop the optimisation process.
Definition TGPBuilder.h:451
URANIE::Modeler::TKriging * buildGP(Bool_t computeLooErrors=kTRUE)
Build the gaussian process model.
void setLog()
Definition TGPBuilder.h:704
Double_t tolerance
Tolerance value used to stop the optimisation process.
Definition TGPBuilder.h:111
void changeLog()
Definition TGPBuilder.h:714
void setLengthMaxScreeningSF(double sf)
Set the scale factor to reduce the maximum value of the correlation length during screening.
Int_t _retOptim
optimisation results
Definition TGPBuilder.h:136
Bool_t bHas_measurement_error
if kTRUE, the construction of the GP will take into account the existence of a measurement error vari...
Definition TGPBuilder.h:106
void findOptimalParameters(TString criterion="ML", Int_t screeningSize=100, TString optimAlgo="BFGS", Int_t nbMaxOptimSteps=1000, Bool_t reset=kTRUE, Option_t *option="")
Search for the optimal parameters of the Gaussian Process.
virtual void printLog(Option_t *option="")
Bool_t hasVarianceInFactor()
Return kTRUE if the variance of the GP is determined analytically.
Definition TGPBuilder.h:226
void updateObservations()
Update the GP builder matrices.
void setLengthRange(double themin, double themax)
Set the Minimun and maximum boundaries for the correlation length.
void initVariables()
Initialisation of the GPBuilder variables.
Double_t * Vmes
The covariance matrix of the measurement errors (dimension: _nS * _nS)
Definition TGPBuilder.h:114
TString trendString
Character string containing the trend parameters separated by ":" or a trend type ("Const" or "Linear...
Definition TGPBuilder.h:126
void setCorrFunction(const char *corrFuncType)
Set the correlation function of the gaussian process from a character string.
TGPBuilder()
Default Constructor.
virtual ~TGPBuilder()
Default destructor.
void setRegularisation(Double_t regularisation)
Set the regularisation coefficient.
Definition TGPBuilder.h:465
Bool_t bIsbuildWithDuplicateKandCandCorrFunc
kTRUE if build with duplicate K, C and CorrFunc, otherwise kFALSE
Definition TGPBuilder.h:138
TGPBuilder * buildWithDuplicateKandCandCorrFunc()
Double_t _modlengthMax
Maximum value of the correlation length if default behaviour is requested to be changed by the user.
Definition TGPBuilder.h:122
void setUsePrior(Bool_t use_prior=kTRUE)
Set wether or not to use a priori knowledge on the deterministic trend parameters.
Double_t * C
The correlation matrix (dimension: _nS * _nS)
Definition TGPBuilder.h:116
Bool_t hasTrend()
Return kTRUE if a deterministic trend has been defined.
Definition TGPBuilder.h:238
Int_t _nP
Number of coefficients of the deterministic trend.
Definition TGPBuilder.h:109
Double_t _lengthMaxScreeningSF
Scale factor to change the Maximum value of the correlation length during screening procedure: new le...
Definition TGPBuilder.h:124
Double_t getTolerance()
Return the tolerance used to stop the optimisation process
Definition TGPBuilder.h:369
Double_t * getTrendPriorCovMat()
Return the array of the a priori covariance matrix of the trend parameters.
Definition TGPBuilder.h:357
Bool_t getLog()
Definition TGPBuilder.h:719
Bool_t hasMeasurementError()
Return kTRUE if a measurement error should be considered to build the GP.
Definition TGPBuilder.h:232
Double_t * yObs
Array representation of the outputs (size: _nS)
Definition TGPBuilder.h:119
Int_t _nX
Number of input attributes.
Definition TGPBuilder.h:100
Int_t _nY
Number of output attributes (should be equal to 1)
Definition TGPBuilder.h:101
void setHasMeasurementError(Bool_t has_measurement_error=kTRUE)
Indicate if a measurement error should be taken into account or not.
Definition TGPBuilder.h:481
Double_t * getTrendPriorMeans()
Return the array of the a priori means of the trend parameters.
Definition TGPBuilder.h:351
Int_t _nS
Number of observations.
Definition TGPBuilder.h:108
Double_t * getCorrelationMatrix()
Return the array of the correlation matrix of the gaussian process.
Definition TGPBuilder.h:321
Double_t * getObsInputs()
Return the observations inputs as a flat array.
Definition TGPBuilder.h:284
Double_t * getObsNormParams()
Return the normalisation parameters of the inputs as a flat array.
Definition TGPBuilder.h:301
Double_t * getObsOutput()
Return the observations outputs.
Definition TGPBuilder.h:290
Double_t * H
Deterministic trend matrix (dimension: _nS * _nP)
Definition TGPBuilder.h:115
TGPBuilder(URANIE::DataServer::TDataServer *tdsObs, const char *varexpinput, const char *varexpoutput, const char *corrFunc, const char *trend="", Option_t *option="")
Construction from a data server, a list of input and output variables and a correlation function name...
Int_t _nSeed
number of seed for pseudo-random generator
Definition TGPBuilder.h:134
Bool_t hasCorrFunction()
Return kTRUE if a correlation function is defined, kFALSE otherwise.
Definition TGPBuilder.h:220
void setAlpha(Double_t a)
Set the value of the alpha parameter.
Definition TGPBuilder.h:495
Double_t getVariance()
Return the variance of the gaussian process.
Definition TGPBuilder.h:363
void unsetLog()
Definition TGPBuilder.h:709
Description of the class TKriging.
Definition TKriging.h:79
ROOT.
Definition TAnisp.h:164