Documentation / User's manual in C++ :
Evaluating an analytic function towards a design-of-experiments given in an ASCII file.
This analytic function is written in C++ using the protocol of Uranie in file
"UserFunctions.C"
(the file can be found in the folder
${URANIESYS}/share/uranie/macros/). This function is named "flowrateModel" and it requires 8
inputs (, , , , , , , ) and returns a scalar ("ymod"). The analytic expression of the function is
given in (Section IV.1.2.1).
The design-of-experiments is the same as in precedent macro (Section XIV.2.4).
{
// Create a TDataServer
TDataServer * tds = new TDataServer();
// Load the data set in the DataServer
tds->fileDataRead("flowrateUniformDesign.dat");
// Load the function in the UserFunction macros file
gROOT->LoadMacro("UserFunctions.C");
// Create a TLauncherFunction from a TDataServer and an analytical function
// Rename the outpout attribute "ymod"
TLauncherFunction * tlf = new TLauncherFunction(tds, "flowrateModel","","ymod");
// Evaluate the function on all the points in the Design Of Experiments (DoE)
tlf->run();
// Graph
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro loadASCIIFile",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
pad->Divide(2,4);
pad->cd(1); tds->draw("ymod:rw");
pad->cd(2); tds->draw("ymod:r");
pad->cd(3); tds->draw("ymod:tu");
pad->cd(4); tds->draw("ymod:tl");
pad->cd(5); tds->draw("ymod:hu");
pad->cd(6); tds->draw("ymod:hl");
pad->cd(7); tds->draw("ymod:l");
pad->cd(8); tds->draw("ymod:kw");
}
Evaluating an analytic function in a stochastic design-of-experiments made with the LHS method.
This analytic function is written in C++ using the protocol of Uranie in file
"UserFunctions.C"
(the file can be found in the folder
${URANIESYS}/share/uranie/macros/). This function is named "flowrateModel" and it requires 8
inputs (, , , , , , , ) and returns a scalar ("ymod"). The analytic expression of the function is
given in (Section IV.1.2.1).
The design-of-experiments is made using the LHS method requesting 1000 samples.
{
Int_t nS = 1000;
// Create a TDataServer
TDataServer * tds = new TDataServer("tdsFlowrate","TDS for flowrate");
// Add the eight attributes of the study with uniform law
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// Generate the sampling from the TDataServer
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// Load the function in the UserFunction macros file
gROOT->LoadMacro("UserFunctions.C");
// Create a TLauncherFunction from a TDataServer and an analytical function
// Rename the outpout attribute "ymod"
TLauncherFunction * tlf = new TLauncherFunction(tds, "flowrateModel","","ymod");
// Evaluate the function on all the design of experiments
tlf->run();
// Graph
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro loadASCIIFile",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
pad->Divide(2,4);
pad->cd(1); tds->drawProfile("ymod:rw","","same");
pad->cd(2); tds->drawProfile("ymod:r","","same");
pad->cd(3); tds->drawProfile("ymod:tu","","same");
pad->cd(4); tds->drawProfile("ymod:tl","","same");
pad->cd(5); tds->drawProfile("ymod:hu","","same");
pad->cd(6); tds->drawProfile("ymod:hl","","same");
pad->cd(7); tds->drawProfile("ymod:l","","same");
pad->cd(8); tds->drawProfile("ymod:kw","","same");
}
The objective of this macro is to evaluate the flowrateModel
function on a design-of-experiments, then to
perform visualisations with different options. The sampling is made out of 1000 patterns using the LHS method. The
flowrateModel
function is used as a function and uses parameters obeying uniform laws on
specific intervals defined in Section IV.1.2.1.
{
Int_t nS = 1000;
// Create a TDataServer
TDataServer * tds = new TDataServer("tdsFlowrate","TDS for flowrate");
// Add the eight attributes of the study with uniform law
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// Generate the sampling from the TDataServer
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// Load the function in the UserFunction macros file
gROOT->LoadMacro("UserFunctions.C");
// Create a TLauncherFunction from a TDataServer and an analytical function
// Rename the outpout attribute "ymod"
TLauncherFunction * tlf = new TLauncherFunction(tds, "flowrateModel","","ymod");
// Evaluate the function on all the design of experiments
tlf->run();
// Graph
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchFunctionSampling",5,90,935,614);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
pad->Divide(2,4);
pad->cd(1); tds->drawTufte("rw:r","","same");
pad->cd(2); tds->drawCDF("rw");
pad->cd(3); tds->draw("ymod");
pad->cd(4); tds->drawCDF("ymod","","ccdf");
pad->cd(5); tds->draw("ymod:rw:hu");
pad->cd(6); tds->drawProfile("ymod:r","","same");
pad->cd(7); tds->drawProfile("ymod:rw","","same");
pad->cd(8); tds->draw("ymod:rw","","colz");
}
The attributes linked to the TDataServer
obey uniform laws:
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
The sampling is built with a LHS method on 1000 patterns:
TSampling *sampling = new TSampling(tds, "lhs", 1000);
sampling->generateSample();
The flowrateModel
function is evaluated on the design-of-experiments:
TLauncherFunction * tlf = new TLauncherFunction(tds, "flowrateModel","","ymod");
tlf->run();
Different visualisations are then performed on attributes:
tds->drawTufte("rw:r","","same");
tds->drawCDF("rw");
tds->draw("ymod");
tds->drawCDF("ymod","","ccdf");
tds->draw("ymod:rw:hu");
tds->drawProfile("ymod:r","","same");
tds->drawProfile("ymod:rw","","same");
tds->draw("ymod:rw","","colz");
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the input
file 'flowrate_input_with_keys.in'
is a "key=value" type and the output file
"_output_flowrate_withRow_.dat"
is a "values in rows" type. This flowrate
code is described in Section IV.1.2.3.1.1.
The database is contained in the file flowrateUniformDesign.dat
containing 32 patterns.
#NAME: flowrateborehole #TITLE: Uniform design of flow rate borehole problem proposed by Ho and Xu(2000) #COLUMN_NAMES: rw| r| tu| tl| hu| hl| l| kw | ystar #COLUMN_TITLES: r_{#omega}| r | T_{u} | T_{l} | H_{u} | H_{l} | L | K_{#omega} | y^{*} #COLUMN_UNITS: m | m | m^{2}/yr | m^{2}/yr | m | m | m | m/yr | m^{3}/yr 0.0500 33366.67 63070.0 116.00 1110.00 768.57 1200.0 11732.14 26.18 0.0500 100.00 80580.0 80.73 1092.86 802.86 1600.0 10167.86 14.46 0.0567 100.00 98090.0 80.73 1058.57 717.14 1680.0 11106.43 22.75 0.0567 33366.67 98090.0 98.37 1110.00 734.29 1280.0 10480.71 30.98 0.0633 100.00 115600.0 80.73 1075.71 751.43 1600.0 11106.43 28.33 0.0633 16733.33 80580.0 80.73 1058.57 785.71 1680.0 12045.00 24.60 0.0700 33366.67 63070.0 98.37 1092.86 768.57 1200.0 11732.14 48.65 0.0700 16733.33 115600.0 116.00 990.00 700.00 1360.0 10793.57 35.36 0.0767 100.0 115600.0 80.73 1075.71 751.43 1520.0 10793.57 42.44 0.0767 16733.33 80580.0 80.73 1075.71 802.86 1120.0 9855.00 44.16 0.0833 50000.00 98090.0 63.10 1041.43 717.14 1600.0 10793.57 47.49 0.0833 50000.00 115600.0 63.10 1007.14 768.57 1440.0 11419.29 41.04 0.0900 16733.33 63070.0 116.00 1075.71 751.43 1120.0 11419.29 83.77 0.0900 33366.67 115600.0 116.00 1007.14 717.14 1360.0 11106.43 60.05 0.0967 50000.00 80580.0 63.10 1024.29 820.00 1360.0 9855.00 43.15 0.0967 16733.33 80580.0 98.37 1058.57 700.00 1120.0 10480.71 97.98 0.1033 50000.00 80580.0 63.10 1024.29 700.00 1520.0 10480.71 74.44 0.1033 16733.33 80580.0 98.37 1058.57 820.00 1120.0 10167.86 72.23 0.1100 50000.00 98090.0 63.10 1024.29 717.14 1520.0 10793.57 82.18 0.1100 100.00 63070.0 98.37 1041.43 802.86 1600.0 12045.00 68.06 0.1167 33366.67 63070.0 116.00 990.00 785.71 1280.0 12045.00 81.63 0.1167 100.00 98090.0 98.37 1092.86 802.86 1680.0 9855.00 72.5 0.1233 16733.33 115600.0 80.73 1092.86 734.29 1200.0 11419.29 161.35 0.1233 16733.33 63070.0 63.10 1041.43 785.71 1680.0 12045.00 86.73 0.1300 33366.67 80580.0 116.00 1110.00 768.57 1280.0 11732.14 164.78 0.1300 100.00 98090.0 98.37 1110.00 820.00 1280.0 10167.86 121.76 0.1367 50000.00 98090.0 63.10 1007.14 820.00 1440.0 10167.86 76.51 0.1367 33366.67 98090.0 116.00 1024.29 700.00 1200.0 10480.71 164.75 0.1433 50000.00 63070.0 116.00 990.00 785.71 1440.0 9855.00 89.54 0.1433 50000.00 115600.0 63.10 1007.14 734.29 1440.0 11732.14 141.09 0.1500 33366.67 63070.0 98.37 990.00 751.43 1360.0 11419.29 139.94 0.1500 100.00 115600.0 80.73 1041.43 734.29 1520.0 11106.43 157.59
The input file flowrate_input_with_keys.in
is "key=value" format:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -k.
The output file, _output_flowrate_withRow_.dat
when created, is a "values in rows with an
header" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d have to be defined as output variables in the macro.
{
// Create a TDataServer
TDataServer * tds = new TDataServer();
// Load the data base in the DataServer
tds->fileDataRead("flowrateUniformDesign.dat");
// The reference input file
TString sIn = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "Rw");
tds->getAttribute("r")->setFileKey(sIn, "R");
tds->getAttribute("tu")->setFileKey(sIn, "Tu");
tds->getAttribute("tl")->setFileKey(sIn, "Tl");
tds->getAttribute("hu")->setFileKey(sIn, "Hu");
tds->getAttribute("hl")->setFileKey(sIn, "Hl");
tds->getAttribute("l")->setFileKey(sIn, "L");
tds->getAttribute("kw")->setFileKey(sIn, "Kw");
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
// Graph
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateKeyDataBase",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
pad->Divide(2,4);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(2); tds->draw("yhat:r");
pad->cd(3); tds->draw("yhat:tu");
pad->cd(4); tds->draw("yhat:tl");
pad->cd(5); tds->draw("yhat:hu");
pad->cd(6); tds->draw("yhat:hl");
pad->cd(7); tds->draw("yhat:l");
pad->cd(8); tds->draw("yhat:kw");
}
The database is loaded from a data file flowrateUniformDesign.dat
:
tds->fileDataRead("flowrateUniformDesign.dat");
Then, properties are set for each input variable. For example for the first variable, it is created as a
TAttribute
named "rw": this TAttribute
is then linked to the input
file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "Rw");
which will be understood by Uranie as the fact the rw variable has to be read in the input file with "key=value" format with the key Rw.
We use the output file with "values in rows" type _output_flowrate_withRow_.dat
which will be
instantiated as a TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variables yhat and d can be linked to this
TOutputFileRow
output file. But here, only yhat will be
considered by Uranie as variable of interest.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-k" option.
TCode *mycode = new TCode(tds, "flowrate -k");
which indicates that flowrate code has to find the input file with "key=value" type.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *lanceur = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the 32 patterns with the
run
method:
lanceur->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments with the input
file "flowrate_input_with_keys.in"
with "key=value" type and the output file
"_output_flowrate_withRow_.dat"
with "values in rows" type. This flowrate
code is described in Section IV.1.2.3.1.1.
The used input file flowrate_input_with_keys.in
is with "key=value" type:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -k.
The output file, _output_flowrate_withRow_.dat
is with "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d have to be defined as output variables in the macro.
void launchCodeFlowrateKeySampling(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "Rw");
tds->getAttribute("r")->setFileKey(sIn, "R");
tds->getAttribute("tu")->setFileKey(sIn, "Tu");
tds->getAttribute("tl")->setFileKey(sIn, "Tl");
tds->getAttribute("hu")->setFileKey(sIn, "Hu");
tds->getAttribute("hl")->setFileKey(sIn, "Hl");
tds->getAttribute("l")->setFileKey(sIn, "L");
tds->getAttribute("kw")->setFileKey(sIn, "Kw");
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateFlag",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,80.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
The laws of distribution are set for each input variable. For example for the Rw
variable, the macro creates an uniform distribution between 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "@Rw@");
which will be understood by Uranie as the fact the rw variable has to be read in the input file with "key=value" format with the key Rw.
A design-of-experiments is then built with 100 samplings using the LHS method:
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
We want the output file to be with values in rows. So the output file
_output_flowrate_withRow_.dat
is set as a TOutputFileRow
:
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d could be linked to this
TOutputFileRow
output file. But here, only yhat will be
considered as variable of interest by Uranie:
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-k" option:
TCode *mycode = new TCode(tds, "flowrate -k");
in xhich the "-k" option indicates that flowrate has to find input files with "key=value" format.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *lanceur = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the 100 patterns with the
run
method:
tlch->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments with the input
file "flowrate_input_with_xml.in"
with XML format and the output file
"_output_flowrate_withXML_.dat"
also with XML format. This flowrate code is
described in Section IV.1.2.3.1.1.
The used input file flowrate_input_with_xml.in
is with XML type:
<?xml version="1.0"?>
<problem>
<description name="flowrate" title="UseCase flowrate with XML input file" version="1.0" date="2011-07-22 12:55:17">
<tool name="uranie" version="0.3"/>
</description>
<steady_state name="sch">
<wall_friction rw="0.0500" r="33366.67"/>
<tinit>0.0</tinit>
<tmax>1000000</tmax>
<dt_step_nb_max>1500</dt_step_nb_max>
<parameter>
<tonode>mesher</tonode><toport>dt_hu</toport>
<value><double>1110.00</double></value>
</parameter>
<parameter>
<tonode>mesher</tonode><toport>dt_hl</toport>
<value><double>768.57</double></value>
</parameter>
<parameter>
<tonode>mesher</tonode><toport>dt_hd</toport>
<value><int>12345</int></value>
</parameter>
<facsec>1000000.</facsec>
<kW value="11732.14"/>
<informations>
<parameter name="Tu">
<Uniform_Field>1</Uniform_Field>
<value><double>63070.0</double></value>
</parameter>
<parameter name="Tl">
<Uniform_Field>1</Uniform_Field>
<value><double>116.00</double></value>
</parameter>
<parameter name="L" precision="1200.0"/>
</informations>
<convergence>
<criterion>relative_max_du_dt</criterion>
<precision>1.e-6</precision>
</convergence>
<stop_criterium ch_abscissa_hu="1050" ch_ordinate_hl="770" c_radius="1100" nLoop="1"/>
<solver name="Newton3">
<max_iter_matrix>1</max_iter_matrix>
<max_iter_implicit>1</max_iter_implicit>
<date>5654321</date>
<implicit_convergence_threshold>1.e-6</implicit_convergence_threshold>
<implicit_assembly>10</implicit_assembly>
<linear_solver name="BiCGS">
<preconditioner>ILU</preconditioner>
<implicit_solve_threshold>1.e-5</implicit_solve_threshold>
</linear_solver>
</solver>
</steady_state>
</problem>
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -x.
The output file, _output_flowrate_withXML_.dat
is with XML type. It looks like:
<?xml version="1.0"?>
<steady_state name="flowrate">
<parameter>
<tonode>mesher</tonode>
<toport>dt_hl</toport>
<value>
<double>2.618019e+01</double>
</value>
</parameter>
<distance value="3.602045e+03"/>
</steady_state>
yhat and d have to be defined as output variables in the macro.
void launchCodeFlowrateXMLSampling(Int_t nS = 100){
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_xml.in");
tds->getAttribute("rw")->setFileKey(sIn, "wall_friction/@rw", "%e", TAttributeFileKey::kXMLAttribute);
tds->getAttribute("r")->setFileKey(sIn, "wall_friction/@r", "%e", TAttributeFileKey::kXMLAttribute);
tds->getAttribute("tu")->setFileKey(sIn, "parameter[@name='Tu']/value/double", "%e", TAttributeFileKey::kXMLField);
tds->getAttribute("tl")->setFileKey(sIn, "parameter[@name='Tl']/value/double", "%e", TAttributeFileKey::kXMLField);
tds->getAttribute("hu")->setFileKey(sIn, "parameter[tonode='mesher' and toport='dt_hu']/value/double", "%e", TAttributeFileKey::kXMLField);
tds->getAttribute("hl")->setFileKey(sIn, "parameter[tonode='mesher' and toport='dt_hl']/value/double", "%e", TAttributeFileKey::kXMLField);
tds->getAttribute("l")->setFileKey(sIn, "parameter[@name='L']/@precision", "%e", TAttributeFileKey::kXMLAttribute);
tds->getAttribute("kw")->setFileKey(sIn, "kW/@value", "%e", TAttributeFileKey::kXMLAttribute);
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileXML *fout = new TOutputFileXML("_output_flowrate_withXML_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"), "/steady_state[@name='flowrate']/parameter/value/double", TAttributeFileKey::kXMLField);
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -x");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateOATMinMax",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,80.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
The laws of distribution are set for each input variable. For example for the Rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05,0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey("flowrate_input_with_xml.in", "frottement_paroi/@rw","%e", TAttributeFileKey::kXMLAttribute);
which will be understood by Uranie as the fact the rw variable has to be read in
the input file with XML format as an XML attribute (kXMLAttribute
) with the path frottement_paroi/@rw. In the same way, others TAttributes
are added,
some with XML fields:
tds->getAttribute("tu")->setFileKey(sIn, "parameter[@name='Tu']/value/double", "%e", TAttributeFileKey::kXMLField);
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
We want the output file to be with XML format. So the output file _output_flowrate_withXML_.dat
is set as a TOutputFileXML
.
TOutputFileXML *fout = new TOutputFileXML("_output_flowrate_withXML_.dat");
The variable yhat and d could be linked to this
TOutputFileRow
output file. But here, only yhat will be
considered as variable of interest by Uranie, by passing Uranie the new attribute, its XML path and type:
fout->addAttribute(new TAttribute("yhat"), "/steady_state[@name='flowrate']/parameter/value/double", URANIE::DataServer::TAttributeFileKey::kXMLField);
We set the code as being the flowrate execution with "-x" option to deal with XML inputs.
TCode *mycode = new TCode(tds, "flowrate -x");
which indicates that flowrate has to find input files with XML format.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *lanceur = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the 100 patterns with the
run
method:
tlch->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where input
file "flowrate_input_with_keys.in"
is with type "key=value" and the output file
"_output_flowrate_withKey_.dat"
is also of the "key=value" type. This code is described in
Section IV.1.2.3.1.1.
The used input file flowrate_input_with_keys.in
has "key=value" format:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
It defines the eight variables , , , , , , , and performs the execution of the command flowrate -k.
The output file _output_flowrate_withKey_.dat
is with "key=value"
type. It looks like:
yhat = 6.757218e+01; d = 4.092561e+03;
yhat and d are defined as output variables in the macro.
void launchCodeFlowrateKeySamplingKey(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "Rw");
tds->getAttribute("r")->setFileKey(sIn, "R");
tds->getAttribute("tu")->setFileKey(sIn, "Tu");
tds->getAttribute("tl")->setFileKey(sIn, "Tl");
tds->getAttribute("hu")->setFileKey(sIn, "Hu");
tds->getAttribute("hl")->setFileKey(sIn, "Hl");
tds->getAttribute("l")->setFileKey(sIn, "L");
tds->getAttribute("kw")->setFileKey(sIn, "Kw");
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileKey *fout = new TOutputFileKey("_output_flowrate_withKey_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
fout->addAttribute(new TAttribute("d"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
// tds->exportData("_flowrate_sampler_launcher_.dat");
tds->startViewer();
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateOATMinMax",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,20.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
axis->AddRange(new TParallelCoordRange(axis,155.0,160.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
The laws of distributions are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw" (note that the set value in
flowrate_input_with_keys.in
for Rw, 0.05, is between
bounds. It is important to check this property when creating the distribution):
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "Rw");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "key=value" format with the key Rw.
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "key=value" type of format _output_flowrate_withKey_.dat
is instantiated
as a TOutputFileKey
.
TOutputFileKey *fout = new TOutputFileKey("_output_flowrate_withKey_.dat");
The two output variables yhat and d are then
linked to this TOutputFileKey
output file.
fout->addAttribute(new TAttribute("d"));
fout->addAttribute(new TAttribute("yhat"));
We set the code as being the flowrate execution with "-k"option:
TCode *mycode = new TCode(tds, "flowrate -k");
in which the "-k" option indicates that flowrate code has to find "key=value" input files.
The launcher is initialised:
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the 100 patterns and launched with
the run
method:
tlch->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the input
file "flowrate_input_with_keys.in"
which is produced by Uranie on the fly is with type
"key=value" and the output file "_output_flowrate_withKey_.dat"
with type "key=value". This
flowrate code is described in Section IV.1.2.3.1.1.
The used input file flowrate_input_with_keys.in
has "key=value" format and will be produced on
the fly by the code:
Rw = 1.480238e-01 ; R = 3.644187e+03 ; Tu = 7.840305e+04 ; Tl = 8.467102e+01 ; Hu = 1.008708e+03 ; Hl = 7.667991e+02 ; L = 1.174857e+03 ; Kw = 1.097634e+04 ;
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -k.
The output file _output_flowrate_withRow_.dat
is with "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro. But here, only yhat is considered as variable of interest by Uranie.
void launchCodeFlowrateKeyRecreateSampling(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "Rw","",TAttributeFileKey::kNewKey);
tds->getAttribute("r")->setFileKey(sIn, "R","",TAttributeFileKey::kNewKey);
tds->getAttribute("tu")->setFileKey(sIn, "Tu","",TAttributeFileKey::kNewKey);
tds->getAttribute("tl")->setFileKey(sIn, "Tl","",TAttributeFileKey::kNewKey);
tds->getAttribute("hu")->setFileKey(sIn, "Hu","",TAttributeFileKey::kNewKey);
tds->getAttribute("hl")->setFileKey(sIn, "Hl","",TAttributeFileKey::kNewKey);
tds->getAttribute("l")->setFileKey(sIn, "L","",TAttributeFileKey::kNewKey);
tds->getAttribute("kw")->setFileKey(sIn, "Kw","",TAttributeFileKey::kNewKey);
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileKey *fout = new TOutputFileKey("_output_flowrate_withKey_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateKeyRecreateSampling",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,80.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
In the first part of this macro, properties are set for each input variable. For example for the Rw variable, the macro creates an uniform distribution between bounds 0.05 and 0.15
associated to a TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_keys.in"), "Rw","",TAttributeFileKey::kNewKey);
which will be understood by Uranie as the fact the rw variable has to be read in
the input file with "key=value" format with the key Rw. The property
TAttributeFileKey::kNewKey
means that the input file is of "key=value" type and has to be
created on the fly for each sampling locations.
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "values in rows" type _output_flowrate_withRow_.dat
is instantiated set as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d could be linked to this
TOutputFileRow
output file. But here, only yhat will be
considered by Uranie as variable of interest.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-k" option.
TCode *mycode = new TCode(tds, "flowrate -k");
which indicates that flowrate code has to find "key=value" input files.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the 100 patterns with the
run
method:
tlch->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the input
file "flowrate_input_with_keys.in"
which will be produced by Uranie on the fly is with type
"key=value" and the output file "_output_flowrate_withRow_.dat"
is with type
"DataServer". This flowrate code is described in Section IV.1.2.3.1.1.
The input file flowrate_input_with_keys.in
has "key=value" format and will be produced on the
fly by the code:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -k.
The output file _output_flowrate_withRow_.dat
is with "DataServer" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro. But here, only yhat is considered as variable of interest by Uranie.
void launchCodeFlowrateKeyRecreateSamplingOutputDataServer(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "Rw","",TAttributeFileKey::kNewKey);
tds->getAttribute("r")->setFileKey(sIn, "R","",TAttributeFileKey::kNewKey);
tds->getAttribute("tu")->setFileKey(sIn, "Tu","",TAttributeFileKey::kNewKey);
tds->getAttribute("tl")->setFileKey(sIn, "Tl","",TAttributeFileKey::kNewKey);
tds->getAttribute("hu")->setFileKey(sIn, "Hu","",TAttributeFileKey::kNewKey);
tds->getAttribute("hl")->setFileKey(sIn, "Hl","",TAttributeFileKey::kNewKey);
tds->getAttribute("l")->setFileKey(sIn, "L","",TAttributeFileKey::kNewKey);
tds->getAttribute("kw")->setFileKey(sIn, "Kw","",TAttributeFileKey::kNewKey);
// Generate the design of experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileDataServer *fout = new TOutputFileDataServer("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute("yhat"); // fout->addAttribute(new TAttribute("y"));
// Create a TCode object from a TDS and the command line
TCode *mycode = new TCode(tds, "flowrate -s -k");
// Add the output file
mycode->addOutputFile( fout );
// Create a launcher of code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateKeyRecreateSamplingOutputDataServer",565,62,560,619);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(1, 3);
// Scatterplot y versus rw
pad->cd(1); tds->draw("yhat:rw");
// Histogramm of the output attribute
pad->cd(2); tds->draw("yhat");
// The parallel plot
pad->cd(3);
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,20.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
axis->AddRange(new TParallelCoordRange(axis,155.0,160.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
The laws of distributions are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_rows.in"), "Rw","",TAttributeFileKey::kNewKey);
which will be understood by Uranie as the fact the rw variable has to be read in
an input file with "key=value" format. The property TAttributeFileKey::kNewKey
means the
input file has to be created on the fly for each sampling created.
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "DataServer" type _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileDataServer
. This TOutputFileDataServer
file is of the same
format that a TDataServer
can load.
TOutputFileDataServer *fout = new TOutputFileDataServer("_output_flowrate_withRow_.dat");
The variable yhat and d are then linked to this
TOutputFileDataServer
output file. But here, only yhat will
be considered by Uranie as a variable of interest.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-k" option.
TCode *mycode = new TCode(tds, "flowrate -k");
which indicates that flowrate code has to find "key=value" input files.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *lanceur = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the 100 patterns with the
run
method.
lanceur->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the input
file "flowrate_input_with_values_rows.in"
will be produced on the fly by Uranie is with
"values in rows" type and the output file "_output_flowrate_withRow_.dat"
with "DataServer"
type. This flowrate code is described in Section IV.1.2.3.1.1.
The input file flowrate_input_with_values_rows.in
is with "values in rows" format and will be
produced on the fly by the code:
0.0500 33366.67 63070.0 116.00 1110.00 768.57 1200.0 11732.14
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -r.
The output file _output_flowrate_withRow_.dat
is of "DataServer" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro.
void launchCodeFlowrateRowRecreateSamplingOutputDataServer(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The input file
TString sFileName = TString("flowrate_input_with_values_rows.in");
// Set the input file with "key = value" format CREATED ON FLY with row for each input attributes
tds->getAttribute("rw")->setFileKey(sFileName, "Rw","",TAttributeFileKey::kNewRow);
tds->getAttribute("r")->setFileKey(sFileName, "R","",TAttributeFileKey::kNewRow);
tds->getAttribute("tu")->setFileKey(sFileName, "Tu","",TAttributeFileKey::kNewRow);
tds->getAttribute("tl")->setFileKey(sFileName, "Tl","",TAttributeFileKey::kNewRow);
tds->getAttribute("hu")->setFileKey(sFileName, "Hu","",TAttributeFileKey::kNewRow);
tds->getAttribute("hl")->setFileKey(sFileName, "Hl","",TAttributeFileKey::kNewRow);
tds->getAttribute("l")->setFileKey(sFileName, "L","",TAttributeFileKey::kNewRow);
tds->getAttribute("kw")->setFileKey(sFileName, "Kw","",TAttributeFileKey::kNewRow);
// Generate a Design of experiments (DoE) from the TDataServer
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code based on the same format that a TDataServer can load (#COLUMN_NAMES: yhat | d)
TOutputFileDataServer *fout = new TOutputFileDataServer("_output_flowrate_withRow_.dat");
// The attributes in the output file
fout->addAttribute("d"); // fout->addAttribute(new TAttribute("d"));
fout->addAttribute("yhat"); // fout->addAttribute(new TAttribute("yhat"));
// Create a TCode object with the TDS (attribute and input files) and the command to execute
TCode *mycode = new TCode(tds, "flowrate -s -r");
// Add the output file
mycode->addOutputFile( fout );
// Launcher of the code on the Design of experiments (DoE) in the TDS
TLauncher *tlch = new TLauncher(tds, mycode);
tlch->setSave();
tlch->setClean();
//tlch->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
tlch->setVarDraw("yhat:rw","","");
// Evaluate the DoE
tlch->run();
// tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateRowRecreateSamplingOutputDataServer.C",565,62,560,619);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(1, 3);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(2);
// Histogramm of the output attribute
tds->draw("yhat");
pad->cd(3);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,20.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kRed);
axis->AddRange(new TParallelCoordRange(axis,155.0,160.0));
}
The laws of distribution are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_rows.in"), "Rw","",TAttributeFileKey::kNewRow);
which will be understood by Uranie as the fact the rw variable has to be read in
an input file with "values in rows" format. The property TAttributeFileKey::kNewRow
means the input
file has to be created for each sampling created.
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "DataServer" type _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileDataServer
. This TOutputFileDataServer
file is of the same
format that a TDataServer
can load.
TOutputFileDataServer *fout = new TOutputFileDataServer("_output_flowrate_withRow_.dat");
The variable yhat and d are then linked to this
TOutputFileDataServer
output file.
fout->addAttribute("d");
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-r" option:
TCode *mycode = new TCode(tds, "flowrate -r");
in which the "-r" option indicates that flowrate code has to find "values in rows" input files.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -r command for each of the 100 patterns with the
run
method.
tlch->run();
The objective of the macro is to evaluate the flowrate external code on the design-of-experiments where the
input file "flowrate_input_with_flags.in"
has flags" replaced with usable values and the
output file "_output_flowrate_withRow_.dat"
with "values in rows" type. This code
flowrate is described in Section IV.1.2.3.1.1.
The creation of an input file containing some "flags" is motivated by the will to make evolve variables in an input file with no particular structure:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { 0.071623 19712.541454 } // values of Rw and R tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min 1051.972855 // value of Hu dt_max 805.249178 // value of Hl facsec 1000000. kW 11401.611060 // value of Kw information_Tu Champ_Uniforme 1 85927.853162 // value of Tu information_Tl Champ_Uniforme 1 85.803614 // value of Tl information_L { precision 1162.689830 // value of L } convergence { criterion relative_max_du_dt precision 1.e-6 } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
These values are then replaced by "flags" bounded with special characters.
The input file flowrate_input_with_flags.in
that contains "flags" is built this way:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { @Rw@ @R@ } tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min @Hu@ dt_max @Hl@ facsec 1000000. kW @Kw@ information_Tu Champ_Uniforme 1 @Tu@ information_Tl Champ_Uniforme 1 @Tl@ information_L { precision @L@ } convergence { criterion relative_max_du_dt precision @Rw@ } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
This file defines the eight variables , , , , , , , needed to perform the execution of the command flowrate -f.
The output file _output_flowrate_withRow_.dat
is of "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro. But here, only yhat is considered as variable of interest by Uranie.
void launchCodeFlowrateFlagSampling(Int_t nS = 400)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_flags.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileFlag(sIn, "@Rw@");
tds->getAttribute("r")->setFileFlag(sIn, "@R@");
tds->getAttribute("tu")->setFileFlag(sIn, "@Tu@");
tds->getAttribute("tl")->setFileFlag(sIn, "@Tl@");
tds->getAttribute("hu")->setFileFlag(sIn, "@Hu@");
tds->getAttribute("hl")->setFileFlag(sIn, "@Hl@");
tds->getAttribute("l")->setFileFlag(sIn, "@L@");
tds->getAttribute("kw")->setFileFlag(sIn, "@Kw@");
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -f");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
// lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateFlag",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,100.0,160.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
The laws of distribution are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileFlag(TString("flowrate_input_with_flags.in"), "@Rw@");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "flags".
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "values in rows" type _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d are then linked to this
TOutputFileRow
output file. But here, only yhat will be
considered as variable of interest by Uranie.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-f" option.
TCode *mycode = new TCode(tds, "flowrate -f");
which indicates that flowrate code has to find input files with "flags".
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -f command for each of the 100 patterns with the
run
method:
tlch->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the input
file "flowrate_input_with_flags.in"
has "flags" and the output file
"_output_flowrate_withKey_.dat"
is with type "key=value". This code is described in Section IV.1.2.3.1.1.
The creation of an input file containing some "flags" is motivated by the will to make evolve variables in an input file with no particular structure:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { 0.071623 19712.541454 } // values of Rw and R tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min 1051.972855 // value of Hu dt_max 805.249178 // value of Hl facsec 1000000. kW 11401.611060 // value of Kw information_Tu Champ_Uniforme 1 85927.853162 // value of Tu information_Tl Champ_Uniforme 1 85.803614 // value of Tl information_L { precision 1162.689830 // value of L } convergence { criterion relative_max_du_dt precision 1.e-6 } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
These values are then replaced by "flags" bounded with special characters.
The input file flowrate_input_with_flags.in
containing "flags" is built this way:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { @Rw@ @R@ } tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min @Hu@ dt_max @Hl@ facsec 1000000. kW @Kw@ information_Tu Champ_Uniforme 1 @Tu@ information_Tl Champ_Uniforme 1 @Tl@ information_L { precision @L@ } convergence { criterion relative_max_du_dt precision @Rw@ } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
It defines the eight variables , , , , , , , and performs the execution of the command flowrate -f.
The output file _output_flowrate_withKey_.dat
is with "key=value"
type. It looks like:
yhat = 6.757218e+01; d = 4.092561e+03;
yhat and d are defined as output variables in the macro.
void launchCodeFlowrateFlagSamplingKey(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = TString("flowrate_input_with_flags.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "@Rw@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("r")->setFileKey(sIn, "@R@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("tu")->setFileKey(sIn, "@Tu@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("tl")->setFileKey(sIn, "@Tl@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("hu")->setFileKey(sIn, "@Hu@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("hl")->setFileKey(sIn, "@Hl@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("l")->setFileKey(sIn, "@L@","%f",TAttributeFileKey::kFlag);
tds->getAttribute("kw")->setFileKey(sIn, "@Kw@","%f",TAttributeFileKey::kFlag);
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileKey *fout = new TOutputFileKey("_output_flowrate_withKey_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
fout->addAttribute(new TAttribute("d"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -f ");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_oat_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateFlag",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,18.0,20.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
axis->AddRange(new TParallelCoordRange(axis,155.0,160.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kRed);
}
The distribution laws are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileFlag(sFileName, "@Rw@");
which is the same thing as writing:
tds->getAttribute("rw")->setFileKey("flowrate_input_with_flags.in", @Rw@,"%e",TAttributeFileKey::kFlag);
which will be understood by Uranie as the fact the rw variable has to be read in an input file with flag format. The code will then, for each generated sampling, replace the flag @Rw@ in the input file by the corresponding value.
A design-of-experiments is then built with 100 samplings using the LHS method:
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "key=value" format _output_flowrate_withKey_.dat
is instantiated as a
TOutputFileKey
.
TOutputFileKey *fout = new TOutputFileKey("_output_flowrate_withKey_.dat");
The two output variables yhat and d are then
linked to this TOutputFileKey
output file:
fout->addAttribute(new TAttribute("d"));
fout->addAttribute(new TAttribute("yhat"));
We set the code as being the flowrate execution with "-f" option:
TCode *mycode = new TCode(tds, "flowrate -f");
in which the "-f" option indicates that flowrate code has to find input files with "flags".
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *tlch = new TLauncher(tds, mycode);
tlch->run();
The launcher will execute the flowrate -f command for each of the 100 patterns with the
run
method.
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the values
of attributes will be replaced in two input files, the first, "flowrate_input_with_keys.in"
with "key=value" type, the second, "flowrate_input_with_flags.in"
with "flags" and the output
file "_output_flowrate_withRow_.dat"
with "values in rows" type. This
flowrate code is described in Section IV.1.2.3.1.1.
The first input file flowrate_input_with_keys.in
is "key=value" format:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
The creation of an input file containing some "flags" is motivated by the will to make evolve variables in an input file with no particular structure:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { 0.071623 19712.541454 } // values of Rw and R tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min 1051.972855 // value of Hu dt_max 805.249178 // value of Hl facsec 1000000. kW 11401.611060 // value of Kw information_Tu Champ_Uniforme 1 85927.853162 // value of Tu information_Tl Champ_Uniforme 1 85.803614 // value of Tl information_L { precision 1162.689830 // value of L } convergence { criterion relative_max_du_dt precision 1.e-6 } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
These values are then replaced by "flags" bounded with special characters.
The second input file flowrate_input_with_flags.in
containing "flags" is built this way:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { @Rw@ @R@ } tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min @Hu@ dt_max @Hl@ facsec 1000000. kW @Kw@ information_Tu Champ_Uniforme 1 @Tu@ information_Tl Champ_Uniforme 1 @Tl@ information_L { precision @L@ } convergence { criterion relative_max_du_dt precision @Rw@ } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
These files define the eight variables , , , , , , , needed to perform the execution of the command flowrate -k and the command flowrate -f.
The output file _output_flowrate_withRow_.dat
is of "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro.
void launchCodeFlowrateKeyFlagSampling(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file with key
TString sInKey = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sInKey, "Rw");
tds->getAttribute("r")->setFileKey(sInKey, "R");
tds->getAttribute("tu")->setFileKey(sInKey, "Tu");
tds->getAttribute("tl")->setFileKey(sInKey, "Tl");
tds->getAttribute("hu")->setFileKey(sInKey, "Hu");
tds->getAttribute("hl")->setFileKey(sInKey, "Hl");
tds->getAttribute("l")->setFileKey(sInKey, "L");
tds->getAttribute("kw")->setFileKey(sInKey, "Kw");
// The reference input file with flag
TString sInFlag = TString("flowrate_input_with_flags.in");
tds->getAttribute("rw")->setFileFlag(sInFlag, "@Rw@");
tds->getAttribute("r")->setFileFlag(sInFlag, "@R@");
tds->getAttribute("tu")->setFileFlag(sInFlag, "@Tu@");
tds->getAttribute("tl")->setFileFlag(sInFlag, "@Tl@");
tds->getAttribute("hu")->setFileFlag(sInFlag, "@Hu@");
tds->getAttribute("hl")->setFileFlag(sInFlag, "@Hl@");
tds->getAttribute("l")->setFileFlag(sInFlag, "@L@");
tds->getAttribute("kw")->setFileFlag(sInFlag, "@Kw@");
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
// tds->scan("*");
tds->exportData("_flowrate_sampler_launcher_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateFlag",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,80.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
The laws of distribution are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the first input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "Rw");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "key=value" format. If the user wants to get values of variables in an input file with "flags", he can redefine the link towards the "flag" file directly:
tds->getAttribute("rw")->setFileFlag(TString("flowrate_input_with_flags.in"), "@Rw@");
So the code will look for input files with "flags".
A design-of-experiments is then built with 100 samplings using the LHS method:
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "values in rows" type _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variables yhat and d could then be linked to
this TOutputFileRow
output file. But here, only yhat will
be considered as a variable of interest by Uranie.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-f" option but user can also use the "-k" option.
TCode *mycode = new TCode(tds, "flowrate -f");
which indicates that flowrate code has to find input files with "flags". With option "-k", flowrate has to find file with "key=value" format.
Then the launcher is initialised with a TDataServer
and the code is executed:
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -f command for each of the 100 patterns with the
run
method:
tlch->run();
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments where the input
file "flowrate_input_with_keys.in"
is with "key=value" type and defines the variables usable
by the code ; a second input file "flowrate_input_with_flags.in"
will moved by Uranie in the
working directory but it will not be modified. The output file "_output_flowrate_withRow_.dat"
is with "values in rows" type. This code is described in Section IV.1.2.3.1.1.
The first input file flowrate_input_with_keys.in
has "key=value" format:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
If we suppose that one wants to add an input file with "flag" format
flowrate_input_with_flags.in
.
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { @Rw@ @R@ } tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min @Hu@ dt_max @Hl@ facsec 1000000. kW @Kw@ information_Tu Champ_Uniforme 1 @Tu@ information_Tl Champ_Uniforme 1 @Tl@ information_L { precision @L@ } convergence { criterion relative_max_du_dt precision @Rw@ } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
The input file flowrate_input_with_keys.in
defines the eight variables , , , , , , , needed to
perform the execution of the command flowrate -k.
The output file _output_flowrate_withRow_.dat
is with "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d have to be defined as output variables in the macro. But in this one, only yhat will be considered.
void launchCodeFlowrateKeywithFlagSampling(Int_t nS = 100)
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsFlowrate", "Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file with key
TString sInKey = TString("flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sInKey, "Rw");
tds->getAttribute("r")->setFileKey(sInKey, "R");
tds->getAttribute("tu")->setFileKey(sInKey, "Tu");
tds->getAttribute("tl")->setFileKey(sInKey, "Tl");
tds->getAttribute("hu")->setFileKey(sInKey, "Hu");
tds->getAttribute("hl")->setFileKey(sInKey, "Hl");
tds->getAttribute("l")->setFileKey(sInKey, "L");
tds->getAttribute("kw")->setFileKey(sInKey, "Kw");
// Generate the Design of Experiments
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// on ajoute le fichier de sortie du code
mycode->setReferenceDirectory( gSystem->pwd() );
mycode->addInputFile("flowrate_input_with_flags.in");
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateOATMinMax",5,64,1270,667);
gStyle->SetPalette(1);
tds->draw("yhat:rw");
tds->startViewer();
}
The laws of distribution are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "Rw");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "key=value" format.
A design-of-experiments is then built with 100 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 100);
sampling->generateSample();
The output file with "values in rows" type _output_flowrate_withKey_.dat
is set as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat is then linked to this TOutputFileRow
output file.
fout->addAttribute(new TAttribute("yhat"));
We set the code as being the flowrate execution with "-k" option:
TCode *mycode = new TCode(tds, "flowrate -k");
in which the "-k" option indicates that flowrate code has to find "key=value" input files.
We suppose the user wants to add another input file to the code. He specifies where is the new input file:
mycode->setReferenceDirectory( gSystem->pwd() );
and then he adds the new input file (here it's an input file with "flag" format ) which will be copied each time in the working directory.
mycode->addInputFile("flowrate_input_with_flags.in");
Then the launcher is initialised with a TDataServer
and the code is executed and launched with the
run
method
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->run();
The objective of the macro is to evaluate the external code flowrate with failures on a design-of-experiments where input file
"flowrate_input_with_keys.in"
is with "key=value" type and the output file
"_output_flowrate_withRow_.dat"
with type "values in rows". This flowrate
code is described in Section IV.1.2.3.1.1.
The input file flowrate_input_with_keys.in
is with "key=value":
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
This file defines the eight variables , , , , , , , and also the three additional variables chu, chl and cr needed to perform the execution of the command flowrate -kf.
The output file _output_flowrate_withRow_.dat
is of "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro.
{
Int_t nS = 400;
// Define the DataServer
TDataServer *tds = new TDataServer("tdsflowrate", "DataBase flowrate");
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The reference input file
TString sIn = gSystem->pwd() + TString("/");
sIn += TString("flowrate_input_with_keys.in");
tds->getAttribute("rw")->setFileKey(sIn, "Rw");
tds->getAttribute("r")->setFileKey(sIn, "R");
tds->getAttribute("tu")->setFileKey(sIn, "Tu");
tds->getAttribute("tl")->setFileKey(sIn, "Tl");
tds->getAttribute("hu")->setFileKey(sIn, "Hu");
tds->getAttribute("hl")->setFileKey(sIn, "Hl");
tds->getAttribute("l")->setFileKey(sIn, "L");
tds->getAttribute("kw")->setFileKey(sIn, "Kw");
// Generate the sample
TSampling *sampling = new TSampling(tds, "lhs", nS);
sampling->generateSample();
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
TAttribute * tyhat = new TAttribute("yhat");
tyhat->setDefaultValue(-200.0);
fout->addAttribute(tyhat);
// Create a TCode object
TCode *mycode = new TCode(tds, "flowrate -s -kf");
// Add the output file where to find the output attributes
// mycode->addInputFile(new TInputFile(sIn));
mycode->addOutputFile( fout );
// Create a TLauncher object from a TDataServer and a TCode objects
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
// lanceur->setClean();
lanceur->setVarDraw("hu:hl","yhat>0","");
// lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->run();
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowratestop",5,64,1270,667);
tds->draw("hu:hl","yhat>0");
tds->exportData("_flowrate_sampler_launcher_.dat");
}
The laws of distribution are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "Rw");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "key=value" format.
A design-of-experiments is then built with 300 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 300);
sampling->generateSample();
The output file with "values in rows" _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d are then linked to this
TOutputFileRow
output file. But here, only yhat will be
considered as variable of interest by Uranie.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-kf" option.
TCode *mycode = new TCode(tds, "flowrate -v -kf");
which indicates that flowrate code has to find input files with "key=value" format. Furthermore, the additional variables chu, chl and cr allow to check if flowrate is in failure or not. If it is in failure, the output file will not be produced.
Then the launcher is initialised with a TDataServer
and the code is executed.
TLauncher *lanceur = new TLauncher(tds, mycode);
The launcher will execute the flowrate -kf command for each of the 300 patterns with the
run
method.
lanceur->run();
The macro simulates 100 failures of flowrate.
--- Uranie v0.0/0 --- Developed with ROOT (6.32.02) Copyright (C) 2013-2024 CEA/DES Contact: support-uranie@cea.fr Date: Tue Jan 09, 2024 <URANIE::INFO> <URANIE::INFO> TLauncher "0x562bd21827e0" TCode "codetdsflowrate" with TDataServer "tdsflowrate" <URANIE::INFO> ** Save : Yes <URANIE::INFO> ** WorkingDirectory[${RUNNINGDIR}/URANIE] <URANIE::INFO> ** Proc : 1 <URANIE::INFO> <URANIE::INFO> time elapsed 1.97 sec <URANIE::INFO> Failure : 92/400 --- 23%
The objective of the macro is to evaluate the external code flowrate with failures on a design-of-experiments where input file
"flowrate_input_with_flags.in"
has"flags" and the output file
"_output_flowrate_withRow_.dat"
with type "values in rows". This flowrate
code is described in Section IV.1.2.3.1.1.
The creation of an input file containing some "flags" is motivated by the will to make evolve variables in an input file with no particular structure:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { 0.071623 19712.541454 } // values of Rw and R tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min 1051.972855 // value of Hu dt_max 805.249178 // value of Hl facsec 1000000. kW 11401.611060 // value of Kw information_Tu Champ_Uniforme 1 85927.853162 // value of Tu information_Tl Champ_Uniforme 1 85.803614 // value of Tl information_L { precision 1162.689830 // value of L } convergence { criterion relative_max_du_dt precision 1.e-6 } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
These values are then replaced by "flags" bounded with special characters.
The input file flowrate_input_with_flags.in
containing "flags" is built this way:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { @Rw@ @R@ } tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min @Hu@ dt_max @Hl@ facsec 1000000. kW @Kw@ information_Tu Champ_Uniforme 1 @Tu@ information_Tl Champ_Uniforme 1 @Tl@ information_L { precision @L@ } convergence { criterion relative_max_du_dt precision @Rw@ } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
This file defines the eight variables , , , , , , , and also the three additional variables chu, chl and cr needed to perform the execution of the command flowrate -kf.
The output file _output_flowrate_withRow_.dat
is of "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d
6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro.
{
Int_t nS = 300;
// Define the DataServer
TDataServer *tds = new TDataServer("tdsflowrate", "DataBase flowrate");
// Add the eight attributes of the study with uniform law
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
tds->addAttribute( new TUniformDistribution("r", 100.0, 50000.0));
tds->addAttribute( new TUniformDistribution("tu", 63070.0, 115600.0));
tds->addAttribute( new TUniformDistribution("tl", 63.1, 116.0));
tds->addAttribute( new TUniformDistribution("hu", 990.0, 1110.0));
tds->addAttribute( new TUniformDistribution("hl", 700.0, 820.0));
tds->addAttribute( new TUniformDistribution("l", 1120.0, 1680.0));
tds->addAttribute( new TUniformDistribution("kw", 9855.0, 12045.0));
// The input file
TString sFileName = TString("flowrate_input_with_flags.in");
// Set the input file with flag format and the flag for each input attributes
tds->getAttribute("rw")->setFileFlag(sFileName, "@Rw@");
tds->getAttribute("r")->setFileFlag(sFileName, "@R@");
tds->getAttribute("tu")->setFileFlag(sFileName, "@Tu@");
tds->getAttribute("tl")->setFileFlag(sFileName, "@Tl@");
tds->getAttribute("hu")->setFileFlag(sFileName, "@Hu@");
tds->getAttribute("hl")->setFileFlag(sFileName, "@Hl@");
tds->getAttribute("l")->setFileFlag(sFileName, "@L@");
tds->getAttribute("kw")->setFileFlag(sFileName, "@Kw@");
// Generate the sample
TSampling *sampling = new TSampling(tds, "lhs", 400);
sampling->generateSample();
// The output file of the code where values are stored in row
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
TAttribute * tyhat = new TAttribute("yhat");
tyhat->setDefaultValue(-200.0);
fout->addAttribute(tyhat);
// Create a TCode object
TCode *mycode = new TCode(tds, "flowrate -s -ff");
// Add the output file where to find the output attributes
mycode->addOutputFile( fout );
// Create a TLauncher object from a TDataServer and a TCode objects
TLauncher *tlch = new TLauncher(tds, mycode);
tlch->setSave();
// tlch->setClean();
tlch->setVarDraw("hu:hl","yhat>0","");
// tlch->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
tlch->run();
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateFlagFailure",5,64,1270,667);
tds->draw("hu:hl","yhat>0","");
tds->exportData("_flowrate_sampler_launcher_.dat");
}
The laws of distribution are set for each input variable. For example for the rw
variable, the macro creates an uniform distribution between bounds 0.05 and 0.15 associated to a
TAttribute
named "rw":
tds->addAttribute( new TUniformDistribution("rw", 0.05, 0.15));
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileFlag(TString("flowrate_input_with_flags.in"),"@Rw@");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "flags".
A design-of-experiments is then built with 300 samplings using the LHS method.
TSampling *sampling = new TSampling(tds, "lhs", 300);
sampling->generateSample();
The output file with "values in rows" type _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d are then linked to this
TOutputFileRow
output file. But here, only yhat will be
considered as a variable of interest by Uranie.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-ff" option.
TCode *mycode = new TCode(tds, "flowrate -ff");
which indicates that flowrate code has to find input files with "flags" format. Furthermore, the additional variables chu, chl and cr allow to check if flowrate is in failure or not. If it is in failure, the output file will not be produced.
Then the launcher is initialised with a TDataServer
and the code is executed.
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -ff command for each of the 300 patterns with the
run
method.
tlch->run();
The macro simulates 100 failures for flowrate.
--- Uranie v0.0/0 --- Developed with ROOT (6.32.02) Copyright (C) 2013-2024 CEA/DES Contact: support-uranie@cea.fr Date: Tue Jan 09, 2024 <URANIE::INFO> <URANIE::INFO> TLauncher "0x62e15d956660" TCode "codetdsflowrate" with TDataServer "tdsflowrate" <URANIE::INFO> ** Save : Yes <URANIE::INFO> ** WorkingDirectory[${RUNNINGDIR}/URANIE] <URANIE::INFO> ** Proc : 1 <URANIE::INFO> <URANIE::INFO> time elapsed 2.09 sec <URANIE::INFO> Failure : 100/400 --- 25%
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments generated by the
function PlanOATMinMax
where input file "flowrate_input_with_keys.in"
is with "key=value"
format and the output file "_output_flowrate_withRow_.dat"
is with "values in rows" type. This code is described in
Section IV.1.2.1. The function
PlanOATMinMax
consists in constructing a design around the nominal value for each
attribute, except for one attribute whose value is set to one of its boundaries(minimum and then maximum). Doing
this for the 8 input attributes and the central design, in which each attribute takes its nominal value leads to a
seventeen patterns design.
The input file for this code is flowrate_input_with_keys.in
of key = value
type. It looks like:
# # # INPUT FILE with KEYS for the "FLOWREATE" code # \date 2008-04-22 12:53:35 # date = 123456 ; ######################### ## ## exclude points ## chu = 1050; chl = 770; cr = 1100; ## ######################### ######################### ## ## parameters : 8 ## Rw = 0.0500 ; R = 33366.67 ; Tu = 63070.0 ; Tl = 116.00 ; Hu = 1110.00 ; Hl = 768.57; L = 1200.0 ; Kw = 11732.14 ; ## ######################### ######################### ## ## to simulate CPU time ## ## normal 1 : ## min 10000000 : 1.160u 0.000s 0:01.16 100.0% ## max 100000000 : 11.600u 0.010s 0:11.61 100.0% ## nLoop = 1; ## ######################### end = 6;
These files define the eight variables , , , , , , , needed to perform the execution of the command flowrate -k.
The output file _output_flowrate_withRow_.dat
is of "values in rows" type. It looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d are defined as output variables in the macro.
void PlanOATMinMax(TDataServer *tds)
{
// Create the data tuple
tds->createTuple();
Int_t natt = tds->getNAttributes();
// The number of attributes is incremented by one for the iterator
const Int_t nn = natt+1;
// Allocate the data vector to fill the tuple
Double_t value[nn];
// Init the iterator. It is always the first value.
value[0] = 0;
// Init the data vector with the nominal/mean values of attributes
for(Int_t i=0;i<natt;i++)
value[1+i] = tds->getAttribute(i)->getMean();
// Fill the nominal/mean values
tds->getTuple()->Fill(value);
// Loop on each attributes
for(Int_t i=0;i<natt;i++) {
// Case of min values
value[1+i] = tds->getAttribute(i)->getLowerBound();
value[0] += 1.0;
tds->getTuple()->Fill(value);
// Case of the max value
value[1+i] = tds->getAttribute(i)->getUpperBound();
value[0] += 1.0;
tds->getTuple()->Fill(value);
// Reset the nominal/mean value
value[1+i] = tds->getAttribute(i)->getMean();
}
}
void launchCodeFlowrateKeyOATMinMax()
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsOATMinMaxFlowrate", "OATMinMax Design of experiments for Flowrate");
// Add the study attributes ( min, max and nominal values)
tds->addAttribute( new TAttribute("rw", 0.05, 0.15));
tds->getAttribute("rw")->setMean(0.10);
tds->addAttribute( new TAttribute("r", 100.0, 50000.0));
tds->getAttribute("r")->setMean(25050.);
tds->addAttribute( new TAttribute("tu", 63070.0, 115600.0));
tds->getAttribute("tu")->setMean(89335.);
tds->addAttribute( new TAttribute("tl", 63.1, 116.0));
tds->getAttribute("tl")->setMean(89.55);
tds->addAttribute( new TAttribute("hu", 990.0, 1110.0));
tds->getAttribute("hu")->setMean(1050.);
tds->addAttribute( new TAttribute("hl", 700.0, 820.0));
tds->getAttribute("hl")->setMean(760.);
tds->addAttribute( new TAttribute("l", 1120.0, 1680.0));
tds->getAttribute("l")->setMean(1400.);
tds->addAttribute( new TAttribute("kw", 9855.0, 12045.0));
tds->getAttribute("kw")->setMean(10950.);
// The reference input file
TString sIn = gSystem->pwd();
sIn += TString("/flowrate_input_with_keys.in");
// Set the reference input file and the key for each input attributes
tds->getAttribute("rw")->setFileKey(sIn, "Rw");
tds->getAttribute("r")->setFileKey(sIn, "R");
tds->getAttribute("tu")->setFileKey(sIn, "Tu");
tds->getAttribute("tl")->setFileKey(sIn, "Tl");
tds->getAttribute("hu")->setFileKey(sIn, "Hu");
tds->getAttribute("hl")->setFileKey(sIn, "Hl");
tds->getAttribute("l")->setFileKey(sIn, "L");
tds->getAttribute("kw")->setFileKey(sIn, "Kw");
// Construit le plan OAT par avec les bornes (Min, Max) and the nominal values
PlanOATMinMax(tds);
// Scan the data ( 17 = 1 + 2*8 patterns)
tds->Scan("*","","colsize=5 col=3:4::6::4:3:4:");
// Save the Design of experiments in an ASCII file
tds->exportData("_flowrate_sampler_oat_.dat");
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -k");
// mycode->addInputFile( new TInputFile(sIn));
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *lanceur = new TLauncher(tds, mycode);
lanceur->setSave();
lanceur->setClean();
//lanceur->setWorkingDirectory(gSystem->Getenv("PWD") + TString("/tmpLanceurUranie/flowrate"));
lanceur->setVarDraw("yhat:rw","","");
lanceur->run();
tds->exportData("_flowrate_sampler_launcher_oat_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateOATMinMax",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1); tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,20.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
axis->AddRange(new TParallelCoordRange(axis,155.0,160.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
PlanOATMinMax
function builds the design-of-experiments from a TDataServer
: for the first design and for each
attribute of the TDataServer
, values of attributes are initialised with their means.
for(Int_t i=0 ; i<tds->getNAttributes(); i++)
value[1+i] = tds->getAttribute(i)->getMean();
These data are put in the TDataServer
,
tds->getTuple()->Fill(value)
this is how the central point is constructed. Two designs are then built for every attribute: one with the value of the attribute initialised to its lower boundary while other attributes are still initialised to their means:
value[1+i] = tds->getAttribute(i)->getLowerBound();
tds->getTuple()->Fill(value);
and the other where the value of the attribute is initialised to its upper boundary while other attributes are still initialised to their means:
value[1+i] = tds->getAttribute(i)->getUpperBound();
tds->getTuple()->Fill(value);
In the first part of the function launchCodeFlowrateKeyOATMinMax
, properties are set for each
input variable. For example for the rw variable, the macro creates a
TAttribute
named "rw" bounded by 0.05 and 0.15:
tds->addAttribute( new TAttribute("rw", 0.05, 0.15));
A initial mean value value is then set for this TAttribute, so as to inform the PlanOATMinMax
function.
tds->getAttribute("rw")->setMean(0.10);
Then, the TAttribute
is linked to the first input file with:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_keys.in"), "Rw");
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "key=value" format.
Then the design-of-experiments is generated by the PlanOATMinMax
function.
PlanOATMinMax(tds);
The output file with values in rows _output_flowrate_withRow_.dat
is instantiated as a
TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d are then linked to this
TOutputFileRow
output file. But here, only yhat will be
considered by Uranie as a variable of interest.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-k" option:
TCode *mycode = new TCode(tds, "flowrate -k");
in which the "-k" option indicates that flowrate code has to find input files with "key=value" format.
Then the launcher is initialised with a TDataServer
and the code is executed
TLauncher *tlch = new TLauncher(tds, mycode);
The launcher will execute the flowrate -k command for each of the seventeen patterns with the
run
method.
tlch->run();
The macro succeeded with no failure, using the following design-of-experiments;
Processing launchCodeFlowrateKeyOATMinMax.C... ****************************************************************************** * Row * tds * rw.r * r.r * tu.tu * tl.tl * hu.h * hl. * l.l * kw.kw * ****************************************************************************** * 0 * 0 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 1 * 1 * 0.05 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 2 * 2 * 0.15 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 3 * 3 * 0.1 * 100 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 4 * 4 * 0.1 * 50000 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 5 * 5 * 0.1 * 25050 * 63070 * 89.55 * 1050 * 760 * 1400 * 10950 * * 6 * 6 * 0.1 * 25050 * 115600 * 89.55 * 1050 * 760 * 1400 * 10950 * * 7 * 7 * 0.1 * 25050 * 89335 * 63.1 * 1050 * 760 * 1400 * 10950 * * 8 * 8 * 0.1 * 25050 * 89335 * 116 * 1050 * 760 * 1400 * 10950 * * 9 * 9 * 0.1 * 25050 * 89335 * 89.55 * 990 * 760 * 1400 * 10950 * * 10 * 10 * 0.1 * 25050 * 89335 * 89.55 * 1110 * 760 * 1400 * 10950 * * 11 * 11 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 700 * 1400 * 10950 * * 12 * 12 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 820 * 1400 * 10950 * * 13 * 13 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1120 * 10950 * * 14 * 14 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1680 * 10950 * * 15 * 15 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 9855 * * 16 * 16 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 12045 * ******************************************************************************
The objective of the macro is to evaluate the flowrate external code on a design-of-experiments generated by the
function PlanOATMinMax
where input file "flowrate_input_with_flags.in"
contains "flags" and
the output file "_output_flowrate_withRow_.dat"
is with "values in rows" type. This code is described in section
(Section IV.1.2.1). The function
PlanOATMinMax
consists in constructing a design around the nominal value for each
attribute, except for one attribute whose value is set to one of its boundaries(minimum and then maximum). Doing
this for the 8 input attributes and the central design, in which each attribute takes its nominal value leads to a
seventeen patterns design.
The input file for this code is flowrate_input_with_flags.in
with "flags" type. It looks like:
# # INPUT FILE with FLAG for the "FLOWREATE" code # \date 2008-04-22 12:55:17 # new Implicit_Steady_State sch { frottement_paroi { @Rw@ @R@ } tinit 0.0 tmax 1000000. nb_pas_dt_max 1500 dt_min @Hu@ dt_max @Hl@ facsec 1000000. kW @Kw@ information_Tu Champ_Uniforme 1 @Tu@ information_Tl Champ_Uniforme 1 @Tl@ information_L { precision @L@ } convergence { criterion relative_max_du_dt precision @Rw@ } stop_criterium { ch_abcsissa_hu 1050 ch_ordinate_hl 770 c_radius 1100 } Solveur Newton3 { max_iter_matrice 1 max_iter_implicite 1 date 5654321 seuil_convg_implicite 1.e-6 assemblage_implicite 10 solveur_lineaire BiCGS preconditionneur ILU seuil_resol_implicite 1.e-5 } }
These files define the eight variables , , , , , , , needed to perform the execution of the command flowrate -f.
The output file, _output_flowrate_withRow_.dat
when created, is of "values in rows" type. It
looks like:
#COLUMN_NAMES: yhat | d 6.757218e+01 4.092561e+03
yhat and d have to be defined as output variables in the macro.
void PlanOATMinMax(TDataServer *tds)
{
// Create the data tuple
tds->createTuple();
Int_t natt = tds->getNAttributes();
// The number of attributes is incremented by one for the iterator
const Int_t nn = natt+1;
// Allocate the data vector to fill the tuple
Double_t value[nn];
// Init the iterator. It is always the first value.
value[0] = 0;
// Init the data vector with the nominal/mean values of attributes
for(Int_t i=0;i<natt;i++)
value[1+i] = tds->getAttribute(i)->getMean();
// Fill the nominal/mean values : nominal pattern
tds->getTuple()->Fill(value);
// Loop on each attributes
for(Int_t i=0;i<natt;i++) {
// Case of min values
value[1+i] = tds->getAttribute(i)->getLowerBound();
value[0] += 1.0;
// Fill the min value value for xi attribute and nominal values for other attributes
tds->getTuple()->Fill(value);
// Case of the max value
value[1+i] = tds->getAttribute(i)->getUpperBound();
value[0] += 1.0;
// Fill the max value value for xi attribute and nominal values for other attributes
tds->getTuple()->Fill(value);
// Reset the nominal/mean value
value[1+i] = tds->getAttribute(i)->getMean();
}
}
void launchCodeFlowrateFlagOATMinMax()
{
// Define the DataServer
TDataServer *tds = new TDataServer("tdsOATMinMaxFlowrateFlag", "OATMinMax Design of experiments for Flowrate");
// Add the eight attributes of the study with min, max and nominal values
tds->addAttribute( new TAttribute("rw", 0.05, 0.15));
tds->getAttribute("rw")->setMean(0.10);
tds->addAttribute( new TAttribute("r", 100.0, 50000.0));
tds->getAttribute("r")->setMean(25050.);
tds->addAttribute( new TAttribute("tu", 63070.0, 115600.0));
tds->getAttribute("tu")->setMean(89335.);
tds->addAttribute( new TAttribute("tl", 63.1, 116.0));
tds->getAttribute("tl")->setMean(89.55);
tds->addAttribute( new TAttribute("hu", 990.0, 1110.0));
tds->getAttribute("hu")->setMean(1050.);
tds->addAttribute( new TAttribute("hl", 700.0, 820.0));
tds->getAttribute("hl")->setMean(760.);
tds->addAttribute( new TAttribute("l", 1120.0, 1680.0));
tds->getAttribute("l")->setMean(1400.);
tds->addAttribute( new TAttribute("kw", 9855.0, 12045.0));
tds->getAttribute("kw")->setMean(10950.);
// The input file
TString sFileName = TString("flowrate_input_with_flags.in");
// Set the input file with flag format and the flag for each input attributes
tds->getAttribute("rw")->setFileFlag(sFileName, "@Rw@");
tds->getAttribute("r")->setFileFlag(sFileName, "@R@");
tds->getAttribute("tu")->setFileFlag(sFileName, "@Tu@");
tds->getAttribute("tl")->setFileFlag(sFileName, "@Tl@");
tds->getAttribute("hu")->setFileFlag(sFileName, "@Hu@");
tds->getAttribute("hl")->setFileFlag(sFileName, "@Hl@");
tds->getAttribute("l")->setFileFlag(sFileName, "@L@");
tds->getAttribute("kw")->setFileFlag(sFileName, "@Kw@");
// Build the Design of Experiments (DoE)
PlanOATMinMax(tds);
// Scan the data ( 17 = 1 + 2*8 patterns)
tds->Scan("*","","colsize=5 col=3:4::6::4:3:4:");
// Save the Design of experiments in an ASCII file
tds->exportData("_flowrate_sampler_oat_.dat");
// The output file of the code
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
// The attribute in the output file
fout->addAttribute(new TAttribute("yhat"));
// Instanciation de mon code
TCode *mycode = new TCode(tds, "flowrate -s -f");
//mycode->setLog();
// on ajoute le fichier de sortie du code
mycode->addOutputFile( fout );
// Lancement du code
TLauncher *tlch = new TLauncher(tds, mycode);
tlch->setSave();
tlch->setClean();
tlch->setDrawProgressBar(kFALSE);
tlch->setVarDraw("yhat:rw","","");
tlch->run();
tds->exportData("_flowrate_sampler_launcher_oat_.dat");
// Visualisation
TCanvas *Canvas = new TCanvas("c1", "Graph for the Macro launchCodeFlowrateFlagOATMinMax",5,64,1270,667);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw();
gStyle->SetPalette(1);
pad->Divide(2, 2);
pad->cd(1);
tds->draw("yhat:rw");
pad->cd(3); tds->draw("yhat");
pad->cd(2); tds->draw("yhat:rw","","colz");
pad->cd(4);
// The parallel plot
tds->draw("rw:r:tu:tl:hu:hl:l:kw:yhat","","para");
TParallelCoord* para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
// The output attribute
TParallelCoordVar* axis = (TParallelCoordVar*)para->GetVarList()->FindObject("yhat");
axis->AddRange(new TParallelCoordRange(axis,15.0,20.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
axis->AddRange(new TParallelCoordRange(axis,155.0,160.0));
para->AddSelection("blue");
para->GetCurrentSelection()->SetLineColor(kBlue);
}
PlanOATMinMax
function builds the design-of-experiments from a TDataServer
: for the first design and for each
attribute of the TDataServer
, values of attributes are initialised with their means.
for(Int_t i=0 ; i<natt ; i++)
value[1+i] = tds->getAttribute(i)->getMean();
These data are put in the TDataServer
,
tds->getTuple()->Fill(value)
this is how the central point is constructed. Two designs are then built for every attribute: one with the value of the attribute initialised to its lower boundary while other attributes are still initialised to their means:
value[1+i] = tds->getAttribute(i)->getLowerBound();
tds->getTuple()->Fill(value);
and the other where the value of the attribute is initialised to its upper boundary while other attributes are still initialised to their means:
value[1+i] = tds->getAttribute(i)->getUpperBound();
tds->getTuple()->Fill(value);
In the first part of the function launchCodeFlowrateFlagOATMinMax
, properties are set for each
input variable. For example for the Rw variable, the macro creates a
TAttribute
named "rw" bounded by 0.05 and 0.15:
tds->addAttribute( new TAttribute("rw", 0.05, 0.15));
An initial mean value is then set for this TAttribute
, so as to inform the
PlanOATMinMax
function.
tds->getAttribute("rw")->setMean(0.10);
Then, the TAttribute
is linked to the input file with:
tds->getAttribute("rw")->setFileFlag(TString("flowrate_input_with_flags.in"), "@Rw@");
which is the same thing as writing:
tds->getAttribute("rw")->setFileKey(TString("flowrate_input_with_flags.in"), "@Rw@","",TAttributeFileKey::kFlag);
which will be understood by Uranie as the fact the rw variable has to be read in an input file with "flags" format.
Then the design-of-experiments is generated by the PlanOATMinMax
function.
PlanOATMinMax(tds);
We want the output file to be with values in rows. So the output file
_output_flowrate_withRow_.dat
is set as a TOutputFileRow
.
TOutputFileRow *fout = new TOutputFileRow("_output_flowrate_withRow_.dat");
The variable yhat and d could then be linked to
this TOutputFileRow
output file. But here, only yhat will
be considered.
fout->addAttribute("yhat");
We set the code as being the flowrate execution with "-f" option:
TCode *mycode = new TCode(tds, "flowrate -f");
in which the "-f" option indicates that flowrate code has to find input files with "flags" format.
The launcher will execute the flowrate -f command for each of the seventeen patterns. One sampling corresponds to one input file created by the launcher.
Then the launcher is initialised and launched with the run
method
TLauncher *tlch = new TLauncher(tds, mycode);
tlch->run();
The macro succeeded with no failure, using the following design-of-experiments:
Processing launchCodeFlowrateFlagOATMinMax.C... ****************************************************************************** * Row * tds * rw.r * r.r * tu.tu * tl.tl * hu.h * hl. * l.l * kw.kw * ****************************************************************************** * 0 * 0 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 1 * 1 * 0.05 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 2 * 2 * 0.15 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 3 * 3 * 0.1 * 100 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 4 * 4 * 0.1 * 50000 * 89335 * 89.55 * 1050 * 760 * 1400 * 10950 * * 5 * 5 * 0.1 * 25050 * 63070 * 89.55 * 1050 * 760 * 1400 * 10950 * * 6 * 6 * 0.1 * 25050 * 115600 * 89.55 * 1050 * 760 * 1400 * 10950 * * 7 * 7 * 0.1 * 25050 * 89335 * 63.1 * 1050 * 760 * 1400 * 10950 * * 8 * 8 * 0.1 * 25050 * 89335 * 116 * 1050 * 760 * 1400 * 10950 * * 9 * 9 * 0.1 * 25050 * 89335 * 89.55 * 990 * 760 * 1400 * 10950 * * 10 * 10 * 0.1 * 25050 * 89335 * 89.55 * 1110 * 760 * 1400 * 10950 * * 11 * 11 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 700 * 1400 * 10950 * * 12 * 12 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 820 * 1400 * 10950 * * 13 * 13 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1120 * 10950 * * 14 * 14 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1680 * 10950 * * 15 * 15 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 9855 * * 16 * 16 * 0.1 * 25050 * 89335 * 89.55 * 1050 * 760 * 1400 * 12045 * ******************************************************************************
Warning
The levele command will be install on your machine only if a Fortran compiler has been found
The objective of this macro is to launch a code that will produce several numerical values for at least one
attribute, when only once computation is performed. To do so, the levele use-case code will
be used. It is a code that computes the dose emitted by radioactive sources, as a function of time, given a set of
twelve input parameters. It provides three possible output formats, the one under consideration being here the
Column one, corresponding to the TOutputFileColumn
class. Here is an
example of the output:
20000.00 30000.00 40000.00 50000.00 60000.00 70000.00 80000.00 90000.00 100000.0 200000.0 300000.0 400000.0 500000.0 600000.0 700000.0 800000.0 900000.0 1000000. 2000000. 3000000. 4000000. 5000000. 6000000. 7000000. 8000000. 9000000. 0.9223239E-37 0.4206201E-32 0.5129892E-29 0.9733449E-27 0.6020410E-25 0.1766700E-23 0.3050058E-22 0.3543269E-21 0.3028644E-20 0.1192590E-14 0.6677703E-12 0.2881550E-10 0.3190472E-09 0.1532743E-08 0.4212096E-08 0.7793285E-08 0.1077026E-07 0.1192316E-07 0.1117317E-09 -0.9543977E-12 0.1073334E-19 0.2311560E-19 0.3043276E-19 0.3529515E-19 0.4011028E-19 0.4548453E-19 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.1401298E-44 0.1261169E-42 0.9172900E-41 0.1422271E-29 0.4459172E-24 0.8303329E-21 0.1017911E-18 0.2349300E-17 0.1774175E-16 0.6073529E-16 0.1159985E-15 0.1421619E-15 0.1248398E-19 0.9108749E-24 0.1152050E-39 0.5343305E-39 0.9261532E-39 0.1245747E-38 0.1608835E-38 0.2068842E-38
{
// OS abstraction
string which_levele =
string(gSystem->GetBuildArch()) == "win64" ? "where levele" : "which levele";
//Exit if levele not found
if(gSystem->Exec(which_levele.c_str()))
exit(-1);
//Create DataServer and add input attributes
TDataServer *tds1 = new TDataServer("tds1", "levelE usecase");
tds1->addAttribute( new TUniformDistribution("t",100,1000) );
tds1->addAttribute( new TLogUniformDistribution("kl",0.001,0.01) );
tds1->addAttribute( new TLogUniformDistribution("kc",0.000001,0.00001) );
tds1->addAttribute( new TLogUniformDistribution("v1",0.001,0.1) );
tds1->addAttribute( new TUniformDistribution("l1",100,500) );
tds1->addAttribute( new TUniformDistribution("r1",1,5) );
tds1->addAttribute( new TUniformDistribution("rc1",3,30) );
tds1->addAttribute( new TLogUniformDistribution("v2",0.01,0.1) );
tds1->addAttribute( new TUniformDistribution("l2",50,200) );
tds1->addAttribute( new TUniformDistribution("r2",1,5) );
tds1->addAttribute( new TUniformDistribution("rc2",3,30) );
tds1->addAttribute( new TLogUniformDistribution("w",100000,10000000) );
//Tell the code where to find attribute value in input file
TString sJDD = "levelE_input_with_values_rows.in";
tds1->getAttribute("t")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("kl")->setFileKey(sJDD,"", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("kc")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("v1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("l1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("r1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("rc1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("v2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("l2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("r2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("rc2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("w")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
// Create DOE
Int_t ns = 100;
TSampling *samp = new TSampling(tds1, "lhs", ns);
samp->generateSample();
//How to read ouput files
TOutputFileColumn *_fout = new URANIE::Launcher::TOutputFileColumn("_output_levelE_withColumn_.dat");
_fout->addAttribute(new TAttribute("tps",TAttribute::kVector));
_fout->addAttribute(new TAttribute("y",TAttribute::kVector));
_fout->addAttribute(new TAttribute("z",TAttribute::kVector));
//Creation of TCode
TCode *tc1 = new URANIE::Launcher::TCode(tds1, "levele 2> /dev/null");
tc1->addOutputFile( _fout );
//Run the code
TLauncher *tl1 = new URANIE::Launcher::TLauncher(tds1, tc1);
tl1->run();
//Draw the results
TCanvas *Can = new TCanvas("Can","Can",1);
Can->SetGrid(); Can->SetLogx();
double mean[26], stand[26];
tds1->computeStatistic("y");
for(unsigned int i=0; i<26; i++)
{
mean[i] = tds1->getAttribute("y")->getMean(i);
stand[i] = tds1->getAttribute("y")->getStd(i);
}
double tps[26]={20000,30000,40000,50000,60000,70000,80000,90000,100000, 200000,300000,400000,500000,600000,700000,800000,900000, 1e+06,2e+06,3e+06,4e+06,5e+06,6e+06,7e+06,8e+06,9e+06};
TGraphErrors *gr = new TGraphErrors(26,tps,mean,0,stand);
gr->Draw("A*");
gr->SetTitle("");
gr->GetXaxis()->SetTitle("Time"); gr->GetYaxis()->SetTitle("<y>");
}
The levele external code is located in the bin directory.
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. The only noticeable (and compulsory) thing to do is to change the default type of the attribute read at the end of the job. This is done in this line:
_fout->addAttribute(new URANIE::DataServer::TAttribute("y", TAttribute::kVector));
where the output attribute is provided, changing its nature to a vector, thanks to the second argument of the
TAttribute
constructor from the default (kReal
) to the desired
nature (kVector
). Once this is done, this information is broadcast internally to the code
that knows how to deal with this type of attribute.
The results of the previous macro is shown in Figure XIV.35, that displays the average of the hundred dose curve, over the time.
Warning
The levele command will be installed on your machine only if a Fortran compiler is found
The objective of this macro is to launch a code that will produce several numerical values for at least one
attribute, when only once computation is performed. To do so, the levele use-case code will
be used. It is a code that compute the dose emitted by radioactive sources, as a function of time, given a set of
twelve inputs parameters. It provides three possible output formats, the one under consideration being here the
Row one, corresponding to the TOutputFileRow
class. Here is an
example of the output:
#COLUMN_NAMES: tps | y | z 20000.00 0.9223239E-37 0.000000 30000.00 0.4206201E-32 0.000000 40000.00 0.5129892E-29 0.000000 50000.00 0.9733449E-27 0.000000 60000.00 0.6020410E-25 0.000000 70000.00 0.1766700E-23 0.000000 80000.00 0.3050058E-22 0.1401298E-44 90000.00 0.3543269E-21 0.1261169E-42 100000.0 0.3028644E-20 0.9172900E-41 200000.0 0.1192590E-14 0.1422271E-29 300000.0 0.6677703E-12 0.4459172E-24 400000.0 0.2881550E-10 0.8303329E-21 500000.0 0.3190472E-09 0.1017911E-18 600000.0 0.1532743E-08 0.2349300E-17 700000.0 0.4212096E-08 0.1774175E-16 800000.0 0.7793285E-08 0.6073529E-16 900000.0 0.1077026E-07 0.1159985E-15 1000000. 0.1192316E-07 0.1421619E-15 2000000. 0.1117317E-09 0.1248398E-19 3000000. -0.9543977E-12 0.9108749E-24 4000000. 0.1073334E-19 0.1152050E-39 5000000. 0.2311560E-19 0.5343305E-39 6000000. 0.3043276E-19 0.9261532E-39 7000000. 0.3529515E-19 0.1245747E-38 8000000. 0.4011028E-19 0.1608835E-38 9000000. 0.4548453E-19 0.2068842E-38
{
// OS abstraction
string which_levele =
string(gSystem->GetBuildArch()) == "win64" ? "where levele" : "which levele";
//Exit if levele not found
if(gSystem->Exec(which_levele.c_str()))
exit(-1);
//Create DataServer and add input attributes
TDataServer *tds1 = new TDataServer("tds1", "levelE usecase");
tds1->addAttribute( new TUniformDistribution("t",100,1000) );
tds1->addAttribute( new TLogUniformDistribution("kl",0.001,0.01) );
tds1->addAttribute( new TLogUniformDistribution("kc",0.000001,0.00001) );
tds1->addAttribute( new TLogUniformDistribution("v1",0.001,0.1) );
tds1->addAttribute( new TUniformDistribution("l1",100,500) );
tds1->addAttribute( new TUniformDistribution("r1",1,5) );
tds1->addAttribute( new TUniformDistribution("rc1",3,30) );
tds1->addAttribute( new TLogUniformDistribution("v2",0.01,0.1) );
tds1->addAttribute( new TUniformDistribution("l2",50,200) );
tds1->addAttribute( new TUniformDistribution("r2",1,5) );
tds1->addAttribute( new TUniformDistribution("rc2",3,30) );
tds1->addAttribute( new TLogUniformDistribution("w",100000,10000000) );
//Tell the code where to find attribute value in input file
TString sJDD = "levelE_input_with_values_rows.in";
tds1->getAttribute("t")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("kl")->setFileKey(sJDD,"", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("kc")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("v1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("l1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("r1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("rc1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("v2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("l2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("r2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("rc2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("w")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
// Create DOE
Int_t ns = 100;
TSampling *samp = new TSampling(tds1, "lhs", ns);
samp->generateSample();
//How to read ouput files
TOutputFileRow *_fout = new URANIE::Launcher::TOutputFileRow("_output_levelE_withRow_.dat");
_fout->addAttribute(new TAttribute("tps",TAttribute::kVector));
_fout->addAttribute(new TAttribute("y",TAttribute::kVector));
_fout->addAttribute(new TAttribute("z",TAttribute::kVector));
//Creation of TCode
TCode *tc1 = new URANIE::Launcher::TCode(tds1, "levele 2> /dev/null");
tc1->addOutputFile( _fout );
//Run the code
TLauncher *tl1 = new URANIE::Launcher::TLauncher(tds1, tc1);
tl1->run();
//Draw the results
TCanvas *Can = new TCanvas("Can","Can",1);
Can->SetGrid(); Can->SetLogx();
double mean[26], stand[26];
tds1->computeStatistic("y");
for(unsigned int i=0; i<26; i++)
{
mean[i] = tds1->getAttribute("y")->getMean(i);
stand[i] = tds1->getAttribute("y")->getStd(i);
}
double tps[26]={20000,30000,40000,50000,60000,70000,80000,90000,100000, 200000,300000,400000,500000,600000,700000,800000,900000, 1e+06,2e+06,3e+06,4e+06,5e+06,6e+06,7e+06,8e+06,9e+06};
TGraphErrors *gr = new TGraphErrors(26,tps,mean,0,stand);
gr->Draw("A*");
gr->SetTitle("");
gr->GetXaxis()->SetTitle("Time"); gr->GetYaxis()->SetTitle("<y>");
}
The levele external code is located in the bin directory.
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. The only noticeable (and compulsory) thing to do is to change the default type of the attribute read at the end of the job. This is done in this line:
_fout->addAttribute(new URANIE::DataServer::TAttribute("y", TAttribute::kVector));
where the output attribute is provided, changing its nature to a vector, thanks to the second argument of the
TAttribute
constructor from the default (kReal
) to the desired
nature (kVector
). Once this is done, this information is broadcast internally to the code
that knows how to deal with this type of attribute.
The results of the previous macro is shown in Figure XIV.36, that displays the average of the hundred dose curve, over the time.
Warning
The levele command will be installed on your machine only if a Fortran compiler is found
The objective of this macro is to launch a code that will produce several numerical values for at least one
attribute, when only once computation is performed. To do so, the levele use-case code will
be used. It is a code that compute the dose emitted by radioactive sources, as a function of time, given a set of
twelve inputs parameters. It provides three possible output formats, the one under consideration being here the
Key one, corresponding to the TOutputFileKey
class. Here is an
example of the output:
time = 20000.00 y = 0.9223239E-37 z = 0.000000 time = 30000.00 y = 0.4206201E-32 z = 0.000000 time = 40000.00 y = 0.5129892E-29 z = 0.000000 time = 50000.00 y = 0.9733449E-27 z = 0.000000 time = 60000.00 y = 0.6020410E-25 z = 0.000000 time = 70000.00 y = 0.1766700E-23 z = 0.000000 time = 80000.00 y = 0.3050058E-22 z = 0.1401298E-44 time = 90000.00 y = 0.3543269E-21 z = 0.1261169E-42 time = 100000.0 y = 0.3028644E-20 z = 0.9172900E-41 time = 200000.0 y = 0.1192590E-14 z = 0.1422271E-29 time = 300000.0 y = 0.6677703E-12 z = 0.4459172E-24 time = 400000.0 y = 0.2881550E-10 z = 0.8303329E-21 time = 500000.0 y = 0.3190472E-09 z = 0.1017911E-18 time = 600000.0 y = 0.1532743E-08 z = 0.2349300E-17 time = 700000.0 y = 0.4212096E-08 z = 0.1774175E-16 time = 800000.0 y = 0.7793285E-08 z = 0.6073529E-16 time = 900000.0 y = 0.1077026E-07 z = 0.1159985E-15 time = 1000000. y = 0.1192316E-07 z = 0.1421619E-15 time = 2000000. y = 0.1117317E-09 z = 0.1248398E-19 time = 3000000. y = -0.9543977E-12 z = 0.9108749E-24 time = 4000000. y = 0.1073334E-19 z = 0.1152050E-39 time = 5000000. y = 0.2311560E-19 z = 0.5343305E-39 time = 6000000. y = 0.3043276E-19 z = 0.9261532E-39 time = 7000000. y = 0.3529515E-19 z = 0.1245747E-38 time = 8000000. y = 0.4011028E-19 z = 0.1608835E-38 time = 9000000. y = 0.4548453E-19 z = 0.2068842E-38
{
// OS abstraction
string which_levele =
string(gSystem->GetBuildArch()) == "win64" ? "where levele" : "which levele";
//Exit if levele not found
if(gSystem->Exec(which_levele.c_str()))
exit(-1);
//Create DataServer and add input attributes
TDataServer *tds1 = new TDataServer("tds1", "levelE usecase");
tds1->addAttribute( new TUniformDistribution("t",100,1000) );
tds1->addAttribute( new TLogUniformDistribution("kl",0.001,0.01) );
tds1->addAttribute( new TLogUniformDistribution("kc",0.000001,0.00001) );
tds1->addAttribute( new TLogUniformDistribution("v1",0.001,0.1) );
tds1->addAttribute( new TUniformDistribution("l1",100,500) );
tds1->addAttribute( new TUniformDistribution("r1",1,5) );
tds1->addAttribute( new TUniformDistribution("rc1",3,30) );
tds1->addAttribute( new TLogUniformDistribution("v2",0.01,0.1) );
tds1->addAttribute( new TUniformDistribution("l2",50,200) );
tds1->addAttribute( new TUniformDistribution("r2",1,5) );
tds1->addAttribute( new TUniformDistribution("rc2",3,30) );
tds1->addAttribute( new TLogUniformDistribution("w",100000,10000000) );
//Tell the code where to find attribute value in input file
TString sJDD = "levelE_input_with_values_rows.in";
tds1->getAttribute("t")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("kl")->setFileKey(sJDD,"", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("kc")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("v1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("l1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("r1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("rc1")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("v2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("l2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("r2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("rc2")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
tds1->getAttribute("w")->setFileKey(sJDD, "", "%e",TAttributeFileKey::kNewRow);
// Create DOE
Int_t ns = 100;
TSampling *samp = new TSampling(tds1, "lhs", ns);
samp->generateSample();
//How to read ouput files
TOutputFileKey *_fout = new URANIE::Launcher::TOutputFileKey("_output_levelE_withKey_.dat");
_fout->addAttribute(new TAttribute("tps",TAttribute::kVector));
_fout->addAttribute(new TAttribute("y",TAttribute::kVector));
_fout->addAttribute(new TAttribute("z",TAttribute::kVector));
//Creation of TCode
TCode *tc1 = new URANIE::Launcher::TCode(tds1, "levele 2> /dev/null");
tc1->addOutputFile( _fout );
//Run the code
TLauncher *tl1 = new URANIE::Launcher::TLauncher(tds1, tc1);
tl1->run();
//Draw the results
TCanvas *Can = new TCanvas("Can","Can",1);
Can->SetGrid(); Can->SetLogx();
double mean[26], stand[26];
tds1->computeStatistic("y");
for(unsigned int i=0; i<26; i++)
{
mean[i] = tds1->getAttribute("y")->getMean(i);
stand[i] = tds1->getAttribute("y")->getStd(i);
}
double tps[26]={20000,30000,40000,50000,60000,70000,80000,90000,100000, 200000,300000,400000,500000,600000,700000,800000,900000, 1e+06,2e+06,3e+06,4e+06,5e+06,6e+06,7e+06,8e+06,9e+06};
TGraphErrors *gr = new TGraphErrors(26,tps,mean,0,stand);
gr->Draw("A*");
gr->SetTitle("");
gr->GetXaxis()->SetTitle("Time"); gr->GetYaxis()->SetTitle("<y>");
}
The levele external code is located in the bin directory.
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. The only noticeable (and compulsory) thing to do is to change the default type of the attribute read at the end of the job. This is done in this line:
_fout->addAttribute(new URANIE::DataServer::TAttribute("y", TAttribute::kVector));
where the output attribute is provided, changing its nature to a vector, thanks to the second argument of the
TAttribute
constructor from the default (kReal
) to the desired
nature (kVector
). Once this is done, this information is broadcast internally to the code
that knows how to deal with this type of attribute.
The results of the previous macro is shown in Figure XIV.37, that displays the average of the hundred dose curve, over the time.
In order to test the possibility of reading vectors and strings (for jobs that produce those kind of results) but also to re-write them in files when they are requested by a code (as an input) the multitype code has been created. It is just a dummy piece of code that generates outputs containing vectors and strings along with double-precision results, and re-read them to use the information contained and produce a new flat result.
Special flags have been added to the multitype code aiming to produce an output containing:
2 words: w1 and w2, at first and last position, drawn randomly from a list that goes from "zero" to "nine".
2 vectors: v1 and v2, at second and third position, filled with and , doubles that follow two different gaussian drawings. These number and are drawn randomly between 1 and 15 and might then changed from one event to another.
1 float, f1, at fourth position, drawn following a gaussian.
The code can produce different kind of output files depending on the way it is called:
multitype -mtKey
: produces 2 output files (_output_multitype_mt_Key_.dat
and_output_multitype_mt_Key_condensate_.dat
) written in Key formatmultitype -mtRow
: produces an output file (_output_multitype_mt_Row_.dat
) written in Row formatmultitype -mtCol
: produces an output file (_output_multitype_mt_Column_.dat
) written in Column formatmultitype -mtDS
: produces an output file (_output_multitype_mt_DataServer_.dat
) written in DataServer formatmultitype -mtXML
: produces an output file (_output_multitype_mt_.xml
) written in XML format
The code uses an input file called "multitype_input.dat
" containing a single double that
corresponds to the seed used to generate the outputs. This is the only attribute needed when this
-mt option is used for multitype.
Another special flag has been added to the multitype code aiming to analyse the output of the step described previously. The idea is to check that vectors and strings are read and replaced carefully as input for the new operation which produces two double-precision outputs: thev1 and thev2. Their values is set to 987654321 by default and when the code is run the idea is:
- to recover the word w1 and the vector v1.
- to get the number that corresponds to the words w1 ("two" == 2).
- to associate thev1 to the w1-Th value of the vector v1 if it exists (and set it to -123456789 otherwise).
This procedure being repeated for w2 and v2 as well.
The code can produce different kinds of output files, from different input files, depending on the way it is called:
multitype -ReadmtKey
: produces an output files (_output_multitype_readmt_Key_.dat
) by reading the input variable in_output_multitype_mt_Key_condensate_.dat
).multitype -ReadmtRow
: produces an output file (_output_multitype_readmt_Row_.dat
) by reading the input variable in_output_multitype_mt_Row_.dat
).multitype -ReadmtCol
: produces an output file (_output_multitype_readmt_Column_.dat
) by reading the input variable in_output_multitype_mt_Column_.dat
).multitype -ReadmtDS
: produces an output file (_output_multitype_readmt_DataServer_.dat
) by reading the input variable in_output_multitype_mt_DataServer_.dat
).multitype -ReadmtXML
: produces an output file (_output_multitype_readmt_.xml
) by reading the input variable in_output_multitype_mt_.xml
).
The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Section XIV.4.22.1, with a Key format, obtained by doing:
multitype -mtKey
The resulting output file, named _output_multitype_mt_Key_.dat
looks like:
w1 = nine v1 = -0.512095 v1 = 0.039669 v1 = -1.3834 v1 = 1.37667 v1 = 0.220672 v1 = 0.633267 v1 = 1.37027 v1 = -0.765636 v2 = 14.1981 v2 = 14.0855 v2 = 10.7848 v2 = 9.45476 v2 = 9.17308 v2 = 6.60804 v2 = 10.0711 v2 = 14.1761 v2 = 10.318 v2 = 12.5095 v2 = 15.6614 v2 = 10.3452 v2 = 9.41101 v2 = 7.47887 f1 = 32.2723 w2 = eight
{
//Create dataserver with the seed attribute
TDataServer *tds = new TDataServer("foo","pouet");
tds->addAttribute( new TUniformDistribution("seed",0,100000));
tds->getAttribute("seed")->setFileKey("multitype_input.dat","", "%e",TAttributeFileKey::kNewRow);
//Create DOE
TSampling *tsam = new TSampling(tds,"lhs",100);
tsam->generateSample();
//Precise output and create Code
TOutputFileKey *out = new TOutputFileKey("_output_multitype_mt_Key_.dat");
out->addAttribute(new TAttribute("w1",TAttribute::kString));
out->addAttribute(new TAttribute("w2",TAttribute::kString));
out->addAttribute(new TAttribute("v1",TAttribute::kVector));
out->addAttribute(new TAttribute("v2",TAttribute::kVector));
out->addAttribute(new TAttribute("f1"));
TCode *myc = new URANIE::Launcher::TCode(tds, "multitype -mtKey");
myc->addOutputFile( out );
//Create TLauncher and run it
TLauncher *tlau = new URANIE::Launcher::TLauncher(tds, myc);
tlau->run();
//Produce control plot
TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw(); pad->cd();
tds->drawPairs("w1:v1:v2:f1:w2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created with a simple input (the seed) drawn as an uniform distribution. The design-of-experiments is generated and
the TOutputFileKey
is created and filled with new attributes. This is the important part,
where nature of the attributes are precised:
TOutputFileKey *out = new TOutputFileKey("_output_multitype_mt_Key_.dat");
out->addAttribute(new URANIE::DataServer::TAttribute("w1",TAttribute::kString));
out->addAttribute(new URANIE::DataServer::TAttribute("w2",TAttribute::kString));
out->addAttribute(new URANIE::DataServer::TAttribute("v1",TAttribute::kVector));
out->addAttribute(new URANIE::DataServer::TAttribute("v2",TAttribute::kVector));
out->addAttribute(new URANIE::DataServer::TAttribute("f1"));
The rest is very common and a pair plot is performed to check that the reading of the output went well (see following plot).
The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Section XIV.4.22.1, with a Key format, obtained by doing:
multitype -mtKey
The resulting output file, named _output_multitype_mt_Key_condensate_.dat
looks like:
w1 = nine v1 = [ -0.512095,0.039669,-1.3834,1.37667,0.220672,0.633267,1.37027,-0.765636 ] v2 = [ 14.1981,14.0855,10.7848,9.45476,9.17308,6.60804,10.0711,14.1761,10.318,12.5095,15.6614,10.3452,9.41101,7.47887 ] f1 = 32.2723 w2 = eight
It is a much more readable format than the previously defined one. Note that the vector-values are comma-separated without blanks. This has been discussed in Section IV.3.1.1 and is compulsory because of the way the files (in the Launcher module) are read.
{
//Create dataserver with the seed attribute
TDataServer *tds = new TDataServer("foo","pouet");
tds->addAttribute( new TUniformDistribution("seed",0,100000));
tds->getAttribute("seed")->setFileKey("multitype_input.dat","", "%e",TAttributeFileKey::kNewRow);
//Create DOE
TSampling *tsam = new TSampling(tds,"lhs",100);
tsam->generateSample();
//Precise output and create Code
TOutputFileKey *out = new TOutputFileKey("_output_multitype_mt_Key_condensate_.dat");
out->addAttribute(new TAttribute("w1",TAttribute::kString));
out->addAttribute(new TAttribute("w2",TAttribute::kString));
out->addAttribute(new TAttribute("v1",TAttribute::kVector));
out->addAttribute(new TAttribute("v2",TAttribute::kVector));
out->addAttribute(new TAttribute("f1"));
//Specify that the output will be separated by commas and that [ and ] have to be considered as separator (== ignored)
out->setVectorProperties("[",",","]");
TCode *myc = new URANIE::Launcher::TCode(tds, "multitype -mtKey");
myc->addOutputFile( out );
//Create TLauncher and run it
TLauncher *tlau = new URANIE::Launcher::TLauncher(tds, myc);
tlau->run();
//Produce control plot
TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw(); pad->cd();
tds->drawPairs("w1:v1:v2:f1:w2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. Actually it is the exact same code as in Section XIV.4.24, up to this line:
//Specify that the output will be separated by commas and that [ and ] have to be considered as separator (== ignored)
out->setVectorProperties("[",",","]");
Thanks to this line, the output file parser will know that all vector values have to be read at once, and it will know how to separate them. This is the line to modify in order to go from key format describe in Section XIV.4.24 to a condensate one. The rest is very common and a pair plot is performed to check that the reading of the output went well (see following plot).
The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Section XIV.4.22.1, with a DataServer format, obtained by doing:
multitype -mtDS
The resulting output file, named _output_multitype_mt_DataServer_.dat
looks like:
#COLUMN_NAMES: w1|v1|v2|f1|w2 #COLUMN_TYPES: S|V|V|D|S nine -0.512095,0.039669,-1.3834,1.37667,0.220672,0.633267,1.37027,-0.765636 14.1981,14.0855,10.7848,9.45476,9.17308,6.60804,10.0711,14.1761,10.318,12.5095,15.6614,10.3452,9.41101,7.47887 32.2723 eight
{
//Create dataserver with the seed attribute
TDataServer *tds = new TDataServer("foo","pouet");
tds->addAttribute( new TUniformDistribution("seed",0,100000));
tds->getAttribute("seed")->setFileKey("multitype_input.dat","", "%e",TAttributeFileKey::kNewRow);
//Create DOE
TSampling *tsam = new TSampling(tds,"lhs",100);
tsam->generateSample();
//Precise output and create Code
TOutputFileDataServer *out = new TOutputFileDataServer("_output_multitype_mt_DataServer_.dat");
out->addAttribute(new TAttribute("w1",TAttribute::kString));
out->addAttribute(new TAttribute("w2",TAttribute::kString));
out->addAttribute(new TAttribute("v1",TAttribute::kVector));
out->addAttribute(new TAttribute("v2",TAttribute::kVector));
out->addAttribute(new TAttribute("f1"));
TCode *myc = new URANIE::Launcher::TCode(tds, "multitype -mtDS");
myc->addOutputFile( out );
//Create TLauncher and run it
TLauncher *tlau = new URANIE::Launcher::TLauncher(tds, myc);
tlau->run();
//Produce control plot
TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw(); pad->cd();
tds->drawPairs("w1:v1:v2:f1:w2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created with a simple input (the seed) drawn as an uniform distribution. The design-of-experiments is generated and
the TOutputFileDataServer
is created and filled with new attributes. This is the important part,
where nature of the attributes are precised:
TOutputFileDataServer *out = new TOutputFileDataServer("_output_multitype_mt_DataServer_.dat");
out->addAttribute(new URANIE::DataServer::TAttribute("w1",TAttribute::kString));
out->addAttribute(new URANIE::DataServer::TAttribute("w2",TAttribute::kString));
out->addAttribute(new URANIE::DataServer::TAttribute("v1",TAttribute::kVector));
out->addAttribute(new URANIE::DataServer::TAttribute("v2",TAttribute::kVector));
out->addAttribute(new URANIE::DataServer::TAttribute("f1"));
The rest is very common and a pair plot is performed to check that the reading of the output went well (see following plot).
The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Section XIV.4.22.1, with a Column format, obtained by doing:
multitype -mtCol
The resulting output file, named _output_multitype_mt_Column_.dat
looks like:
nine -0.512095 0.039669 -1.3834 1.37667 0.220672 0.633267 1.37027 -0.765636 14.1981 14.0855 10.7848 9.45476 9.17308 6.60804 10.0711 14.1761 10.318 12.5095 15.6614 10.3452 9.41101 7.47887 32.2723 eight
{
//Create dataserver with the seed attribute
TDataServer *tds = new TDataServer("foo","pouet");
tds->addAttribute( new TUniformDistribution("seed",0,100000));
tds->getAttribute("seed")->setFileKey("multitype_input.dat","", "%e",TAttributeFileKey::kNewRow);
//Create DOE
TSampling *tsam = new TSampling(tds,"lhs",100);
tsam->generateSample();
//Precise output and create Code
TOutputFileColumn *out = new TOutputFileColumn("_output_multitype_mt_Column_.dat");
out->addAttribute(new TAttribute("w1",TAttribute::kString),1);
out->addAttribute(new TAttribute("w2",TAttribute::kString),5);
out->addAttribute(new TAttribute("v1",TAttribute::kVector),2);
out->addAttribute(new TAttribute("v2",TAttribute::kVector),3);
out->addAttribute(new TAttribute("f1"),4);
TCode *myc = new URANIE::Launcher::TCode(tds, "multitype -mtCol");
myc->addOutputFile( out );
//Create TLauncher and run it
TLauncher *tlau = new URANIE::Launcher::TLauncher(tds, myc);
tlau->run();
//Produce control plot
TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw(); pad->cd();
tds->drawPairs("w1:v1:v2:f1:w2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created with a simple input (the seed) drawn as an uniform distribution. The design-of-experiments is generated and
the TOutputFileColumn
is created and filled with new attributes. This is the important part,
where nature of the attributes are precised:
TOutputFileColumn *out = new TOutputFileColumn("_output_multitype_mt_Column_.dat");
out->addAttribute(new URANIE::DataServer::TAttribute("w1",TAttribute::kString),1);
out->addAttribute(new URANIE::DataServer::TAttribute("w2",TAttribute::kString),5);
out->addAttribute(new URANIE::DataServer::TAttribute("v1",TAttribute::kVector),2);
out->addAttribute(new URANIE::DataServer::TAttribute("v2",TAttribute::kVector),3);
out->addAttribute(new URANIE::DataServer::TAttribute("f1"),4);
The rest is very common and a pair plot is performed to check that the reading of the output went well (see following plot).
The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Section XIV.4.22.1, with a Row format, obtained by doing:
multitype -mtRow
When requesting a "row" type output, extra caution has to be taken: the usual separator between two fields are blank and/or tabulation. With this formatting, an output can look like this:
1.234 4.321 5.653 5.321
With this kind of file, it is impossible to know which attributes own the element on the second line (in other
words, if it should have been, first, second or third column). The proposed solution is to change the separator
between field, using any specific sign, followed by a blank. This is done using ";" and it results in an output
file, named _output_multitype_mt_Row_.dat
which looks like:
nine; -0.512095; 14.1981; 32.2723; eight ; 0.039669; 14.0855; ; ; ; -1.3834; 10.7848; ; ; ; 1.37667; 9.45476; ; ; ; 0.220672; 9.17308; ; ; ; 0.633267; 6.60804; ; ; ; 1.37027; 10.0711; ; ; ; -0.765636; 14.1761; ; ; ; ; 10.318; ; ; ; ; 12.5095; ; ; ; ; 15.6614; ; ; ; ; 10.3452; ; ; ; ; 9.41101; ; ; ; ; 7.47887; ; ;
{
//Create dataserver with the seed attribute
TDataServer *tds = new TDataServer("foo","pouet");
tds->addAttribute( new TUniformDistribution("seed",0,100000));
tds->getAttribute("seed")->setFileKey("multitype_input.dat","", "%e",TAttributeFileKey::kNewRow);
//Create DOE
TSampling *tsam = new TSampling(tds,"lhs",100);
tsam->generateSample();
//Precise output and create Code
TOutputFileRow *out = new TOutputFileRow("_output_multitype_mt_Row_.dat");
out->setFieldSeparatorCharacter(";");
out->addAttribute(new TAttribute("w1",TAttribute::kString));
out->addAttribute(new TAttribute("v1",TAttribute::kVector));
out->addAttribute(new TAttribute("v2",TAttribute::kVector));
out->addAttribute(new TAttribute("f1"));
out->addAttribute(new TAttribute("w2",TAttribute::kString));
TCode *myc = new URANIE::Launcher::TCode(tds, "multitype -mtRow");
myc->addOutputFile( out );
//Create TLauncher and run it
TLauncher *tlau = new URANIE::Launcher::TLauncher(tds, myc);
tlau->run();
//Produce control plot
TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw(); pad->cd();
tds->drawPairs("w1:v1:v2:f1:w2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created with a simple input (the seed) drawn as an uniform distribution. The design-of-experiments is generated and
the TOutputFileRow
is created and filled with new attributes. This is the important part,
where nature of the attributes are precised:
TOutputFileRow *out = new TOutputFileRow("_output_multitype_mt_Row_.dat");
out->setFieldSeparatorCharacter(";");
out->addAttribute(new URANIE::DataServer::TAttribute("w1",TAttribute::kString));
out->addAttribute(new URANIE::DataServer::TAttribute("v1",TAttribute::kVector));
out->addAttribute(new URANIE::DataServer::TAttribute("v2",TAttribute::kVector));
out->addAttribute(new URANIE::DataServer::TAttribute("f1"));
out->addAttribute(new URANIE::DataServer::TAttribute("w2",TAttribute::kString));
The second line is important as it explains the TOutputFileRow
object how to read the file
to know that some fields are empty. The rest is very common and a pair plot is performed to check that the reading
of the output went well (see following plot).
The objective of this macro is to test the case where vectors and strings are produced as outputs, using the code described in Section XIV.4.22.1, with a XML format, obtained by doing:
multitype -mtXML
The resulting output file is named _output_multitype_mt_.xml
and looks like:
<?xml version="1.0" encoding="iso-8859-1"?>
<multitypeMT>
<w1 value="nine"/>
<v1 n="8">
<values>
-0.512095 0.039669 -1.3834 1.37667 0.220672 0.633267 1.37027 -0.765636
</values>
</v1>
<v2 n="14">
<values>
14.1981 14.0855 10.7848 9.45476 9.17308 6.60804 10.0711 14.1761 10.318 12.5095 15.6614 10.3452 9.41101 7.47887
</values>
</v2>
<f1 value="32.2723"/>
<w2 value="eight"/>
</multitypeMT>
{
//Create dataserver with the seed attribute
TDataServer *tds = new TDataServer("foo","pouet");
tds->addAttribute( new TUniformDistribution("seed",0,100000));
tds->getAttribute("seed")->setFileKey("multitype_input.dat","", "%e",TAttributeFileKey::kNewRow);
//Create DOE
TSampling *tsam = new TSampling(tds,"lhs",100);
tsam->generateSample();
//Precise output and create Code
TOutputFileXML *out = new TOutputFileXML("_output_multitype_mt_.xml");
out->addAttribute(new TAttribute("w1",TAttribute::kString), "/multitypeMT/w1/@value", TAttributeFileKey::kXMLAttribute );
out->addAttribute(new TAttribute("w2",TAttribute::kString), "/multitypeMT/w2/@value", TAttributeFileKey::kXMLAttribute );
out->addAttribute(new TAttribute("v1",TAttribute::kVector), "/multitypeMT/v1/values", TAttributeFileKey::kXMLField );
out->addAttribute(new TAttribute("v2",TAttribute::kVector), "/multitypeMT/v2/values", TAttributeFileKey::kXMLField );
out->addAttribute(new TAttribute("f1"), "/multitypeMT/f1/@value", TAttributeFileKey::kXMLAttribute );
TCode *myc = new URANIE::Launcher::TCode(tds, "multitype -mtXML");
myc->addOutputFile( out );
//Create TLauncher and run it
TLauncher *tlau = new URANIE::Launcher::TLauncher(tds, myc);
tlau->run();
//Produce control plot
TCanvas *Can = new TCanvas("Can","Can",10,10,1000,800);
TPad *pad = new TPad("pad","pad",0, 0.03, 1, 1); pad->Draw(); pad->cd();
tds->drawPairs("w1:v1:v2:f1:w2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created with a simple input (the seed) drawn as an uniform distribution. The design-of-experiments is generated and
the TOutputFileXML
is created and filled with new attributes. This is the important part,
where nature of the attributes are precised:
TOutputFileXML *out = new TOutputFileXML("_output_multitype_mt_.xml");
out->addAttribute(new TAttribute("w1",TAttribute::kString), "/multitypeMT/w1/@value", TAttributeFileKey::kXMLAttribute );
out->addAttribute(new TAttribute("w2",TAttribute::kString), "/multitypeMT/w2/@value", TAttributeFileKey::kXMLAttribute );
out->addAttribute(new TAttribute("v1",TAttribute::kVector), "/multitypeMT/v1/values", TAttributeFileKey::kXMLField );
out->addAttribute(new TAttribute("v2",TAttribute::kVector), "/multitypeMT/v2/values", TAttributeFileKey::kXMLField );
out->addAttribute(new TAttribute("f1"), "/multitypeMT/f1/@value", TAttributeFileKey::kXMLAttribute );
The second line is important as it explains the TOutputFileXML
object how to read the file
to know that some fields are empty. The rest is very common and a pair plot is performed to check that the reading
of the output went well (see following plot).
The objective of this macro is to test the case where vectors and strings are used as inputs, using the code described in Section XIV.4.22.2, with a Key format, obtained by doing:
multitype -ReadmtKey
The input values will be read from a database which
is produced with the multitype -mt
code, as no sampling is available yet to produce vectors and
strings. The database file is readmultitype_sampling.dat
which looks like this:
#NAME: foo #TITLE: TDS for flowrate #DATE: Mon Oct 3 23:50:34 2016 #COLUMN_NAMES: v1| w1| v2| w2| f1| foo__n__iter__ #COLUMN_TYPES: V|S|V|S|D|D -6.901933299378e-02,-1.292435959913e-01,4.558876683004e-01,5.638486368789e-01,-4.767582766745e-02,7.102109543136e-03,2.819049677902e-01,-2.019788081790e+00,-2.604401028584e+00,-1.617682380292e+00,2.894560949798e-02,-3.493905850261e-01 six 1.142449011404e+01,7.318948216271e+00,1.502260859231e+01,6.041193793062e+00,6.729445145907e+00,1.128096968597e+01 zero 3.425632316777e+01 0.000000000000e+00 -6.923200061823e-01,-4.798721931875e-01,-1.329893204384e+00,1.292933726829e+00 zero 1.249911290435e+01,6.309239169117e+00,1.596653626442e+01,5.500878012739e+00,1.322535550082e+01,7.070984389647e+00,1.708574150702e+00,1.265915339220e+01 two 4.295175025115e+01 1.000000000000e+00 5.773813268848e-01,-3.512405673973e-01,-6.870089014992e-01,1.273074555211e-01 nine 1.242682578759e+01,1.109680842701e+01,1.670410641828e+01,7.296321908492e+00,8.732800753443e+00,1.262906549132e+01,8.882310687564e+00,1.104280818003e+01 five 5.591437936893e+01 2.000000000000e+00 5.518508915499e-01,2.438158138873e-01,1.111784497742e+00,-1.517566514667e+00,7.146879916125e-01,2.328439269321e+00,-1.251913839951e+00,8.876684186954e-01,-1.383023165632e+00,-8.192089693621e-01,-1.079524713568e-01,6.595650273375e-01,-2.275345802432e-03,1.304354557600e+00 nine 1.021975159505e+01,4.995433740783e+00,1.108628156181e+01,1.041110604995e+01,1.111365770153e+01,6.365695806343e+00,6.374053973239e+00,6.854423942510e+00,7.144262333164e+00 two 4.093776591421e+01 3.000000000000e+00 2.403942476958e-01,6.868091212609e-01,-1.561012830108e+00,1.937806684989e+00,-1.465851888061e+00,5.367279844359e-02,-1.263005327899e+00,-1.132259472701e+00 two 7.382048319627e+00,5.874867917970e+00,1.158191378461e+01,1.073321314846e+01 six 6.980549752305e+01 4.000000000000e+00 2.220485143391e+00,-5.787212569267e-01,8.843648237689e-01,2.020662891124e+00,1.066403357312e+00,-5.817432767992e-01,3.063023900800e-01,-7.393588637933e-01 two 2.049656723853e+00,9.679003878866e+00,7.338089623518e+00,1.235630702472e+01,1.509238505697e+01,1.034077492413e+01,1.116077550501e+01,7.179221834787e+00,1.582041236432e+01,9.204085091129e+00,4.707490792498e+00,1.618155764288e+01 five 3.507773555061e+01 5.000000000000e+00 8.908373817765e-01,-2.446355046704e-01,-1.900125532005e+00 seven 1.351254851860e+01,9.297087139459e+00,1.130966904782e+01,1.219245848701e+01,1.012996566249e+01,7.150071600452e+00,1.097549218518e+01,1.443074761657e+01 five 4.464560504112e+01 6.000000000000e+00 -2.514644600888e+00,1.633579305804e+00 one 1.229098312451e+01,1.013486836958e+01,1.243386772880e+01,1.071783135260e+01,1.453735777922e+01,7.995593455015e+00,9.753966962919e+00,5.924583770352e+00,6.187713988125e+00,1.061975242996e+01,6.650425922126e+00 four 4.553396475968e+01 7.000000000000e+00 -1.347811599520e+00,-1.259450135534e+00,1.812553405758e+00 five 7.717018655412e+00,1.053283796180e+01,7.404059210327e+00 eight 6.695868880279e+01 8.000000000000e+00 -1.258360863204e-01,-9.000566818602e-01,7.039146852797e-01,1.015917277706e+00,-2.397650482929e-01 four 4.346717386417e+00,1.033024889324e+01,7.183787459050e+00,8.742095837835e+00,1.277095440277e+01,8.685683828779e+00,9.321006265935e+00,6.353438157123e+00,8.552570119034e+00 six 4.381313066586e+01 9.000000000000e+00
For every pattern, an input file is created with the Key condensate format, as the other key format is not practical (and usable). This input file looks like this:
w1 = nine v1 = [ -0.512095,0.039669,-1.3834,1.37667,0.220672,0.633267,1.37027,-0.765636 ] v2 = [ 14.1981,14.0855,10.7848,9.45476,9.17308,6.60804,10.0711,14.1761,10.318,12.5095,15.6614,10.3452,9.41101,7.47887 ] f1 = 32.2723 w2 = eight
The resulting output file, named _output_multitype_readmt_Key_.dat
looks like:
thev1 = -0.2397650482929 thev2 = 9.321006265935
{
//Create dataserver with a database of 10 runs of the "multitype -mt" code
TDataServer *tds = new TDataServer("foo","pouet");
tds->fileDataRead("readmultitype_sampling.dat");
//Explain the name of the input file and the format chosen
tds->getAttribute("w1")->setFileKey("_output_multitype_mt_Key_condensate_.dat","", "%e",TAttributeFileKey::kNewKey);
tds->getAttribute("v1")->setFileKey("_output_multitype_mt_Key_condensate_.dat","", "%e",TAttributeFileKey::kNewKey);
tds->getAttribute("v2")->setFileKey("_output_multitype_mt_Key_condensate_.dat","", "%e",TAttributeFileKey::kNewKey);
tds->getAttribute("f1")->setFileKey("_output_multitype_mt_Key_condensate_.dat","", "%e",TAttributeFileKey::kNewKey);
tds->getAttribute("w2")->setFileKey("_output_multitype_mt_Key_condensate_.dat","", "%e",TAttributeFileKey::kNewKey);
//Create the Class that will handle re-writting the input file
TString OutName="_output_multitype_mt_Key_condensate_.dat";
TInputFileRecreate *in = new TInputFileRecreate(gSystem->PrependPathName(gSystem->pwd(),OutName));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
in->setVectorProperties("[",",","]"); // Change the vector properties
// Create the output file interface and state that there will be 2 outputs
TOutputFileKey *out = new TOutputFileKey("_output_multitype_readmt_Key_.dat");
out->addAttribute(new TAttribute("thev1") );
out->addAttribute(new TAttribute("thev2") );
// Create the corresponding interface to code
TCode *tc1 = new TCode(tds, "multitype -ReadmtKey");
tc1->addInputFile( in );
tc1->addOutputFile( out );
// Create the launcher and run the code
TLauncher *tl1 = new TLauncher(tds, tc1);
tl1->run();
tds->Scan("thev1:thev2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created by reading an input file readmultitype_sampling.dat
in which 10 events
are stored. The main difference arises from the way the input file is created: it is done explicitly because the
order in which the attributes are stored in the database file are not the one needed by the code in the input file
(this case is discussed in Section IV.3.1.1). The name of the
file given in the construction has to be absolute, as the TCode
object will check this in
order to know whether the input file should be created.
//Create the Class that will handle re-writing the input file
TInputFileRecreate *in = new TInputFileRecreate(Form("%s/_output_multitype_mt_Key_condensate_.dat",gSystem->pwd()));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
in->setVectorProperties("[",",","]"); // Change the vector properties
Moreover, an extra line is added to specify that the Key format is a condensate one, so that Uranie knows how to deal with vectors and strings specific case (only vectors here). The rest is very common and a screenshot of the result displayed in console is provided in the following subsection.
Processing launchCodeReadMultiTypeKey.C... ************************************ * Row * thev1 * thev2 * ************************************ * 0 * 0.2819049 * 11.424490 * * 1 * -0.692320 * 15.966536 * * 2 * -12345678 * 12.629065 * * 3 * -0.819208 * 11.086281 * * 4 * -1.561012 * -12345678 * * 5 * 0.8843648 * 10.340774 * * 6 * -12345678 * 7.1500716 * * 7 * 1.6335793 * 14.537357 * * 8 * -12345678 * -12345678 * * 9 * -0.239765 * 9.3210062 * ************************************
The objective of this macro is to test the case where vectors and strings are used as inputs, using the code described in Section XIV.4.22.2, with a DataServer format, obtained by doing:
multitype -ReadmtDS
. The input values will be read from a
database which is produced with the multitype -mt
code, as no sampling is available yet to produce
vectors and strings. The database file is readmultitype_sampling.dat
which is shown in Section XIV.4.29.1. For every pattern, an input file will
be created with the DataServer format. This input file looks like this:
#COLUMN_NAMES: w1|v1|v2|f1|w2 #COLUMN_TYPES: S|V|V|D|S nine -0.512095,0.039669,-1.3834,1.37667,0.220672,0.633267,1.37027,-0.765636 14.1981,14.0855,10.7848,9.45476,9.17308,6.60804,10.0711,14.1761,10.318,12.5095,15.6614,10.3452,9.41101,7.47887 32.2723 eight
The resulting output file, named _output_multitype_readmt_DataServer_.dat
looks like:
#COLUMN_NAMES: thev1|thev2 #COLUMN_TYPES: D|D -0.2397650482929 9.321006265935
{
//Create dataserver with a database of 10 runs of the "multitype -mt" code
TDataServer *tds = new TDataServer("foo","pouet");
tds->fileDataRead("readmultitype_sampling.dat");
//Explain the name of the input file and the format chosen
tds->getAttribute("w1")->setFileKey("_output_multitype_mt_DataServer_.dat","", "%e",TAttributeFileKey::kNewTDS);
tds->getAttribute("v1")->setFileKey("_output_multitype_mt_DataServer_.dat","", "%e",TAttributeFileKey::kNewTDS);
tds->getAttribute("v2")->setFileKey("_output_multitype_mt_DataServer_.dat","", "%e",TAttributeFileKey::kNewTDS);
tds->getAttribute("f1")->setFileKey("_output_multitype_mt_DataServer_.dat","", "%e",TAttributeFileKey::kNewTDS);
tds->getAttribute("w2")->setFileKey("_output_multitype_mt_DataServer_.dat","", "%e",TAttributeFileKey::kNewTDS);
//Create the Class that will handle re-writting the input file
TString OutName="_output_multitype_mt_DataServer_.dat";
TInputFileRecreate *in = new TInputFileRecreate(gSystem->PrependPathName(gSystem->pwd(),OutName));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
// Create the output file interface and state that there will be 2 outputs
TOutputFileDataServer *out = new TOutputFileDataServer("_output_multitype_readmt_DataServer_.dat");
out->addAttribute(new TAttribute("thev1") );
out->addAttribute(new TAttribute("thev2") );
// Create the corresponding interface to code
TCode *tc1 = new TCode(tds, "multitype -ReadmtDS");
tc1->addInputFile( in );
tc1->addOutputFile( out );
// Create the launcher and run the code
TLauncher *tl1 = new TLauncher(tds, tc1);
tl1->run();
tds->Scan("thev1:thev2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created by reading an input file readmultitype_sampling.dat
in which 10 events
are stored. The main difference arises from the way the input file is created: it is done explicitly because the
order in which the attributes are stored in the database file are not the one needed by the code in the input file
(this case is discussed in Section IV.3.1.1). The name of the
file given in the construction has to be absolute, as the TCode
object will check this in
order to know whether the input file should be created.
//Create the Class that will handle re-writing the input file
TInputFileRecreate *in = new TInputFileRecreate(Form("%s/_output_multitype_mt_DataServer_.dat",gSystem->pwd()));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
The rest is very common and a screenshot of the result displayed in console is provided in the following subsections.
Processing launchCodeReadMultiTypeDataServer.C... ************************************ * Row * thev1 * thev2 * ************************************ * 0 * 0.2819049 * 11.424490 * * 1 * -0.692320 * 15.966536 * * 2 * -12345678 * 12.629065 * * 3 * -0.819208 * 11.086281 * * 4 * -1.561012 * -12345678 * * 5 * 0.8843648 * 10.340774 * * 6 * -12345678 * 7.1500716 * * 7 * 1.6335793 * 14.537357 * * 8 * -12345678 * -12345678 * * 9 * -0.239765 * 9.3210062 * ************************************
The objective of this macro is to test the case where vectors and strings are used as inputs, using the code described in Section XIV.4.22.2, with a Column format, obtained by doing:
multitype -ReadmtCol
The input values will be read from a
database which is produced with the multitype -mt
code, as no sampling is available yet to produce
vectors and strings. The database file is readmultitype_sampling.dat
which is shown in Section XIV.4.29.1. For every pattern, an input file will
be created with the Column format. This input file looks like this:
nine -0.512095 0.039669 -1.3834 1.37667 0.220672 0.633267 1.37027 -0.765636 14.1981 14.0855 10.7848 9.45476 9.17308 6.60804 10.0711 14.1761 10.318 12.5095 15.6614 10.3452 9.41101 7.47887 32.2723 eight
The resulting output file, named _output_multitype_readmt_Column_.dat
looks like:
-0.2397650482929 9.321006265935
{
//Create dataserver with a database of 10 runs of the "multitype -mt" code
TDataServer *tds = new TDataServer("foo","pouet");
tds->fileDataRead("readmultitype_sampling.dat");
//Explain the name of the input file and the format chosen
tds->getAttribute("w1")->setFileKey("_output_multitype_mt_Column_.dat","", "%e",TAttributeFileKey::kNewColumn);
tds->getAttribute("v1")->setFileKey("_output_multitype_mt_Column_.dat","", "%e",TAttributeFileKey::kNewColumn);
tds->getAttribute("v2")->setFileKey("_output_multitype_mt_Column_.dat","", "%e",TAttributeFileKey::kNewColumn);
tds->getAttribute("f1")->setFileKey("_output_multitype_mt_Column_.dat","", "%e",TAttributeFileKey::kNewColumn);
tds->getAttribute("w2")->setFileKey("_output_multitype_mt_Column_.dat","", "%e",TAttributeFileKey::kNewColumn);
//Create the Class that will handle re-writting the input file
TString OutName="_output_multitype_mt_Column_.dat";
TInputFileRecreate *in = new TInputFileRecreate(gSystem->PrependPathName(gSystem->pwd(),OutName));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
// Create the output file interface and state that there will be 2 outputs
TOutputFileColumn *out = new TOutputFileColumn("_output_multitype_readmt_Column_.dat");
out->addAttribute(new TAttribute("thev1") );
out->addAttribute(new TAttribute("thev2") );
// Create the corresponding interface to code
TCode *tc1 = new TCode(tds, "multitype -ReadmtCol");
tc1->addInputFile( in );
tc1->addOutputFile( out );
// Create the launcher and run the code
TLauncher *tl1 = new TLauncher(tds, tc1);
tl1->run();
tds->Scan("thev1:thev2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created by reading an input file readmultitype_sampling.dat
in which 10 events
are stored. The main difference arises from the way the input file is created: it is done explicitly because the
order in which the attributes are stored in the database file are not the one needed by the code in the input file
(this case is discussed in Section IV.3.1.1). The name of the
file given in the construction has to be absolute, as the TCode
object will check this in
order to know whether the input file should be created.
//Create the Class that will handle re-writing the input file
TInputFileRecreate *in = new TInputFileRecreate(Form("%s/_output_multitype_mt_Column_.dat",gSystem->pwd()));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
The rest is very common and a screenshot of the result displayed in console is provided in the following subsection.
Processing launchCodeReadMultiTypeColumn.C... ************************************ * Row * thev1 * thev2 * ************************************ * 0 * 0.2819049 * 11.424490 * * 1 * -0.692320 * 15.966536 * * 2 * -12345678 * 12.629065 * * 3 * -0.819208 * 11.086281 * * 4 * -1.561012 * -12345678 * * 5 * 0.8843648 * 10.340774 * * 6 * -12345678 * 7.1500716 * * 7 * 1.6335793 * 14.537357 * * 8 * -12345678 * -12345678 * * 9 * -0.239765 * 9.3210062 * ************************************
The objective of this macro is to test the case where vectors and strings are used as inputs, using the code described in Section XIV.4.22.2, with a Row format, obtained by doing:
multitype -ReadmtRow
The input values will be read from a database which
has been produced with the multitype -mt
code, as no sampling is available yet to produce vectors and
strings. The database file is readmultitype_sampling.dat
which is shown in Section XIV.4.29.1. For every pattern, an input file will be created
with the Row format. This input file is very peculiar as the number of entries per attribute is not equal going
from attribute to another (this format is not recommended as discussed in the third item of Section IV.3.1.2.3). It will look like this:
nine; -0.512095; 14.1981; 32.2723; eight ; 0.039669; 14.0855; ; ; ; -1.3834; 10.7848; ; ; ; 1.37667; 9.45476; ; ; ; 0.220672; 9.17308; ; ; ; 0.633267; 6.60804; ; ; ; 1.37027; 10.0711; ; ; ; -0.765636; 14.1761; ; ; ; ; 10.318; ; ; ; ; 12.5095; ; ; ; ; 15.6614; ; ; ; ; 10.3452; ; ; ; ; 9.41101; ; ; ; ; 7.47887; ; ;
The resulting output file, named _output_multitype_readmt_Row_.dat
, looks like:
-0.2397650482929; 9.321006265935
{
//Create dataserver with a database of 10 runs of the "multitype -mt" code
TDataServer *tds = new TDataServer("foo","pouet");
tds->fileDataRead("readmultitype_sampling.dat");
//Explain the name of the input file and the format chosen
tds->getAttribute("w1")->setFileKey("_output_multitype_mt_Row_.dat","", "%e",TAttributeFileKey::kNewRow);
tds->getAttribute("v1")->setFileKey("_output_multitype_mt_Row_.dat","", "%e",TAttributeFileKey::kNewRow);
tds->getAttribute("v2")->setFileKey("_output_multitype_mt_Row_.dat","", "%e",TAttributeFileKey::kNewRow);
tds->getAttribute("f1")->setFileKey("_output_multitype_mt_Row_.dat","", "%e",TAttributeFileKey::kNewRow);
tds->getAttribute("w2")->setFileKey("_output_multitype_mt_Row_.dat","", "%e",TAttributeFileKey::kNewRow);
//Create the Class that will handle re-writting the input file
TString OutName="_output_multitype_mt_Row_.dat";
TInputFileRecreate *in = new TInputFileRecreate( gSystem->PrependPathName(gSystem->pwd(),OutName));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
in->setFieldSeparatorCharacter("; "); // Change the separator
// Create the output file interface and state that there will be 2 outputs
TOutputFileRow *out = new TOutputFileRow("_output_multitype_readmt_Row_.dat");
out->addAttribute(new TAttribute("thev1") );
out->addAttribute(new TAttribute("thev2") );
// Create the corresponding interface to code
TCode *tc1 = new TCode(tds, "multitype -ReadmtRow");
tc1->addInputFile( in );
tc1->addOutputFile( out );
// Create the launcher and run the code
TLauncher *tl1 = new TLauncher(tds, tc1);
tl1->run();
tds->Scan("thev1:thev2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created by reading an input file readmultitype_sampling.dat
in which 10 events
are stored. The main difference arises from the way the input file is created: it is done explicitly because the
order in which the attributes are stored in the database file are not the one needed by the code in the input file
(this case is discussed in Section IV.3.1.1). The name of the
file given in the construction has to be absolute, as the TCode
object will check this in
order to know whether the input file should be created.
//Create the Class that will handle re-writing the input file
TInputFileRecreate *in = new TInputFileRecreate(Form("%s/_output_multitype_mt_Row_.dat",gSystem->pwd()));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
in->setFieldSeparatorCharacter("; "); // Change the separator
When requesting a "Row" type input, extra caution has to be taken: the usual separator between two fields are blank and/or tabulation. With this formatting, an input can look like this:
1.234 4.321 5.653
5.321
With this kind of file, it is impossible to know which attributes own the element on the second line (in other words, if it should have been, first, second or third column). The proposed solution is to change the separator between field, using any specific sign, followed by a blank. This is done using ";" and it is shown as the last line in previous code. The rest is very common and a screenshot of the result displayed in console is provided in the following subsection.
Processing launchCodeReadMultiTypeRow.C... ************************************ * Row * thev1 * thev2 * ************************************ * 0 * 0.2819049 * 11.424490 * * 1 * -0.692320 * 15.966536 * * 2 * -12345678 * 12.629065 * * 3 * -0.819208 * 11.086281 * * 4 * -1.561012 * -12345678 * * 5 * 0.8843648 * 10.340774 * * 6 * -12345678 * 7.1500716 * * 7 * 1.6335793 * 14.537357 * * 8 * -12345678 * -12345678 * * 9 * -0.239765 * 9.3210062 * ************************************
The objective of this macro is to test the case where vectors and strings are used as inputs, using the code described in Section XIV.4.22.2, with a XML format, obtained by doing:
multitype -ReadmtXML
The input values will be read from a database which
is produced with the multitype -mt
code, as no sampling is available yet to produce vectors and
strings. The database file is readmultitype_sampling.dat
which is shown in Section XIV.4.29.1. For every pattern, an input file will be created
with the XML format. This input file looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<multitypeMT>
<w1 value="nine"/>
<v1 n="8">
<values>
-0.512095 0.039669 -1.3834 1.37667 0.220672 0.633267 1.37027 -0.765636
</values>
</v1>
<v2 n="14">
<values>
14.1981 14.0855 10.7848 9.45476 9.17308 6.60804 10.0711 14.1761 10.318 12.5095 15.6614 10.3452 9.41101 7.47887
</values>
</v2>
<f1 value="32.2723"/>
<w2 value="eight"/>
</multitypeMT>
The resulting output file is named _output_multitype_readmt_.xml
and looks like:
<?xml version="1.0" encoding="iso-8859-1"?>
<multitypeREADMT>
<thev1 value="-0.2397650482929"/>
<thev2 value="9.321006265935"/>
</multitypeREADMT>
{
//Create dataserver with a database of 10 runs of the "multitype -mt" code
TDataServer *tds = new TDataServer("foo","pouet");
tds->fileDataRead("readmultitype_sampling.dat");
//Produce the input files
gSystem->Exec("multitype -mtXML");
//Explain the name of the input file and the format chosen
tds->getAttribute("w1")->setFileKey("_output_multitype_mt_.xml","w1/@value", "", TAttributeFileKey::kXMLAttribute);
tds->getAttribute("v1")->setFileKey("_output_multitype_mt_.xml","v1/values", "", TAttributeFileKey::kXMLField);
tds->getAttribute("v2")->setFileKey("_output_multitype_mt_.xml","v2/values", "", TAttributeFileKey::kXMLField);
tds->getAttribute("f1")->setFileKey("_output_multitype_mt_.xml","f1/@value", "", TAttributeFileKey::kXMLAttribute);
tds->getAttribute("w2")->setFileKey("_output_multitype_mt_.xml","w2/@value", "", TAttributeFileKey::kXMLAttribute);
//Create the Class that will handle re-writting the input file
TString OutName="_output_multitype_mt_.xml";
TInputFileXML *in = new TInputFileXML(gSystem->PrependPathName(gSystem->pwd(),OutName));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
// Create the output file interface and state that there will be 2 outputs
TOutputFileXML *out = new TOutputFileXML("_output_multitype_readmt_.xml");
out->addAttribute(new TAttribute("thev1"), "/flowrateREADMT/thev1/@value", TAttributeFileKey::kXMLAttribute);
out->addAttribute(new TAttribute("thev2"), "/flowrateREADMT/thev2/@value", TAttributeFileKey::kXMLAttribute );
// Create the corresponding interface to code
TCode *tc1 = new TCode(tds, "multitype -ReadmtXML");
tc1->addInputFile( in );
tc1->addOutputFile( out );
// Create the launcher and run the code
TLauncher *tl1 = new TLauncher(tds, tc1);
tl1->run();
tds->Scan("thev1:thev2");
}
When looking at the code and comparing it to an usual launcher job, the organisation is completely transparent. A
dataserver is created by reading an input file readmultitype_sampling.dat
in which 10 events
are stored. The main difference arises from the way the input file is created: it is done explicitly because the
order in which the attributes are stored in the database file are not the one needed by the code in the input file
(this case is discussed in Section IV.3.1.1). The name of the
file given in the construction has to be absolute, as the TCode
object will check this in
order to know whether the input file should be created.
//Create the Class that will handle re-writing the input file
TInputFileXML *in = new TInputFileXML(Form("%s/_output_multitype_mt_.xml",gSystem->pwd()));
// Add attribute in the correct (needed) order
in->addAttribute( tds->getAttribute("w1") );
in->addAttribute( tds->getAttribute("v1") );
in->addAttribute( tds->getAttribute("v2") );
in->addAttribute( tds->getAttribute("f1") );
in->addAttribute( tds->getAttribute("w2") );
The class of input file is not a TInputFileRecreate
as an example of input file is
needed. The class used is so the TInputFileXML
and in order to be sure that this file
exists, the code is called at first as following to produce the _output_multitype_mt_.xml
.
//Produce the input files
gSystem->Exec("multitype -mtXML");
The rest is very common and a screenshot of the result displayed in console is provided in the following subsection.
Processing launchCodeReadMultiTypeXML.C... ************************************ * Row * thev1 * thev2 * ************************************ * 0 * 1.2345678 * 1.2345678 * * 1 * 1.2345678 * 1.2345678 * * 2 * 1.2345678 * 1.2345678 * * 3 * 1.2345678 * 1.2345678 * * 4 * 1.2345678 * 1.2345678 * * 5 * 1.2345678 * 1.2345678 * * 6 * 1.2345678 * 1.2345678 * * 7 * 1.2345678 * 1.2345678 * * 8 * 1.2345678 * 1.2345678 * * 9 * 1.2345678 * 1.2345678 * ************************************
The objective of this macro is to test the case where input and output key files are dfined with blank space in the
key definition. This is a first attempt to overcome this situation and it will be using a newly-made code named
withblank
that deal with pressure and density of water in a brewery and take its input from the
following file withblank_input.dat
water model.brewery pit pressure = 1E5 \\ Double I do like Chocolate residual brew density model.factor for glass = 1E-2 \\ Double aussi
The code itself is meaningless as it only multiply by two (for the pressure) and by three (for the density) and
these meaningless information are stored in the output file withblank_output.dat
which also is
the form of key file, in which the keys contains several blank space, as shown below
Test doubling.water model.brewery pit pressure = 10.55397966411 Bla Bla Bla Chocolat doubling.residual brew density model.factor for glass = 2.738635531741
{
// Create dataserver and add attributes
TDataServer *tds = new TDataServer("pouet","foo");
tds->addAttribute(new TUniformDistribution("pressure",0,10));
tds->addAttribute(new TLogUniformDistribution("density",0.01,100));
// Define the input file and the keys for
TString sFileName=TString("withblank_input.dat");
tds->getAttribute("pressure")->setFileKey(sFileName, "water model.brewery pit pressure ");
tds->getAttribute("density")->setFileKey(sFileName, "residual brew density model.factor for glass ");
// Create the input file interface before it's done by the TCode to precise information
TInputFileKey *in = new TInputFileKey(gSystem->PrependPathName(gSystem->pwd(),sFileName));
// Set the separator to '=' so that the line could contains blank spaces (specific)
in->setFieldSeparatorCharacter("=");
in->setSeparatorCharacter(" ");
in->addAttribute( tds->getAttribute("pressure") );
in->addAttribute( tds->getAttribute("density") );
// Generate a doe
TBasicSampling *sampl = new TBasicSampling(tds,"srs",10);
sampl->generateSample();
// Define the output
TString sOutFileName="withblank_output.dat";
TOutputFileKey *fout = new TOutputFileKey(sOutFileName);
// Set the separator to '=' so that the line could contains blank spaces (specific)
fout->setFieldSeparatorCharacter("=");
fout->setSeparatorCharacter("\n");
// Define the attributes and their keys
TAttribute *outAtt = new TAttribute("outpressure");
outAtt->setFileKey(sOutFileName,"Test doubling.water model.brewery pit pressure ");
TAttribute *outAtt2 = new TAttribute("outdensity");
outAtt2->setFileKey(sOutFileName,"Chocolat doubling.residual brew density model.factor for glass ");
fout->addAttribute(outAtt);
fout->addAttribute(outAtt2);
// Create a TCode object with the TDS (attribute and input files) and the command to execute
TCode *mycode = new TCode(tds, "withblank");
// Add the output file
mycode->addInputFile( in );
mycode->addOutputFile( fout );
// Launcher of the code on the Design of experiments (DoE) in the TDS
TLauncher *tlch = new TLauncher(tds, mycode);
tlch->setSave(-1);
tlch->setClean();
tlch->run();
tds->Scan("pressure:outpressure:density:outdensity");
}
As for all launcher's macro, it starts by defining the attributes and precise the key values with
setFileKey
method. From there, the main difference arise from the few lines below: as for
the case introduced Section XIV.4.27 one needs to recreate the input file
TInputFileKey
as one needs to specify some properties
// Create the input file interface before it's done by the TCode to precise information
TInputFileKey *in = new TInputFileKey(gSystem->PrependPathName(gSystem->pwd(),sFileName));
// Set the separator to '=' so that the line could contains blank spaces (specific)
in->setFieldSeparatorCharacter("=");
in->setSeparatorCharacter(" ");
in->addAttribute( tds->getAttribute("pressure") );
in->addAttribute( tds->getAttribute("density") );
Apart from the creation of the file, the two main functions to be called are
setFieldSeparatorCharacter
, used to define the "=" character as the field delimiter while
the second one setSeparatorCharacter
cancel the usual separator cleaning procedure
(usually the code is removing few characters such as ";", "\n", "="). Given this option, the file is breakdown, on
a line-by-line basis, to find the field separator.
The following block is defining a sampler while the next one is the definition of the output files
withblank_output.dat
. As previously the output file is created and the two main functions are
called with the same consequences: thanks to setFieldSeparatorCharacter
and
setSeparatorCharacter
, used with the already discussed argument, the output keys are also
usable with blank.
// Define the output
TString sOutFileName="withblank_output.dat";
TOutputFileKey *fout = new TOutputFileKey(sOutFileName);
// Set the separator to '=' so that the line could contains blank spaces (specific)
fout->setFieldSeparatorCharacter("=");
fout->setSeparatorCharacter("\n");
The rest of this macro is very usual, as one defines the code, the launcher and one runs it, one can check the content through a scan, shown below.xs
Processing launchCodeFilesWithBlank.C... ************************************************************ * Row * pressure * outpressu * density * outdensit * ************************************************************ * 0 * 3.3622174 * 6.7244349 * 19.122886 * 57.368659 * * 1 * 5.4302620 * 10.860524 * 0.0823283 * 0.2469849 * * 2 * 6.2876717 * 12.575343 * 0.2559847 * 0.7679543 * * 3 * 3.3986722 * 6.7973444 * 0.0503713 * 0.1511141 * * 4 * 1.1833060 * 2.3666120 * 0.0364635 * 0.1093906 * * 5 * 9.3162251 * 18.632450 * 0.0134744 * 0.0404234 * * 6 * 2.1579343 * 4.3158686 * 0.0431745 * 0.1295236 * * 7 * 1.2310214 * 2.4620429 * 12.797791 * 38.393373 * * 8 * 4.5137647 * 9.0275294 * 2.3940563 * 7.1821691 * * 9 * 8.4025508 * 16.805101 * 65.518819 * 196.55645 * ************************************************************