English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Modeler: TPolynomialChaos.h Source File
Uranie / Modeler v4.9.0
/* @license-end */
TPolynomialChaos.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/>.
17
36#ifndef TPOLYNOMIALCHAOS_H
37#define TPOLYNOMIALCHAOS_H
38
39//ROOT
40#include "Rtypes.h"
41#include "TNamed.h"
42
43// uranie
44#include "TDataServer.h"
45#include "Modeler.h"
46
47//nisp
48#include "TNisp.h"
49#include "nisp_pc.h"
50#include "nisp_util.h"
51
52#include <ctime>
53
54using namespace URANIE::DataServer;
55
56namespace URANIE
57{
58namespace Modeler
59{
60class TPolynomialChaos: public TNamed
61{
62 protected:
63 URANIE::DataServer::UMessageLogger *_fLogger;
64//-----------------------members of the class
65public:
69 Int_t _degree;
71 PolynomialChaos * _pc;
73 Int_t _nx;
75 Int_t _np;
76 // Number of output
77 Int_t _ny;
78 Bool_t _bStoreYHat;
79
85
86 vector<double> *_verrloo;
87 int _degval;
88 double _eqmval;
89
90private:
92 TDataSpecification * _listAttOut;
94 Bool_t _blog;
95//--------------------methodes of the class
96public:
101
115 TPolynomialChaos(TDataServer *tds, TNisp *nisp, TString soutput = "");
116
120 TPolynomialChaos(const char *ct);
121
123
128
132
137 void setDegree(Int_t degree);
138
140
145 void setAutoDegreeFactor(double autodeg);
146
148
153 void setAutoDegreeBoundaries(int amin, int amax=-1);
154
157 {
158 return _degreeResults;
159 }
160
163 {
164 return _bestAutoDeg;
165 }
166
168
172 void computeOutput(double *input);
174
180 Double_t getOutput(TString jname = "");
182
186 Double_t getOutput(Int_t j);
187
189
192 Double_t getEqmLoo(Int_t rank=0);
193
195
199 Double_t getErrLoo(Int_t input, Int_t rank=0);
200
202 double factorial(int n);
203
205
209 void automatisedDegree(Option_t *option = "");
211
215 void computeChaosExpansion(TString type, Option_t * option = "");
217
221 Double_t getMean(Int_t j);
223
229 Double_t getMean(TString name = "");
231
235 Double_t getVariance(Int_t j);
237
243 Double_t getVariance(TString name = "");
245
250 Double_t getCovariance(Int_t i, Int_t j);
252
259 Double_t getCovariance(TString xname, TString yname);
261
266 Double_t getCorrelation(Int_t i, Int_t j);
268
275 Double_t getCorrelation(TString xname, TString yname);
277
282 Double_t getIndexFirstOrder(Int_t i, Int_t j = 0);
284
291 Double_t getIndexFirstOrder(TString xname, TString yname = "");
293
298 Double_t getIndexTotalOrder(Int_t i, Int_t j = 0);
300
307 Double_t getIndexTotalOrder(TString xname, TString yname = "");
309
314 Double_t getIndex(TString sinput = "", TString yname = "");
316
321 Double_t getIndexInteraction(TString sinput = "", TString yname = "");
323
328
333
338
341 Int_t getDegree();
343
348 void exportFunction(const char *file = "nisp",
349 const char *name = "nisp_fct");
351
356 Double_t getCoefficient(Int_t k, TString jname = "");
360 void setLog()
361 {
362 _blog = kTRUE;
363 }
364 void unsetLog()
365 {
366 _blog = kFALSE;
367 }
369 {
370 _blog = _blog ? kFALSE : kTRUE;
371 }
372 Bool_t getLog()
373 {
374 return _blog;
375 }
376 virtual void printLog(Option_t *option = "");
378private:
380
383 void getTarget();
385
389 void setGroupAddVar(Int_t i);
391
394 void writeCodeCToDenormalizeInput(std::ofstream * sourcefile);
396
400public:
401
403
409 void setCoefficient(Int_t noutput, Int_t num, Double_t coef);
410
412
417 Double_t getCoefficient(Int_t noutput, Int_t num);
418
419 //---------------A FAIRE----------juste un lien vers nisp actuellement
430 void generateSample(TString type, Int_t np, Int_t order=1);
434 Double_t getSample(Int_t k, Int_t j);
439 Double_t getSample(Int_t k, TString yname);
449 void getAnova(Int_t nt);
453 void getAnovaOrdered(Double_t seuil, Int_t j);
461 void getAnovaOrdered(Double_t seuil, TString yname = "");
465 void getAnovaOrderedCoefficients(Double_t seuil, Int_t j);
473 void getAnovaOrderedCoefficients(Double_t seuil, TString yname = "");
479 Double_t getQuantile(Double_t alpha, Int_t j);
487 Double_t getQuantile(Double_t alpha, TString yname);
494 Double_t getQuantileWilks(Double_t alpha, Double_t beta, Int_t j = 1);
503 Double_t getQuantileWilks(Double_t alpha, Double_t beta, TString yname);
509 Double_t getInvQuantile(Double_t seuil, Int_t j = 1);
517 Double_t getInvQuantile(Double_t seuil, TString yname);
521 void readTarget(Char_t *file);
525 void setInput(Int_t nt, Double_t dt);
533 void propagateInput(Double_t *dt);
538 void save(Char_t *file);
539 void save(string file);
543 void setAnova();
545
546 ClassDef(URANIE::Modeler::TPolynomialChaos, ID_MODELER)
547
548};
549//end of the class TPolynomialChaos
550}//end of the namespace Modeler
551} //end of the namespace URANIE
552#endif
Interface of the class URANIE::Modeler::TNisp.
Description of the class TNisp.
Definition TNisp.h:62
Description of the class TPolynomialChaos.
Definition TPolynomialChaos.h:61
Double_t getVariance(Int_t j)
Get the variance.
Double_t getInvQuantile(Double_t seuil, Int_t j=1)
Return the probability of a value overrun.
void setLog()
Definition TPolynomialChaos.h:360
Double_t getQuantile(Double_t alpha, TString yname)
Return the quantile of order "alpha".
Double_t getErrLoo(Int_t input, Int_t rank=0)
Get the Leave-One-Out uncertainty for the input (input) and the output (rank)
void propagateInput()
Propagation of input which has been specified SetInput()
Int_t _ny
Definition TPolynomialChaos.h:77
Double_t getIndexTotalOrder(Int_t i, Int_t j=0)
Total index of sensitivity.
Int_t getDegree()
Get the degree.
double factorial(int n)
Dummy factorial methods.
void setGroupEmpty()
Freeing the set.
void setAutoDegreeBoundaries(int amin, int amax=-1)
Change the min and max degree tested for automatise degree determination.
Double_t getOutput(TString jname="")
Get an output.
int _degval
memory arry for the degree in the tree
Definition TPolynomialChaos.h:87
TTree * getAutoDegreeResults()
Return a pointer to the TTree that contains the degree optimisation results.
Definition TPolynomialChaos.h:156
double _eqmval
memory arry for the eqm in the tree
Definition TPolynomialChaos.h:88
void generateSample(TString type, Int_t np, Int_t order=1)
Build a sample for statitical analysis (quantile). Build a sample of size "np" by the method "type".
void getAnovaOrderedCoefficients(Double_t seuil, TString yname="")
Edition of the ANOVA ordered decomposition / coefficients.
void setCoefficient(Int_t noutput, Int_t num, Double_t coef)
Set the coefficient beta of _pc.
void getAnovaOrdered(Double_t seuil, Int_t j)
int _bestAutoDeg
Best value for automatic degree scan.
Definition TPolynomialChaos.h:84
TPolynomialChaos(TDataServer *tds, TNisp *nisp, TString soutput="")
default constructor from a set of stochastic variables
PolynomialChaos * _pc
Object of type polynomialChaos (library Nisp)
Definition TPolynomialChaos.h:71
int _minAutoDeg
Minimal value for automatic degree scan.
Definition TPolynomialChaos.h:82
Double_t getIndexFirstOrder(TString xname, TString yname="")
First index of sensitivity.
TNisp * _nisp
Message logger.
Definition TPolynomialChaos.h:67
Int_t getDimensionExpansion()
Number of the coefficients of the polynomial chaos.
Int_t _nx
Number of stochastic variables i.e number of input.
Definition TPolynomialChaos.h:73
void realisation()
Polynomial chaos is a random variable : a realisation of this random variable (GetOutput()).
TTree * _degreeResults
TDSNtupleD used to store the results of the automatisedDegree method.
Definition TPolynomialChaos.h:80
Int_t _degree
Degree of the Chaos polynomial.
Definition TPolynomialChaos.h:69
void automatisedDegree(Option_t *option="")
Computation of coefficients.
void readTarget(Char_t *file)
Read a set of target from a file.
void setInput(Int_t nt, Double_t dt)
Set an input.
Double_t getCovariance(Int_t i, Int_t j)
Get the Covariance.
Bool_t getLog()
Definition TPolynomialChaos.h:372
void computeOutput(double *input)
Computation of output in relation with input : input[0...nx-1].
void getAnovaOrderedCoefficients(Double_t seuil, Int_t j)
void save(Char_t *file)
Saving of the PC in a file.
void computeChaosExpansion(TString type, Option_t *option="")
Computation of coefficients.
TPolynomialChaos(const TPolynomialChaos &TPC)
copy constructor
Double_t getMean(TString name="")
Get the mean.
Double_t getIndexInteraction(TString sinput="", TString yname="")
Index of interaction sensitivity of a set of variables.
Double_t getQuantileWilks(Double_t alpha, Double_t beta, Int_t j=1)
Return the Wilks' quantile of order "alpha" with confidence "beta".
void setDegree(Int_t degree)
Set the degree.
void propagateInput(Double_t *dt)
Propagation of dt[1...nx].
virtual void printLog(Option_t *option="")
Int_t _np
Number of simulation.
Definition TPolynomialChaos.h:75
Double_t getOutput(Int_t j)
Get an output.
void setAutoDegreeFactor(double autodeg)
Change the factor that links the number of samples, coefficient and the highest possible degree.
Bool_t _blog
Boolean for edit the log.
Definition TPolynomialChaos.h:94
Double_t getMean(Int_t j)
Get the mean.
Double_t getIndexFirstOrder(Int_t i, Int_t j=0)
First index of sensitivity.
Double_t getEqmLoo(Int_t rank=0)
Get the Mean squared uncertainty for the output with rank.
void getTarget()
Get the target.
int _maxAutoDeg
Maximal value for automatic degree scan.
Definition TPolynomialChaos.h:83
Int_t getDimensionOutput()
Number of output.
virtual ~TPolynomialChaos()
destructor
Double_t getVariance(TString name="")
Get the variance.
Double_t getSample(Int_t k, Int_t j)
void unsetLog()
Definition TPolynomialChaos.h:364
double _autoDegreeFactor
Factor used to scale the maximum degree knowing _nx and _np.
Definition TPolynomialChaos.h:81
void setAnova()
Preparation on the ANOVA decomposition.
Double_t getCovariance(TString xname, TString yname)
Get the Covariance.
Int_t getDimensionInput()
Number of input.
void getAnova(Int_t nt)
Edition of the ANOVA decomposition.
Double_t getCorrelation(TString xname, TString yname)
Get the correlation.
Double_t getInvQuantile(Double_t seuil, TString yname)
Return the probability of a value overrun.
Double_t getIndexTotalOrder(TString xname, TString yname="")
Total index of sensitivity.
void setGroupAddVar(Int_t i)
Add a random variable.
void exportFunction(const char *file="nisp", const char *name="nisp_fct")
Export the model in C++ langage in a file.
void changeLog()
Definition TPolynomialChaos.h:368
void writeCodeCToDenormalizeInput(std::ofstream *sourcefile)
Write set Denormalization.
Double_t getCorrelation(Int_t i, Int_t j)
Get the correlation.
Double_t getSample(Int_t k, TString yname)
The value of the output yname for the example k.
TDataSpecification * _listAttOut
Object of type TDataSpecification used to index the name of the variables.
Definition TPolynomialChaos.h:92
void getAnovaOrdered(Double_t seuil, TString yname="")
Return the ANOVA ordered decomposition.
Double_t getCoefficient(Int_t noutput, Int_t num)
Get the coefficient beta of _pc.
vector< double > * _verrloo
vector to contains the err loo and store them in the tree
Definition TPolynomialChaos.h:86
URANIE::DataServer::UMessageLogger * _fLogger
Definition TPolynomialChaos.h:63
Double_t getQuantileWilks(Double_t alpha, Double_t beta, TString yname)
Return the Wilks' quantile of order "alpha" with confidence "beta".
Double_t getCoefficient(Int_t k, TString jname="")
Get coefficents value.
Double_t getQuantile(Double_t alpha, Int_t j)
Return the quantile of order "alpha".
Double_t getIndex(TString sinput="", TString yname="")
Index of sensitivity of a set of variables.
Bool_t _bStoreYHat
Boolean to specify if we add the \hat{} attribute in the TDS [default kTRUE].
Definition TPolynomialChaos.h:78
int getBestAutoDegree()
Return the bet estimated degree when optimisation is done with regression.
Definition TPolynomialChaos.h:162
ROOT.
Definition TAnisp.h:164