English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Optimizer: TFCNAnalyticalFunction.h Source File
Uranie / Optimizer v4.9.0
/* @license-end */
TFCNAnalyticalFunction.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
31#ifndef TFCNANALYTICALFUNCTION_H
32#define TFCNANALYTICALFUNCTION_H
33
34#include "Minuit2/FCNBase.h"
35//#include "TFitterMinuit.h"
36#include "TSystem.h"
37#include "TPad.h"
38#include "TFile.h"
39#include "TMethodCall.h"
40
41// URANIE
42#include "Optimizer.h"
43#include "TDataServer.h"
44
45namespace URANIE
46{
47namespace Optimizer
48{
49class TFCNAnalyticalFunction: public ROOT::Minuit2::FCNBase
50{
51
52public:
54 _blog(kFALSE), _ninput(0), _sinput(""), _noutput(0), _soutput(""), _sCost(""),
55 _tds(NULL), _fMethod(NULL)
56
57 {
58 }
60 TFCNAnalyticalFunction(URANIE::DataServer::TDataServer *tds, void * fcn,
61 TString sinput, TString soutput, TString scost);
63 TFCNAnalyticalFunction(URANIE::DataServer::TDataServer *tds,
64 TString sfunction, TString sinput, TString soutput);
65
68
69 void init();
70
71 //---------------------------------------------
75
76 TMethodCall *getMethodCall() const
77 {
78 return _fMethodCall;
79 }
81
82 double operator()(const vector<double> & par) const
83 {
84 Int_t niter = _tds->getTuple()->GetEntries();
85 if (_blog)
86 cout << " ** niter[" << niter << "]" << endl;
87 double fval = par[1];
88 _dinputValue[0] = 1.0 + niter;
89 for (int i = 0; i < _ninput; i++)
90 {
91 _dinputValue[1 + i] = par[i];
92 if (_blog)
93 cout << "**** input i[" << i << "] val[" << _dinputValue[1 + i]
94 << "]" << endl;
95 }
96 _dinputValue[_ninput + 1] = fval;
97 if (_fMethod != NULL)
98 {
99 //int ind = 1;
100 (*_fMethod)(&_dinputValue[1], _doutputValue);
101 // fval = _doutputValue[0];
102 fval = _doutputValue[_nCost];
103 if (_blog)
104 cout << "*********** output val[" << fval << "]" << endl;
105 }
106 //Fill the output values in the input vector
107 for (int i = 0; i < _noutput; i++)
108 _dinputValue[_ninput + i + 1] = _doutputValue[i];
109 // _dinputValue[_ninput+1] = fval;
110 _tds->getTuple()->Fill(_dinputValue);
111 if (niter % 10)
112 {
113 // _ntd->Draw("val:x", "", "lp");
114 _tds->draw(Form("%s:%s", _sCost.Data(), _tds->getIteratorName()),
115 "", "lp");
116 gPad->Modified();
117 gPad->Update();
118 // save the TNtuple in a TFile
119 TFile *tf = TFile::Open(_tds->getArchiveFileName(), "RECREATE");
120 _tds->getTuple()->SetDirectory(0);
121 _tds->getTuple()->Write();
122 tf->Close();
123 _tds->getTuple()->SetDirectory(gDirectory);
124 }
125 return fval;
126 }
127
128 double Up() const
129 {
130 return 1.;
131 }
132
133 void clean();
134
135private:
136 Bool_t _blog;
138 TString _sinput;
139 double * _dinputValue;
141 TString _soutput;
142 double * _doutputValue;
143 TString _sCost;
144 Int_t _nCost;
145 URANIE::DataServer::TDataServer *_tds;
146 void (*_fMethod)(Double_t *gin, Double_t *f); // A pointer for the analytical function
147 TMethodCall *_fMethodCall;
148
149 ClassDef(URANIE::Optimizer::TFCNAnalyticalFunction, ID_OPTIMIZER)
150 //Classe de
151
152};
153} // Fin du namespace Optimizer
154} // Fin du namespace URANIE
155
157
158#endif
R__EXTERN URANIE::Optimizer::TFCNAnalyticalFunction * gTFCNAF
Definition TFCNAnalyticalFunction.h:156
Definition TFCNAnalyticalFunction.h:50
double * _dinputValue
Definition TFCNAnalyticalFunction.h:139
int _ninput
Definition TFCNAnalyticalFunction.h:137
Int_t _nCost
the current position for the selected cost in the output list of attribute
Definition TFCNAnalyticalFunction.h:144
double operator()(const vector< double > &par) const
Definition TFCNAnalyticalFunction.h:82
TFCNAnalyticalFunction(URANIE::DataServer::TDataServer *tds, TString sfunction, TString sinput, TString soutput)
Constructor with a dataserver.
Bool_t _blog
Boolean for edit the log.
Definition TFCNAnalyticalFunction.h:136
URANIE::DataServer::TDataServer * _tds
Definition TFCNAnalyticalFunction.h:145
double * _doutputValue
The output attribute name.
Definition TFCNAnalyticalFunction.h:142
TString _sCost
The name of the selected cost (the number must be equal to 1)
Definition TFCNAnalyticalFunction.h:143
TFCNAnalyticalFunction()
Definition TFCNAnalyticalFunction.h:53
TMethodCall * _fMethodCall
Pointer to MethodCall in case of interpreted function.
Definition TFCNAnalyticalFunction.h:147
double Up() const
Definition TFCNAnalyticalFunction.h:128
TFCNAnalyticalFunction(URANIE::DataServer::TDataServer *tds, void *fcn, TString sinput, TString soutput, TString scost)
Constructor with a dataserver.
TString _soutput
Name of the output attributes.
Definition TFCNAnalyticalFunction.h:141
int _noutput
Definition TFCNAnalyticalFunction.h:140
void(* _fMethod)(Double_t *gin, Double_t *f)
Pointeur vers un TDS.
Definition TFCNAnalyticalFunction.h:146
TString _sinput
Name of the input attributes.
Definition TFCNAnalyticalFunction.h:138
TMethodCall * getMethodCall() const
Return the pointer to the TmethodCall attribut.
Definition TFCNAnalyticalFunction.h:76
Rosenbrock's function (n=2) with first and second order derivatives.
Definition TBestEstimate.h:58