English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Optimizer: TOptimizer.h Source File
Uranie / Optimizer  v4.10.0
/* @license-end */
TOptimizer.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/>.
18 // $Id$
19 // $Author$
20 // $Date$
21 // $Revision$
22 // $State$
24 
41 #ifndef TOPTIMIZER_H
42 #define TOPTIMIZER_H
43 
44 #include <iostream>
45 
46 //ROOT
47 #include "Rtypes.h"
48 #include "TNamed.h"
49 #include "TMethodCall.h"
50 
51 // Uranie
52 #include "Optimizer.h"
53 #include "TLauncherEnv.h"
54 #include "TCode.h"
55 #include "TDataServer.h"
56 #include "TObjective.h"
57 #include "TObjectiveUncertainty.h"
58 
59 namespace URANIE
60 {
61 namespace Optimizer
62 {
63 
64 class TOptimizer: public URANIE::Launcher::TLauncherEnv
65 {
66 public:
68  {
70  };
72  {
74  };
75 
76 private:
77  Bool_t _bsave;
78  Bool_t _bclean;
79  Int_t _nPrintLevel;
80  URANIE::DataServer::TDataServer *_tds;
83  Double_t _dTolerance;
84  vector<TObjective *> _objectives;
85  TMethodCall *_fMethodCall;
86 #ifdef ROOT5
87  void *_fMethod;
88 #else
89  void (*_fMethod)(Double_t*, Double_t*);
90 #endif
91  TString _sFunctionName;
94  TString _sInput;
95  TString _sOutput;
96  TString _sCost;
97 public:
98  //---------------------------------------------
102  TOptimizer(URANIE::DataServer::TDataServer *tds,
104  URANIE::Launcher::TCode *code);
106 #ifdef ROOT5
107  TOptimizer(URANIE::DataServer::TDataServer *tds, void* fcn, TString sinput =
108  "", TString soutput = "");
109 #else
110  TOptimizer(URANIE::DataServer::TDataServer *tds, void (*fcn)(Double_t*, Double_t*),
111  TString sinput, TString soutput);
112 #endif
113  TOptimizer(URANIE::DataServer::TDataServer *tds, const char* fcn, TString sinput =
115  "", TString soutput = "");
117  virtual ~TOptimizer();
119 
120  //---------------------------------------------
124  void setTolerance(Double_t dtol)
126  {
127  _dTolerance = dtol;
128  }
130  Double_t getTolerance()
131  {
132  return _dTolerance;
133  }
135  void setMaxIterations(Int_t nmax)
136  {
137  _nMaxIterations = nmax;
138  }
141  {
142  return _nMaxIterations;
143  }
145  void setMaxFunctionCalls(Int_t nmax)
146  {
147  _nMaxFunctionCalls = nmax;
148  }
151  {
152  return _nMaxFunctionCalls;
153  }
155 
156  //---------------------------------------------
165  void setMethod(EOptimMethod method = kMigrad)
167  {
168  _optimMethod = method;
169  }
172  {
173  return _optimMethod;
174  }
177  {
178  return _optimProblem;
179  }
181  void setPrintLevel(int level)
182  {
183  _nPrintLevel = level;
184  }
186  int getPrintLevel() const
187  {
188  return _nPrintLevel;
189  }
191 
192  //---------------------------------------------
196  virtual void init(Option_t *option = "");
199  virtual void optimize(Option_t *option = "");
201  virtual void terminate(Option_t *option = "");
203  virtual void clean(Option_t *option = "");
205 
206  //---------------------------------------------
216 
229  void addObjective(TString name, URANIE::DataServer::TDataServer *tds,
230  TString ystar, URANIE::Launcher::TOutputFile *outfile, TString yhat,
231  Double_t weight = 1.0);
233 
246  void addObjective(TString name, URANIE::DataServer::TDataServer *tds,
247  TString ystar, TString sigma,
248  URANIE::Launcher::TOutputFile *outfile, TString yhat,
249  Double_t alpha = 1.0);
251  void unactiveObjective(TString name);
253  void activeObjective(TString name);
255  void invertObjectives();
257  vector< URANIE::Optimizer::TObjective * > getObjectives()
258  {
259  return _objectives;
260  }
262 
267  void addOutputVariable(TString soutput);
269  void selectCost(TString scost);
271  TString getSelectedCost()
272  {
273  return _sCost;
274  }
276 
277  //---------------------------------------------
282  void fixParameter(TString name);
285 
288  void unfixParameter(TString name);
290 
293  void invertParameters();
295 
296  //---------------------------------------------
300  void printState(Option_t *option = "");
302 
303  virtual void printLog(Option_t *option = "");
305 
306  ClassDef(URANIE::Optimizer::TOptimizer, ID_OPTIMIZER)
307  //Classe de
308 };
309 
310 } // Fin du namespace Optimizer
311 } // Fin du namespace URANIE
312 #endif
Rosenbrock&#39;s function (n=2) with first and second order derivatives.
Definition: TBestEstimate.h:57
virtual void clean(Option_t *option="")
Cleans the working directory of the code.
void addObjective(TString name, URANIE::DataServer::TDataServer *tds, TString ystar, URANIE::Launcher::TOutputFile *outfile, TString yhat, Double_t weight=1.0)
Add the objective in the TOptimizer object : Sum of square of the error.
void unfixParameter(TString name)
Unfix the parameter given by these name.
EOptimType getOptimType()
Return the type of optimization.
Definition: TOptimizer.h:176
Int_t getMaxFunctionCalls()
Get the maximum numbers of evaluations.
Definition: TOptimizer.h:150
Int_t _nPrintLevel
The level of Debg between without test.
Definition: TOptimizer.h:79
void setMethod(EOptimMethod method=kMigrad)
Select the algorithm of optimization.
Definition: TOptimizer.h:166
void(* _fMethod)(Double_t *, Double_t *)
Definition: TOptimizer.h:89
Definition: TOptimizer.h:73
void printState(Option_t *option="")
Print the state of the algorithm of optimization.
TString _sCost
The name od the selected cost (the number must be equal to 1)
Definition: TOptimizer.h:96
void setTolerance(Double_t dtol)
Set the tolerance parameter.
Definition: TOptimizer.h:125
void activeObjective(TString name)
Active the objective given by these name.
Interface of class URANIE::Optimize::TObjectiveUncertainty.
void setMaxFunctionCalls(Int_t nmax)
Set the maximum number of evaluations.
Definition: TOptimizer.h:145
void setPrintLevel(int level)
Set the print Level of Debug between .
Definition: TOptimizer.h:181
EOptimMethod getMethod()
Return the algorithm of optimization.
Definition: TOptimizer.h:171
int getPrintLevel() const
Get the print Level of Debug between .
Definition: TOptimizer.h:186
Int_t _nMaxIterations
Pointer vers un TDS.
Definition: TOptimizer.h:81
EOptimType _optimProblem
Function name.
Definition: TOptimizer.h:92
EOptimMethod
Definition: TOptimizer.h:71
Double_t getTolerance()
Get the tolerance parameter.
Definition: TOptimizer.h:130
Definition: TOptimizer.h:73
void unactiveObjective(TString name)
Unactive the objective given by these name.
Description of the class TOptimizer.
Definition: TOptimizer.h:64
Double_t _dTolerance
The tolerance parameter.
Definition: TOptimizer.h:83
virtual ~TOptimizer()
Default destructor.
void fixParameter(TString name)
Fix the parameter given by these name to the default value.
virtual void init(Option_t *option="")
Init phase of the code.
URANIE::DataServer::TDataServer * _tds
Definition: TOptimizer.h:80
TString _sFunctionName
A pointer for the analytical function.
Definition: TOptimizer.h:91
TString getSelectedCost()
Get the selected Select an cost in the Output string.
Definition: TOptimizer.h:271
Interface of class URANIE::Optimize::TObjective.
Int_t getMaxIterations()
Get the maximum number of iterations.
Definition: TOptimizer.h:140
Definition: TOptimizer.h:73
void selectCost(TString scost)
Select an cost in the Output string.
virtual void optimize(Option_t *option="")
Runs phase of the code (TMinuit2)
TString _sOutput
The string of output attributes (the number must be equal to 1)
Definition: TOptimizer.h:95
Bool_t _bsave
Saves all the computation files in each directory.
Definition: TOptimizer.h:77
Definition: TOptimizer.h:73
void invertObjectives()
Invert the state of all the objectives.
void addOutputVariable(TString soutput)
Add input and output variables.
vector< TObjective * > _objectives
vector of objectives
Definition: TOptimizer.h:84
Bool_t _bclean
Cleans the Working Directory before running the code.
Definition: TOptimizer.h:78
void setMaxIterations(Int_t nmax)
Set the maximum number of iterations.
Definition: TOptimizer.h:135
void invertParameters()
Invert the state of all the parameters.
vector< URANIE::Optimizer::TObjective *> getObjectives()
get the vector containing the objectives
Definition: TOptimizer.h:257
EOptimMethod _optimMethod
The method of optimisation.
Definition: TOptimizer.h:93
Int_t _nMaxFunctionCalls
The max number to call the code/function.
Definition: TOptimizer.h:82
virtual void terminate(Option_t *option="")
Terminates phase of the code.
TMethodCall * _fMethodCall
Pointer to MethodCall in case of interpreted function.
Definition: TOptimizer.h:85
virtual void printLog(Option_t *option="")
TOptimizer(URANIE::DataServer::TDataServer *tds, URANIE::Launcher::TCode *code)
Constructor with a dataserver.
TString _sInput
The string of input attributes.
Definition: TOptimizer.h:94
EOptimType
Definition: TOptimizer.h:67