--- myst: substitutions: macro: python: 1-5,19-36,39-54,56-61 cpp: 6-10,17-28,31-44,46-51 bloc1: python: 22-23 cpp: 7,18 bloc2: python: 26-29 cpp: 21-22 bloc3: python: 31-32,36,39,41 cpp: 8,24,28,31,33 bloc4: python: 45,47-48,53-54,56 cpp: 9,37,39,44,46 console: python: 2-49,53-56 cpp: 6-53,57-60 --- # Macro "**modelerFlowrateNeuralNetworks.{{extension}}**" ## Objective The objective of this macro is to build a surrogate model (an Artificial Neural Network) from a database. From a first database created from an ASCII file `flowrate_sampler_launcher_500.dat` (which defines values for eight variables described in [](#launcher_introduction_simple_case_problem) on 500 patterns), two ASCII files are created: one with the 300st patterns (`_flowrate_sampler_launcher_app_.dat`), the other with the 200 last patterns (`_flowrate_sampler_launcher_val_.dat`). The surrogate model is built with the database extracted from the first of the two files, the second allowing to perform calculations with a function. ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateNeuralNetworks." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + macro[language] + "\n" + "```" }} The main {{tds}} loads the main ASCII data file `flowrate_sampler_launcher_500.dat` {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateNeuralNetworks." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} The database is split in two parts by exporting the 300st patterns in a file and the remaining 200 in another one: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateNeuralNetworks." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} A second {{tds}} loads `_flowrate_sampler_launcher_app_.dat` and builds the surrogate model over all the variables: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateNeuralNetworks." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + "```" }} The model is exported in an external file in C++ language `"uranie_ann_flowrate.C"` where the function name is `ANNflowrate`: ````{only} cpp ```cpp tann->exportFunction("c++", "uranie_ann_flowrate.C","ANNflowrate"); ``` ```` ````{only} py ```python tann.exportFunction("c++", "uranie_ann_flowrate","ANNflowrate") ``` ```` The model is loaded from the macro `"uranie_ann_flowrate.C"` and applied on the second database with the function `ANNflowrate`: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateNeuralNetworks." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + "```" }} ## Graph {{ "```{figure} " + parent_dir + "/roottest/build/uranie/doc/modeler/use_cases/" + language + "/neural_network/modelerFlowrateNeuralNetworks.png\n" + ":align: center\n" + ":name: use_cases_modelerFlowrateNeuralNetworks\n" + figure_scale + "\n" + "\n" + "Graph of the macro **\"modelerFlowrateNeuralNetworks." + extension + "\"**" + "\n" + "```" }} ## Console {{ "```{literalinclude} " + parent_dir + "/roottest/build/uranie/doc/modeler/use_cases/" + language + "/modelerFlowrateNeuralNetworks_clean.log\n" + ":language: none\n" + ":lines: " + console[language] + "\n" + "```" }}