English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Modeler: TAnisp.h Source File
Uranie / Modeler  v4.10.0
/* @license-end */
TAnisp.h
Go to the documentation of this file.
1 // 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 
159 using namespace URANIE::DataServer;
160 using namespace URANIE::Exceptions;
161 using namespace URANIE::Launcher;
162 
163 namespace URANIE
164 {
165 namespace Modeler
166 {
167 
168 void StepByStepOutput(Double_t * val, vector<Int_t *> indices);
169 
170 void functionLauncher(vector<Double_t *> ptEXp);
171 
172 class TAnisp: public TModeler
173 {
175 public:
178  {
179  kAnalyticalFunction, kCode
180  };
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 
203 private:
207  Double_t _dTolerance;
209  Int_t _nKMin;
217  Int_t _nDegreeMax;
219  TString _sRootFilename;
221  TString _sLaws;
225  TLauncherFunction * _tAnalyticalFunction;
227  TCode * _Code;
229  TLauncher * _tlauncher;
237  TNtupleD * _tErrorIndicator;
240  /* //! Canvas for graphical outputs */
241  /* TCanvas * _myCanvas; */
247  TString _sinput;
249  TString _soutput;
251  TDataServer* _tdsAnisp;
253 #ifdef ROOT5
254  void* _analyticalFunction;
255 #else
256  void (*_analyticalFunction)(Double_t*, Double_t*);
257 #endif
258  TString _sFunctionName;
261  Int_t _ninputs;
265  TString _sLaunchNumber;
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 
271 public:
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
291 
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 
428  void setNumberMaxOfSimulations(Int_t nmos);
429 
435  {
436  return _nNumberMaxOfSimulations;
437  }
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 
479  Int_t getDegreeMax()
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 
519  TString getRootFilename()
520  {
521  return _sRootFilename;
522  }
523 
528  TNtupleD* getErrorIndicator()
529  {
530  return _tErrorIndicator;
531  }
532 
538  {
539  return _tIntegrationIndices;
540  }
541 
546  TPolynomialChaos getTPolynomialChaos();
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 
668  void restartAnisp();
669 
671 
672 private:
676  void initialize();
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 
735  void setTPolynomialChaos();
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 
ROOT.
Definition: TAnisp.h:163
TString _sinput
Names of the input arguments.
Definition: TAnisp.h:247
Interface of the class URANIE::Modeler::TNisp.
Int_t _nUranieAnisp
number of launching of the ANISP method
Definition: TAnisp.h:263
TPolynomialChaos * _tpc
Object of type TPolynomialChaos.
Definition: TAnisp.h:233
Int_t _nNumberMaxOfSimulations
Stop criterion of the adaptative integration algorithm based of the number of simulations.
Definition: TAnisp.h:211
Description of the class TNisp.
Definition: TNisp.h:61
ANISP_TYPE _nCible
Variable containing the ANISP_TYPE.
Definition: TAnisp.h:231
void addErrorIndicator(Double_t *errInd)
Add an error indicator to _tErrorIndicator.
Definition: TAnisp.h:688
TNtupleD * _tIntegrationIndices
List of integration indices.
Definition: TAnisp.h:239
TObjArray * _drawingGarbageCollector
Garbage collector list for drawing.
Definition: TAnisp.h:205
Definition: TModeler.h:62
TLauncherFunction * _tAnalyticalFunction
Object of type TLauncherFunction.
Definition: TAnisp.h:225
Interface of the class URANIE::Modeder::TPolynomialChaos.
Int_t _nIterationNumber
Number of iteration of adaptative integration algorithm.
Definition: TAnisp.h:223
Int_t getKMin()
Get the order of interaction for adaptative integration.
Definition: TAnisp.h:403
R__EXTERN URANIE::Modeler::TAnisp * gUranieTAnisp
Definition: TAnisp.h:745
Interface of the class URANIE::Optimize::TModeler.
TString _soutput
Names of the output arguments.
Definition: TAnisp.h:249
void addIntegrationIndices(Double_t *ind)
Add an error indicator to _tIntegrationIndices.
Definition: TAnisp.h:700
TString getErrorIndicatorFile() const
Get the error indicator values file name.
Definition: TAnisp.h:594
void exportModelFortran(std::ofstream *sourcefile) const
Export the model in Fortran langage in a file (not yet implemented)
Definition: TAnisp.h:332
TNtupleD * getErrorIndicator()
Get the list of error indicators.
Definition: TAnisp.h:528
Int_t getDegreeMax()
Get the degree maximum for the Polynomial Chaos expansion.
Definition: TAnisp.h:479
TString getIndicesFile() const
Get the integration indices file name.
Definition: TAnisp.h:603
void functionLauncher(vector< Double_t *> ptEXp)
Description of the class TPolynomialChaos.
Definition: TPolynomialChaos.h:60
Description of the class TAnisp.
Definition: TAnisp.h:172
TLauncher * _tlauncher
Object of type TLauncher.
Definition: TAnisp.h:229
Int_t getIterationNumber()
Get the number of iteration of the integration algorithm.
Definition: TAnisp.h:498
TString _sRootFilename
Root of the output files name.
Definition: TAnisp.h:219
void StepByStepOutput(Double_t *val, vector< Int_t *> indices)
Int_t _nNumberOfPoints
Number of computed points.
Definition: TAnisp.h:245
TString getRootFilename()
Get the root name of the output files of the Anisp library.
Definition: TAnisp.h:519
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
Int_t _nGreaterIndice
Greater value possible for an indice.
Definition: TAnisp.h:213
Double_t getTolerance()
Get the tolerance for the adaptative integration.
Definition: TAnisp.h:419
TString getStochasticFile() const
Get the stochastic points file name.
Definition: TAnisp.h:585
ANISP_TYPE
Enum for TCode or analytical function.
Definition: TAnisp.h:177
Double_t _dTolerance
Tolerance of the adaptative integration algorithm.
Definition: TAnisp.h:207
TString getDataAnispFile() const
Get the Anisp intern data file name.
Definition: TAnisp.h:567
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
Int_t _nNumberOfLaunching
Number of use of the launchCalculs method.
Definition: TAnisp.h:243
Int_t _ninputs
number of stochastic inputs
Definition: TAnisp.h:261
Int_t _nDegreeMax
Degree maximum possible for the Polynomial Chaos expansion.
Definition: TAnisp.h:217
Int_t getCible()
Get the ANISP_TYPE which indicates if ANISP approximate a code (TCode) or a function (void *) ...
Definition: TAnisp.h:488
TCode * _Code
Object of type TCode.
Definition: TAnisp.h:227
TNisp * _nisp
Object of type TNisp.
Definition: TAnisp.h:235
void exportModelPython(std::ofstream *sourcefile) const
Export the model in Python langage in a file (not yet implemented)
Definition: TAnisp.h:361
Int_t _nMaxIndices
Number maximum of indices of integration (memory size)
Definition: TAnisp.h:215
Int_t getMaxIndices()
Get the number maximum of indices for the integration.
Definition: TAnisp.h:464
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
TString _sLaws
Laws of probability for each variable.
Definition: TAnisp.h:221
TString _sLaunchNumber
name of the TAttribute containing the number of launching
Definition: TAnisp.h:265
Int_t _nKMin
Order minimum of interaction for the adaptative integration.
Definition: TAnisp.h:209
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