Skip to content
Snippets Groups Projects
Commit 006a9d22 authored by BaM's avatar BaM
Browse files

Add Bam name where it belong..

update XS_MLP model to improve MLP performance, 
Some bug correction on other Equivalence MLP model

git-svn-id: svn+ssh://svn.in2p3.fr/class@798 0e7d625b-0364-4367-a6be-d5be4a48d228
parent b3dfed2d
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ using namespace std;
@f$\alpha_{i} = \bar{\nu_{i}}\cdot\sigma_{i}^{fis} - \sigma_{i}^{abs}@f$
@author BLG
@author BaM
@version 3.0
*/
//________________________________________________________________________
......
......@@ -35,7 +35,9 @@ EQM_MLP_Kinf::EQM_MLP_Kinf(string WeightPathAlpha0, string WeightPathAlpha1, str
fInformationFile = InformationFile;
LoadKeyword();
ReadNFO();//Getting information from fInformationFile
InitialiseTMVAReader();
fNumberOfBatch = NumOfBatch;
fKThreshold = CriticalityThreshold ;
SetBurnUpPrecision(0.005);//1 % of the targeted burnup
......@@ -274,7 +276,7 @@ void EQM_MLP_Kinf::InitialiseTMVAReader()
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
vector<float> InputTMVA;
InputTMVA;
for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++)
InputTMVA.push_back(0);
Float_t Time;
......@@ -300,6 +302,9 @@ void EQM_MLP_Kinf::UpdateInputComposition(IsotopicVector TheFreshfuel, double Th
IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA);
double Ntot = IVAccordingToUserInfoFile.GetSumOfAll();
IVAccordingToUserInfoFile *= 1/Ntot;
map<ZAI,string>::iterator it;
int j = 0;
......
......@@ -32,7 +32,8 @@ Where @f$k_{Threshold}@f$ is the criticality threshold which take into account l
in non simulated devices such as control rods and mixing grid.
@author BLG
@version 1.0
@author BaM
@version 1.0
*/
//________________________________________________________________________
......
......@@ -15,6 +15,7 @@ using namespace std;
based on a Multi layer perceptron
@author BLG
@author BaM
@version 3.0
*/
//________________________________________________________________________
......
......@@ -16,6 +16,7 @@ using namespace std;
based on a Multi layer perceptron
@author BLG
@author BaM
@version 3.0
*/
//________________________________________________________________________
......
......@@ -5,7 +5,6 @@
#include "CLASSMethod.hxx"
#include "StringLine.hxx"
#include "TMVA/Reader.h"
#include "TMVA/Tools.h"
#include "TMVA/MethodCuts.h"
......@@ -49,7 +48,9 @@ XSM_MLP::XSM_MLP(string TMVA_Weight_Directory,string InformationFile, bool IsTim
LoadKeyword();
ReadNFO();
InitialiseTMVAReader();
}
//________________________________________________________________________
......@@ -69,7 +70,9 @@ XSM_MLP::XSM_MLP(CLASSLogger* Log,string TMVA_Weight_Directory,string Informatio
LoadKeyword();
ReadNFO();
InitialiseTMVAReader();
}
//________________________________________________________________________
......@@ -227,76 +230,62 @@ void XSM_MLP::ReadWeightFile(string Filename, int &Z, int &A, int &I, int &React
}
//________________________________________________________________________
TTree* XSM_MLP::CreateTMVAInputTree(IsotopicVector isotopicvector,int TimeStep)
void XSM_MLP::UpdateInputComposition(IsotopicVector TheFreshfuel,int TimeStep)
{
/******Create Input data tree to be interpreted by TMVA::Reader***/
TTree* InputTree = new TTree("InTMP", "InTMP");
vector<float> InputTMVA;
for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++)
InputTMVA.push_back(0);
float Time = 0;
IsotopicVector IVInputTMVA;
map<ZAI ,string >::iterator it;
int j = 0;
for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++)
{
InputTree->Branch( ((*it).second).c_str() ,&InputTMVA[j], ((*it).second + "/F").c_str());
IVInputTMVA+= ((*it).first)*1;
j++;
}
if( !fIsStepTime)
InputTree->Branch( "Time" ,&Time ,"Time/F" );
IsotopicVector IVAccordingToUserInfoFile = isotopicvector.GetThisComposition(IVInputTMVA);
double Ntot = IVAccordingToUserInfoFile.GetSumOfAll();
IVAccordingToUserInfoFile = IVAccordingToUserInfoFile/Ntot;
IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA);
double Ntot = IVAccordingToUserInfoFile.GetSumOfAll();
IVAccordingToUserInfoFile *= 1/Ntot;
j = 0;
DBGV("INPUT TMVA");
int j = 0;
map<ZAI ,string >::iterator it2;
DBGV("INPUT TMVA");
for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++)
{
InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it2).first ) ;
InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it2).first );
DBGV((*it2).first.Z() << " " << (*it2).first.A() << " " << InputTMVA[j]);
j++;
}
Time = fMLP_Time[TimeStep];
InputTree->Fill();
return InputTree;
}
void XSM_MLP::InitialiseTMVAReader()
{
reader = new TMVA::Reader( "Silent" );
for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++)
InputTMVA.push_back(0);
for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++)
InputTMVA.push_back(0);
map<ZAI ,string >::iterator it;
int j = 0;
for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++)
{ reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]);
j++;
}
if(!fIsStepTime)
reader->AddVariable( "Time" ,&Time);
}
//________________________________________________________________________
double XSM_MLP::ExecuteTMVA(string WeightFile,TTree* InputTree)
double XSM_MLP::ExecuteTMVA(string WeightFile, IsotopicVector isotopicvector, int TimeStep)
{
DBGV( "File :" << WeightFile);
// --- Create the Reader object
TMVA::Reader *reader = new TMVA::Reader( "Silent" );
// Create a set of variables and declare them to the reader
// - the variable names MUST corresponds in name and type to those given in the weight file(s) used
vector<float> InputTMVA;
for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++)
InputTMVA.push_back(0);
Float_t Time;
map<ZAI ,string >::iterator it;
int j = 0;
for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++)
{ reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]);
j++;
}
if(!fIsStepTime)
reader->AddVariable( "Time" ,&Time);
UpdateInputComposition(isotopicvector, TimeStep);
DBGV( "File :" << WeightFile);
// --- Book the MVA methods
string dir = fTMVAWeightFolder;
......@@ -307,22 +296,9 @@ double XSM_MLP::ExecuteTMVA(string WeightFile,TTree* InputTree)
TString methodName = "MLP method";
TString weightpath = dir + WeightFile ;
reader->BookMVA( methodName, weightpath );
float val = (reader->EvaluateRegression( methodName ))[0];
map<ZAI ,string >::iterator it2;
j = 0;
for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++)
{
InputTree->SetBranchAddress(( (*it2).second ).c_str(),&InputTMVA[j]);
j++;
}
if(!fIsStepTime)
InputTree->SetBranchAddress( "Time" ,&Time );
InputTree->GetEntry(0);
Float_t val = (reader->EvaluateRegression( methodName ))[0];
delete reader;
DBGL
return (double)val;
......@@ -348,29 +324,22 @@ EvolutionData XSM_MLP::GetCrossSectionsTime(IsotopicVector IV)
int I = -2;
int Reaction = -2;
ReadWeightFile( fWeightFiles[i], Z, A, I, Reaction);
if( Z >= GetZAIThreshold() )
{
for(int TimeStep = 0;TimeStep<int(fMLP_Time.size());TimeStep++)
TGraph* ZAIXSTGraph = new TGraph();
for(int TimeStep = 0; TimeStep < int(fMLP_Time.size()) ; TimeStep++)
{
TTree* InputTree = CreateTMVAInputTree(IV,TimeStep);
pair< map<ZAI, TGraph*>::iterator, bool> IResult;
IResult = ExtrapolatedXS[Reaction].insert( pair<ZAI ,TGraph* >(ZAI(Z,A,I), new TGraph()) );
double XSValue = ExecuteTMVA(fWeightFiles[i],InputTree );
if(IResult.second )
{
(IResult.first)->second->SetPoint(0, (double)fMLP_Time[TimeStep], XSValue );
}
else
{
(IResult.first)->second->SetPoint( (IResult.first)->second->GetN(), (double)fMLP_Time[TimeStep], XSValue );
}
delete InputTree;
}
double XSValue = ExecuteTMVA(fWeightFiles[i], IV, TimeStep );
ZAIXSTGraph->SetPoint( ZAIXSTGraph->GetN(), (double)fMLP_Time[TimeStep], XSValue );
}
pair< map<ZAI, TGraph*>::iterator, bool> IResult;
IResult = ExtrapolatedXS[Reaction].insert( pair<ZAI ,TGraph* >(ZAI(Z,A,I), ZAIXSTGraph) );
}
}
......@@ -436,8 +405,7 @@ void XSM_MLP::ReadWeightFileStep(string Filename, int &Z, int &A, int &I, int &R
EvolutionData XSM_MLP::GetCrossSectionsStep(IsotopicVector IV)
{
DBGL
TTree* InputTree = CreateTMVAInputTree(IV);
EvolutionData EvolutionDataFromMLP = EvolutionData();
map<ZAI,TGraph*> ExtrapolatedXS[3];
......@@ -467,11 +435,11 @@ EvolutionData XSM_MLP::GetCrossSectionsStep(IsotopicVector IV)
if( IResult.second )
{
(IResult.first)->second->SetPoint(0, (double)fMLP_Time[TimeStep], ExecuteTMVA(fWeightFiles[i],InputTree) );
(IResult.first)->second->SetPoint(0, (double)fMLP_Time[TimeStep], ExecuteTMVA(fWeightFiles[i],IV) );
}
else
{
(IResult.first)->second->SetPoint( (IResult.first)->second->GetN(), (double)fMLP_Time[TimeStep], ExecuteTMVA(fWeightFiles[i],InputTree) );
(IResult.first)->second->SetPoint( (IResult.first)->second->GetN(), (double)fMLP_Time[TimeStep], ExecuteTMVA(fWeightFiles[i],IV) );
}
}
}
......@@ -487,7 +455,6 @@ EvolutionData XSM_MLP::GetCrossSectionsStep(IsotopicVector IV)
EvolutionDataFromMLP.SetCaptureXS(ExtrapolatedXS[1]);
EvolutionDataFromMLP.Setn2nXS(ExtrapolatedXS[2]);
delete InputTree;
DBGL
return EvolutionDataFromMLP;
}
......
......@@ -13,7 +13,11 @@
@version 1.0
*/
#include "XSModel.hxx"
#include "TTree.h"
#include "TMVA/Reader.h"
#include <string>
#include <fstream>
#include <iostream>
......@@ -38,6 +42,7 @@ typedef void (XSM_MLP::*XS_MLP_DMthPtr)( const string & ) ;
set of Multi Layer Perceptrons (MLP)
@authors BLG
@authors BaM
@version 1.0
*/
//________________________________________________________________________
......@@ -127,9 +132,10 @@ class XSM_MLP : public XSModel
void ReadWeightFileStep(string Filename, int &Z, int &A, int &I, int &Reaction, int &TimeStep);; //!< Select the reaction according to the weight file name
double ExecuteTMVA(string WeightFile, TTree* InputTree); //!<Execute the MLP according to the input tree created
TTree* CreateTMVAInputTree(IsotopicVector isotopicvector,int TimeStep = 0); //!<Create input tmva tree to be read by ExecuteTMVA
void InitialiseTMVAReader();
double ExecuteTMVA(string WeightFile, IsotopicVector isotopicvector, int TimeStep = 0); //!<Execute the MLP according to the input tree created
void UpdateInputComposition(IsotopicVector TheFreshfuel,int TimeStep = 0); //!<Create input tmva tree to be read by ExecuteTMVA
vector<double> fMLP_Time; //!< Time vector of the data base
......@@ -141,7 +147,12 @@ class XSM_MLP : public XSModel
bool fIsStepTime; //!< true if one TMVA weihgt per step time is requiered otherwise it assumes time is part of the MLP inputs
map<ZAI,string> fMapOfTMVAVariableNames;//!< List of TMVA input variable names (read from fMLPInformationFile ) , name depends on the training step
TMVA::Reader *reader;
vector<float> InputTMVA;
IsotopicVector IVInputTMVA;
float Time;
#ifndef __CINT__
map<string, XS_MLP_DMthPtr> fDKeyword;
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment