English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Modeler: TAnisp.h Source File
Uranie / Modeler v4.9.0
/* @license-end */
TAnisp.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
131#ifndef TANISP_H
132#define TANISP_H
133
134#include <vector>
135#include <string>
136#include "math.h"
137
138//ROOT
139#include "Rtypes.h"
140#include "TLeaf.h"
141#include "TCanvas.h"
142#include "TH1F.h"
143#include "TLegend.h"
144
145// uranie
146#include "TDataServer.h"
147#include "TModeler.h"
148#include "TStochAttribut.h"
149#include "UExceptions.h"
150#include "TLauncherFunction.h"
151#include "TCode.h"
152#include "TLauncher.h"
153#include "TPolynomialChaos.h"
154#include "TNisp.h"
155
156// anisp
157#include "anisp.hpp"
158
159using namespace URANIE::DataServer;
160using namespace URANIE::Exceptions;
161using namespace URANIE::Launcher;
162
163namespace URANIE
164{
165namespace Modeler
166{
167
168void StepByStepOutput(Double_t * val, vector<Int_t *> indices);
169
170void functionLauncher(vector<Double_t *> ptEXp);
171
172class TAnisp: public TModeler
173{
175public:
181
189 friend void StepByStepOutput(Double_t * val, vector<Int_t *> indices);
190
197 friend void functionLauncher(vector<Double_t *> ptEXp);
198
199// public:
200// //! Boolean for edit the log.
201// Bool_t _blog;
202
203private:
207 Double_t _dTolerance;
209 Int_t _nKMin;
221 TString _sLaws;
225 TLauncherFunction * _tAnalyticalFunction;
227 TCode * _Code;
229 TLauncher * _tlauncher;
240 /* //! Canvas for graphical outputs */
241 /* TCanvas * _myCanvas; */
247 TString _sinput;
249 TString _soutput;
251 TDataServer* _tdsAnisp;
253#ifdef ROOT5
255#else
256 void (*_analyticalFunction)(Double_t*, Double_t*);
257#endif
261 Int_t _ninputs;
266 /* //! Object of type TH1F used for graphical output */
267 /* TH1F* _hist1; */
268 /* //! Object of type TH1F used for graphical output */
269 /* TH1F* _hist2; */
270
271public:
283#ifdef ROOT5
284 TAnisp(TDataServer *tds, void *analyticalFunction, TString sinput = "",
285 TString soutput = "", Option_t *option = "");
286#else
287 TAnisp(TDataServer *tds, void (*analyticalFunction)(Double_t*,Double_t*),
288 const char *fname, TString sinput = "",
289 TString soutput = "", Option_t *option = "");
290#endif
299 TAnisp(TDataServer *tds, const char* analyticalFunction, TString sinput = "",
300 TString soutput = "", Option_t *option = "");
301
308 TAnisp(TDataServer *tds, TCode* code, Option_t *option = "");
310
313 virtual ~TAnisp();
315
316 //---------------------------------------------
320
325 void exportModelCplusplus(std::ofstream * sourcefile) const;
326
328
332 void exportModelFortran(std::ofstream * sourcefile) const
333 {
334 UNUSED(sourcefile);
335 std::cerr
336 << " --- Method TAnisp::exportModelFortran(ofstream * sourcefile) not yet implemented"
337 << endl;
338 } ;
339
341
345 void exportModelPMML(const char* file = "",
346 const char* name = "",Option_t *option = "") const
347 {
348 TString soption = option;
349 soption.ToLower();
350 UNUSED(file,name);
351 std::cerr
352 << " --- Method TAnisp::exportModelPMML(ofstream * sourcefile) not yet implemented"
353 << endl;
354 };
355
357
361 void exportModelPython(std::ofstream * sourcefile) const
362 {
363 UNUSED(sourcefile);
364 std::cerr
365 << " --- Method TAnisp::exportModelPython(ofstream * sourcefile) not yet implemented"
366 << endl;
367 };
369
370 //---------------------------------------------
374// void setLog() { _blog = kTRUE;}
375// void unsetLog() { _blog = kFALSE;}
376// void changeLog() { _blog = _blog? kFALSE : kTRUE ; }
377// Bool_t getLog() { return _blog; }
382 virtual void printLog(Option_t *option = "");
384
385 //---------------------------------------------
386
389
397 void setKMin(Int_t kmin);
398
403 Int_t getKMin()
404 {
405 return _nKMin;
406 }
407
409
413 void setTolerance(Double_t tol);
414
419 Double_t getTolerance()
420 {
421 return _dTolerance;
422 }
423
429
438
443 void setGreaterIndice(Int_t greatInd);
444
450 {
451 return _nGreaterIndice;
452 }
453
458 void setMaxIndices(Int_t maxInd);
459
465 {
466 return _nMaxIndices;
467 }
468
473 void setDegreeMax(Int_t degMax);
474
480 {
481 return _nDegreeMax;
482 }
483
488 Int_t getCible()
489 {
490 return _nCible;
491 }
492
494
499 {
500 return _nIterationNumber;
501 }
502
507 void setlog(Bool_t blog);
508
513 void setRootFilename(TString rootName);
514
520 {
521 return _sRootFilename;
522 }
523
529 {
530 return _tErrorIndicator;
531 }
532
538 {
540 }
541
547
553 TString getVariablesName(TString inputs = "");
554
556
559
567 TString getDataAnispFile() const
568 {
569 return _sRootFilename + "data.dat";
570 }
571
576 TString getResultFile() const
577 {
578 return _sRootFilename + TString("res.dat");
579 }
580
585 TString getStochasticFile() const
586 {
587 return _sRootFilename + "sto.dat";
588 }
589
594 TString getErrorIndicatorFile() const
595 {
596 return _sRootFilename + "error.dat";
597 }
598
603 TString getIndicesFile() const
604 {
605 return _sRootFilename + "indices.dat";
606 }
607
609
612
616
628 void setAllAnispParameters(Double_t tol, Int_t kmin, Int_t nmos,
629 Int_t greatInd, Int_t maxInd, Bool_t blog, Int_t degMax,
630 TString rootName);
631
641 void setAnispParameters(Double_t tol, Int_t kmin, Int_t nmos,
642 Int_t greatInd, Int_t maxInd, Bool_t blog);
643
650 void setLightAnispParameters(Double_t tol, Int_t kmin, Int_t nmos);
651
653
656
663 void runAnisp();
664
669
671
672private:
677
688 void addErrorIndicator(Double_t * errInd)
689 {
690 _tErrorIndicator->Fill(errInd);
691 }
692
700 void addIntegrationIndices(Double_t * ind)
701 {
702 _tIntegrationIndices->Fill(ind);
703 }
704
711 void launchCalculs(vector<Double_t *> ptExp);
712
722 void EndIterationActions(Double_t * errIndicator,
723 vector<Double_t *> integrationIndices);
724
729 void changeOfVariable(Double_t * x);
730
736
737 ClassDef(URANIE::Modeler::TAnisp, ID_MODELER)
738
739};
740//end of the class TAnisp
741
742}//end of the namespace Modeler
743} //end of the namespace URANIE
744
746#endif
747
R__EXTERN URANIE::Modeler::TAnisp * gUranieTAnisp
Definition TAnisp.h:745
Interface of the class URANIE::Optimize::TModeler.
Interface of the class URANIE::Modeler::TNisp.
Interface of the class URANIE::Modeder::TPolynomialChaos.
Description of the class TAnisp.
Definition TAnisp.h:173
TString _soutput
Names of the output arguments.
Definition TAnisp.h:249
void setTPolynomialChaos()
Open the result file of the Anisp library and use the coefficients stored there to create a TPolynomi...
Int_t _nKMin
Order minimum of interaction for the adaptative integration.
Definition TAnisp.h:209
void exportModelFortran(std::ofstream *sourcefile) const
Export the model in Fortran langage in a file (not yet implemented)
Definition TAnisp.h:332
Int_t _nUranieAnisp
number of launching of the ANISP method
Definition TAnisp.h:263
Int_t _nNumberOfLaunching
Number of use of the launchCalculs method.
Definition TAnisp.h:243
friend void functionLauncher(vector< Double_t * > ptEXp)
Friend function which launchs the calculs.
void setMaxIndices(Int_t maxInd)
Set the number maximum of indices for the integration.
Int_t getMaxIndices()
Get the number maximum of indices for the integration.
Definition TAnisp.h:464
TPolynomialChaos getTPolynomialChaos()
Get the TPolynomialChaos computed by the Anisp method.
Int_t getIterationNumber()
Get the number of iteration of the integration algorithm.
Definition TAnisp.h:498
TString getStochasticFile() const
Get the stochastic points file name.
Definition TAnisp.h:585
Int_t getKMin()
Get the order of interaction for adaptative integration.
Definition TAnisp.h:403
TNtupleD * _tIntegrationIndices
List of integration indices.
Definition TAnisp.h:239
void runAnisp()
Run the Anisp method to compute a Polynomial Chaos expansion.
void exportModelCplusplus(std::ofstream *sourcefile) const
Export the model in C++ langage in a file.
Double_t getTolerance()
Get the tolerance for the adaptative integration.
Definition TAnisp.h:419
void setlog(Bool_t blog)
Set the _blog parameter.
Int_t getCible()
Get the ANISP_TYPE which indicates if ANISP approximate a code (TCode) or a function (void *)
Definition TAnisp.h:488
Int_t _ninputs
number of stochastic inputs
Definition TAnisp.h:261
void restartAnisp()
Restart the Anisp method to compute a Polynomial Chaos expansion from a previous calcul.
void(* _analyticalFunction)(Double_t *, Double_t *)
analytical function
Definition TAnisp.h:256
TString getVariablesName(TString inputs="")
Get a TString containing the name of all attributes separated by ':'.
TString _sLaws
Laws of probability for each variable.
Definition TAnisp.h:221
void setTolerance(Double_t tol)
Set the tolerance for the adaptative integration.
TString getRootFilename()
Get the root name of the output files of the Anisp library.
Definition TAnisp.h:519
TNisp * _nisp
Object of type TNisp.
Definition TAnisp.h:235
TNtupleD * getIntegrationIndices()
Get the list of integration indices.
Definition TAnisp.h:537
TDataServer * _tdsAnisp
Object of type TDataServer which contains all the launchs data.
Definition TAnisp.h:251
TString _sinput
Names of the input arguments.
Definition TAnisp.h:247
TString getErrorIndicatorFile() const
Get the error indicator values file name.
Definition TAnisp.h:594
void setDegreeMax(Int_t degMax)
Set the degree maximum for the Polynomial Chaos expansion.
void addErrorIndicator(Double_t *errInd)
Add an error indicator to _tErrorIndicator.
Definition TAnisp.h:688
virtual void printLog(Option_t *option="")
Print log.
TLauncher * _tlauncher
Object of type TLauncher.
Definition TAnisp.h:229
TString getDataAnispFile() const
Get the Anisp intern data file name.
Definition TAnisp.h:567
TString getIndicesFile() const
Get the integration indices file name.
Definition TAnisp.h:603
TLauncherFunction * _tAnalyticalFunction
Object of type TLauncherFunction.
Definition TAnisp.h:225
void addIntegrationIndices(Double_t *ind)
Add an error indicator to _tIntegrationIndices.
Definition TAnisp.h:700
TString _sFunctionName
name of the analytical function
Definition TAnisp.h:259
TString _sRootFilename
Root of the output files name.
Definition TAnisp.h:219
void setGreaterIndice(Int_t greatInd)
Set the greater value possible for an indice.
friend void StepByStepOutput(Double_t *val, vector< Int_t * > indices)
Friend function to pass to the anisp function.
void setNumberMaxOfSimulations(Int_t nmos)
Set the criterion of maximum number of simulations before stopping the adaptative integration.
Int_t _nNumberOfPoints
Number of computed points.
Definition TAnisp.h:245
ANISP_TYPE _nCible
Variable containing the ANISP_TYPE.
Definition TAnisp.h:231
void setAnispParameters(Double_t tol, Int_t kmin, Int_t nmos, Int_t greatInd, Int_t maxInd, Bool_t blog)
Set most of the Anisp parameters.
void launchCalculs(vector< Double_t * > ptExp)
Launch batchs of calculs during the numerical integration step of the ANISP method.
Int_t getDegreeMax()
Get the degree maximum for the Polynomial Chaos expansion.
Definition TAnisp.h:479
Int_t _nNumberMaxOfSimulations
Stop criterion of the adaptative integration algorithm based of the number of simulations.
Definition TAnisp.h:211
TAnisp(TDataServer *tds, const char *analyticalFunction, TString sinput="", TString soutput="", Option_t *option="")
Construct an instance of the TAnisp object from a TDataServer object and a void * (analytical functio...
void changeOfVariable(Double_t *x)
Do a changement of variable to change standart stochastic values into the problem uncertain values.
TAnisp(TDataServer *tds, TCode *code, Option_t *option="")
Construct an instance of the TAnisp object from a TDataServer object and a TCode object.
Double_t _dTolerance
Tolerance of the adaptative integration algorithm.
Definition TAnisp.h:207
Int_t _nIterationNumber
Number of iteration of adaptative integration algorithm.
Definition TAnisp.h:223
void setRootFilename(TString rootName)
Set the root name of the output files of the Anisp library.
void initialize()
Initialize attributes of the TAnisp object.
void exportModelPMML(const char *file="", const char *name="", Option_t *option="") const
Export the model in a PMML file (not yet implemented)
Definition TAnisp.h:345
void setLightAnispParameters(Double_t tol, Int_t kmin, Int_t nmos)
Set the Anisp calcul parameters.
TObjArray * _drawingGarbageCollector
Garbage collector list for drawing.
Definition TAnisp.h:205
Int_t _nMaxIndices
Number maximum of indices of integration (memory size)
Definition TAnisp.h:215
void EndIterationActions(Double_t *errIndicator, vector< Double_t * > integrationIndices)
Run at the end of an iteration of the integration algorithm and exploit the integration indices and e...
TPolynomialChaos * _tpc
Object of type TPolynomialChaos.
Definition TAnisp.h:233
ANISP_TYPE
Enum for TCode or analytical function.
Definition TAnisp.h:178
@ kCode
Definition TAnisp.h:179
@ kAnalyticalFunction
Definition TAnisp.h:179
Int_t _nGreaterIndice
Greater value possible for an indice.
Definition TAnisp.h:213
TNtupleD * getErrorIndicator()
Get the list of error indicators.
Definition TAnisp.h:528
virtual ~TAnisp()
Destructor.
TCode * _Code
Object of type TCode.
Definition TAnisp.h:227
Int_t _nDegreeMax
Degree maximum possible for the Polynomial Chaos expansion.
Definition TAnisp.h:217
void setAllAnispParameters(Double_t tol, Int_t kmin, Int_t nmos, Int_t greatInd, Int_t maxInd, Bool_t blog, Int_t degMax, TString rootName)
Set all the Anisp parameters.
void exportModelPython(std::ofstream *sourcefile) const
Export the model in Python langage in a file (not yet implemented)
Definition TAnisp.h:361
TAnisp(TDataServer *tds, void(*analyticalFunction)(Double_t *, Double_t *), const char *fname, TString sinput="", TString soutput="", Option_t *option="")
Construct an instance of the TAnisp object from a TDataServer object and a void * (analytical functio...
void setKMin(Int_t kmin)
Set the value of the _nKMin attribute to "kmin".
TString _sLaunchNumber
name of the TAttribute containing the number of launching
Definition TAnisp.h:265
TString getResultFile() const
Get the computed polynomial coefficients file name.
Definition TAnisp.h:576
Int_t getGreaterIndice()
Get the greater value possible for an indice.
Definition TAnisp.h:449
Int_t getNumberMaxOfSimulations()
Get the criterion of maximum number of simulations before stopping the adaptative integration.
Definition TAnisp.h:434
TNtupleD * _tErrorIndicator
List of error indicators from the integration algorithm.
Definition TAnisp.h:237
Definition TModeler.h:63
Description of the class TNisp.
Definition TNisp.h:62
Description of the class TPolynomialChaos.
Definition TPolynomialChaos.h:61
void functionLauncher(vector< Double_t * > ptEXp)
void StepByStepOutput(Double_t *val, vector< Int_t * > indices)
ROOT.
Definition TAnisp.h:164