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.9.0
/* @license-end */
TOptimizer.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
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 "TCode.h"
54#include "TDataServer.h"
55#include "TObjective.h"
57
58namespace URANIE
59{
60namespace Optimizer
61{
62class TOptimizer: public TNamed
63{
64public:
73
74private:
75 TString _sdirectory;
76 Bool_t _bsave;
77 Bool_t _bclean;
78 Bool_t _blog;
80 URANIE::DataServer::TDataServer *_tds;
81 URANIE::Launcher::TCode *_code;
84 Double_t _dTolerance;
85 vector<TObjective *> _objectives;
86 TMethodCall *_fMethodCall;
87#ifdef ROOT5
88 void *_fMethod;
89#else
90 void (*_fMethod)(Double_t*, Double_t*);
91#endif
95 TString _sInput;
96 TString _sOutput;
97 TString _sCost;
98public:
99 //---------------------------------------------
103
104 TOptimizer(URANIE::DataServer::TDataServer *tds,
105 URANIE::Launcher::TCode *code);
107#ifdef ROOT5
108 TOptimizer(URANIE::DataServer::TDataServer *tds, void* fcn, TString sinput =
109 "", TString soutput = "");
110#else
111 TOptimizer(URANIE::DataServer::TDataServer *tds, void (*fcn)(Double_t*, Double_t*),
112 TString sinput, TString soutput);
113#endif
115 TOptimizer(URANIE::DataServer::TDataServer *tds, const char* fcn, TString sinput =
116 "", TString soutput = "");
118 virtual ~TOptimizer();
120
121 //---------------------------------------------
125
126 void setTolerance(Double_t dtol)
127 {
128 _dTolerance = dtol;
129 }
131 Double_t getTolerance()
132 {
133 return _dTolerance;
134 }
136 void setMaxIterations(Int_t nmax)
137 {
138 _nMaxIterations = nmax;
139 }
142 {
143 return _nMaxIterations;
144 }
146 void setMaxFunctionCalls(Int_t nmax)
147 {
148 _nMaxFunctionCalls = nmax;
149 }
152 {
153 return _nMaxFunctionCalls;
154 }
156
157 //---------------------------------------------
166
168 {
169 _optimMethod = method;
170 }
173 {
174 return _optimMethod;
175 }
178 {
179 return _optimProblem;
180 }
182 void setPrintLevel(int level)
183 {
184 _nPrintLevel = level;
185 }
187 int getPrintLevel() const
188 {
189 return _nPrintLevel;
190 }
192
193 //---------------------------------------------
197
198 virtual void init(Option_t *option = "");
200 virtual void optimize(Option_t *option = "");
202 virtual void terminate(Option_t *option = "");
204 virtual void clean(Option_t *option = "");
206
207 //---------------------------------------------
217
230 void addObjective(TString name, URANIE::DataServer::TDataServer *tds,
231 TString ystar, URANIE::Launcher::TOutputFile *outfile, TString yhat,
232 Double_t weight = 1.0);
234
247 void addObjective(TString name, URANIE::DataServer::TDataServer *tds,
248 TString ystar, TString sigma,
249 URANIE::Launcher::TOutputFile *outfile, TString yhat,
250 Double_t alpha = 1.0);
252 void unactiveObjective(TString name);
254 void activeObjective(TString name);
258 vector< URANIE::Optimizer::TObjective * > getObjectives()
259 {
260 return _objectives;
261 }
263
268 void addOutputVariable(TString soutput);
270 void selectCost(TString scost);
273 {
274 return _sCost;
275 }
277
278 //---------------------------------------------
283
284 void fixParameter(TString name);
286
289 void unfixParameter(TString name);
291
296
297 //---------------------------------------------
301
302 void printState(Option_t *option = "");
303 void setLog()
304 {
305 _blog = kTRUE;
306 }
307 void unsetLog()
308 {
309 _blog = kFALSE;
310 }
312 {
313 _blog = _blog ? kFALSE : kTRUE;
314 }
315 Bool_t getLog()
316 {
317 return _blog;
318 }
319 virtual void printLog(Option_t *option = "");
321
322 ClassDef(URANIE::Optimizer::TOptimizer, ID_OPTIMIZER)
323 //Classe de
324};
325
326} // Fin du namespace Optimizer
327} // Fin du namespace URANIE
328#endif
Interface of class URANIE::Optimize::TObjectiveUncertainty.
Interface of class URANIE::Optimize::TObjective.
Description of the class TOptimizer.
Definition TOptimizer.h:63
vector< URANIE::Optimizer::TObjective * > getObjectives()
get the vector containing the objectives
Definition TOptimizer.h:258
void printState(Option_t *option="")
Print the state of the algorithm of optimization.
Bool_t _bsave
Saves all the computation files in each directory.
Definition TOptimizer.h:76
Int_t _nPrintLevel
The level of Debg between without test.
Definition TOptimizer.h:79
virtual void optimize(Option_t *option="")
Runs phase of the code (TMinuit2)
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.
Bool_t _blog
Boolean to edit the log.
Definition TOptimizer.h:78
Bool_t getLog()
Definition TOptimizer.h:315
Double_t _dTolerance
The tolerance parameter.
Definition TOptimizer.h:84
URANIE::Launcher::TCode * _code
Pointer vers un TDS.
Definition TOptimizer.h:81
EOptimType getOptimType()
Return the type of optimization.
Definition TOptimizer.h:177
TString _sdirectory
Current directory.
Definition TOptimizer.h:75
void invertParameters()
Invert the state of all the parameters.
TString getSelectedCost()
Get the selected Select an cost in the Output string.
Definition TOptimizer.h:272
Int_t _nMaxFunctionCalls
The max number to call the code/function.
Definition TOptimizer.h:83
EOptimMethod _optimMethod
The method of optimisation.
Definition TOptimizer.h:94
EOptimType _optimProblem
Function name.
Definition TOptimizer.h:93
void(* _fMethod)(Double_t *, Double_t *)
Definition TOptimizer.h:90
void addObjective(TString name, URANIE::DataServer::TDataServer *tds, TString ystar, TString sigma, URANIE::Launcher::TOutputFile *outfile, TString yhat, Double_t alpha=1.0)
Add the objective in the TOptimizer object : Sum of square of the weighted error.
vector< TObjective * > _objectives
vector of objectives
Definition TOptimizer.h:85
void addOutputVariable(TString soutput)
Add input and output variables.
void changeLog()
Definition TOptimizer.h:311
Int_t getMaxIterations()
Get the maximum number of iterations.
Definition TOptimizer.h:141
Bool_t _bclean
Cleans the Working Directory before running the code.
Definition TOptimizer.h:77
TOptimizer(URANIE::DataServer::TDataServer *tds, URANIE::Launcher::TCode *code)
Constructor with a dataserver.
void setMaxIterations(Int_t nmax)
Set the maximum number of iterations.
Definition TOptimizer.h:136
TString _sCost
The name od the selected cost (the number must be equal to 1)
Definition TOptimizer.h:97
void setTolerance(Double_t dtol)
Set the tolerance parameter.
Definition TOptimizer.h:126
virtual void init(Option_t *option="")
Init phase of the code.
void fixParameter(TString name)
Fix the parameter given by these name to the default value.
TOptimizer(URANIE::DataServer::TDataServer *tds, const char *fcn, TString sinput="", TString soutput="")
Constructor by a TDataServer, a function name and list of input and output (optional)
EOptimType
Definition TOptimizer.h:66
@ kSumOfSquare
Definition TOptimizer.h:67
@ kMinimizeFunction
Definition TOptimizer.h:67
@ kMinimizeCode
Definition TOptimizer.h:67
virtual void terminate(Option_t *option="")
Terminates phase of the code.
void activeObjective(TString name)
Active the objective given by these name.
void unactiveObjective(TString name)
Unactive the objective given by these name.
TString _sInput
The string of input attributes.
Definition TOptimizer.h:95
virtual void printLog(Option_t *option="")
void unsetLog()
Definition TOptimizer.h:307
void unfixParameter(TString name)
Unfix the parameter given by these name.
TString _sFunctionName
A pointer for the analytical function.
Definition TOptimizer.h:92
Int_t getMaxFunctionCalls()
Get the maximum numbers of evaluations.
Definition TOptimizer.h:151
EOptimMethod getMethod()
Return the algorithm of optimization.
Definition TOptimizer.h:172
void setLog()
Definition TOptimizer.h:303
void setMaxFunctionCalls(Int_t nmax)
Set the maximum number of evaluations.
Definition TOptimizer.h:146
void invertObjectives()
Invert the state of all the objectives.
void setMethod(EOptimMethod method=kMigrad)
Select the algorithm of optimization.
Definition TOptimizer.h:167
URANIE::DataServer::TDataServer * _tds
Definition TOptimizer.h:80
EOptimMethod
Definition TOptimizer.h:70
@ kMigrad
Definition TOptimizer.h:71
@ kCombined
Definition TOptimizer.h:71
@ kSimplex
Definition TOptimizer.h:71
@ kScan
Definition TOptimizer.h:71
Int_t _nMaxIterations
Pointer vers un TCode.
Definition TOptimizer.h:82
TOptimizer(URANIE::DataServer::TDataServer *tds, void(*fcn)(Double_t *, Double_t *), TString sinput, TString soutput)
Constructor by a TDataServer, a function and list of input and output (optional)
TString _sOutput
The string of output attributes (the number must be equal to 1)
Definition TOptimizer.h:96
int getPrintLevel() const
Get the print Level of Debug between .
Definition TOptimizer.h:187
virtual ~TOptimizer()
Default destructor.
void selectCost(TString scost)
Select an cost in the Output string.
void setPrintLevel(int level)
Set the print Level of Debug between .
Definition TOptimizer.h:182
virtual void clean(Option_t *option="")
Cleans the working directory of the code.
TMethodCall * _fMethodCall
Pointer to MethodCall in case of interpreted function.
Definition TOptimizer.h:86
Double_t getTolerance()
Get the tolerance parameter.
Definition TOptimizer.h:131
Rosenbrock's function (n=2) with first and second order derivatives.
Definition TBestEstimate.h:58