Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interface raven running raven #341

Merged
merged 51 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8855ecc
first interface
alfoa Sep 9, 2017
39ace9d
moving ahead
alfoa Sep 10, 2017
682ab78
RAVENparser
alfoa Sep 10, 2017
8486cf9
removed trailing spaces
alfoa Sep 10, 2017
2b4ed9e
merge
alfoa Sep 12, 2017
b90ec87
finished parser
alfoa Sep 12, 2017
cd547ef
parser with addition and half interface ready
alfoa Sep 13, 2017
27455a5
added test
alfoa Sep 14, 2017
0dd1638
moving ahead
alfoa Sep 14, 2017
ae2fe4f
input changing finalized
alfoa Sep 16, 2017
ba4ac98
added initial support for external module
alfoa Sep 16, 2017
f655bf0
added support for external function + collect names of Outstreams
alfoa Sep 17, 2017
bf4eaf2
finalzed interface
alfoa Sep 18, 2017
0337f85
Merge branch 'devel' of https://github.com/idaholab/raven into alfoa/…
alfoa Sep 18, 2017
d1ee2e9
finalized + doc
alfoa Sep 18, 2017
be71d8f
added test
alfoa Sep 18, 2017
08fb72f
addedDefaultExt
alfoa Sep 18, 2017
57e4a81
removed absolute path
alfoa Sep 18, 2017
08a56dc
addressed Josh's and Paul's comments so far
alfoa Sep 19, 2017
63435da
Merge branch 'alfoa/ravenRunningRaven' of https://github.com/idaholab…
alfoa Sep 19, 2017
71d2e9a
modified read mode
alfoa Sep 19, 2017
56276a0
addressed Paul comments
alfoa Sep 19, 2017
56c6c32
fixed noscalar
alfoa Sep 19, 2017
5bffbb5
fixed attribute stuff
alfoa Sep 19, 2017
53c135a
removed absolute path
alfoa Sep 20, 2017
9d54e33
addressed Aaron's comment
alfoa Sep 20, 2017
376fcda
put error message for Variable Groups
alfoa Sep 20, 2017
c075eb8
typo
alfoa Sep 20, 2017
7693759
o
alfoa Sep 20, 2017
0e767f7
fixed nodefile node in case of MPI
alfoa Sep 20, 2017
b446c44
ok
alfoa Sep 20, 2017
00e9421
hope to be done
alfoa Sep 20, 2017
9743df1
fix
alfoa Sep 20, 2017
41c804c
finalizeCodeOut
alfoa Sep 20, 2017
71f6c84
fixed typo
alfoa Sep 20, 2017
7767ea3
removed unuseful runInfo that I added in previous commit
alfoa Sep 21, 2017
107de73
removed if statement
alfoa Sep 21, 2017
84b1138
debug printing for a sec (windwos )
aalfonsi Sep 21, 2017
815910e
parser local env to conver everythin as string
aalfonsi Sep 21, 2017
e7aa9cf
cast localenv to string for windwos
aalfonsi Sep 21, 2017
2395efd
removed trailing spaces
aalfonsi Sep 21, 2017
88a968a
merged
aalfonsi Sep 21, 2017
1600321
Update Code.py
aalfonsi Sep 21, 2017
bc221d9
Check for /usr/bin/bash if /bin/bash not found in windows
joshua-cogliati-inl Sep 21, 2017
96ee40b
fix failed runs
alfoa Sep 21, 2017
3b919a5
Update Code.py
alfoa Sep 21, 2017
bf2e128
fixed faulty checkForOutputFailure
alfoa Sep 21, 2017
b0c595f
Don't use -q, because sometimes it causes conda to crash.
joshua-cogliati-inl Sep 21, 2017
2c0f1a5
Fixed failed
alfoa Sep 21, 2017
93fbcfd
Merge branch 'alfoa/ravenRunningRaven' of https://github.com/idaholab…
alfoa Sep 21, 2017
cfa6e32
added test to check the correct collection of failed runs from Ensemb…
alfoa Sep 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions doc/user_manual/existing_interfaces.tex
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,174 @@ \subsection{Generic Interface}
\item \texttt{|}, the value that is going to be replaced by the Generic Interface, will be left- justified with a string length of ``10'';
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% RAVEN INTERFACE (RAVEN running RAVEN) %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{RAVEN Interface}
\label{subsec:RAVENInterface}
The RAVEN interface is meant to provide the possibility to execute a RAVEN input file
driving a set of SLAVE RAVEN calculations. For example, if the user wants to optimize the parameters
of a surrogate model (e.g. minimizing the distance between the surrogate predictions and the real data), he
can achieve this task by setting up a RAVEN input file (master) that performs an optimization on the feature
space characterized by the surrogate model parameters, whose training and validation assessment is performed in the SLAVE
RAVEN runs.
\\ There are some limitations for this interface:
\begin{itemize}
\item only one sub-level of RAVEN can be executed (i.e. if the SLAVE RAVEN input file contains the run of another RAVEN SLAVE, the MASTER RAVEN will error out)
\item only data from Outstreams of type Print can be collected by the MASTER RAVEN
\item only a maximum of two Outstreams can be collected (1 PointSet and 1 HistorySet)
\end{itemize}


Like for every other interface, most of the RAVEN workflow stays the same independently of which type of Model (i.e. Code) is used.
\\ Similarly to any other code interface, the user provides paths to executables and aliases for sampled variables within the
\xmlNode{Models} block. The \xmlNode{Code} block will contain attributes \xmlAttr{name} and
\xmlAttr{subType}. \xmlAttr{name} identifies that particular \xmlNode{Code} model within RAVEN, and
\xmlAttr{subType} specifies which code interface the model will use (In this case \xmlAttr{subType}=``RAVEN'').
The \xmlNode{executable}
block should contain the absolute or relative (with respect to the current working
directory) path to the RAVEN framework script (\textbf{raven\_framework}).
\\ In addition to the attributes and xml nodes reported above, the RAVEN accepts the following XML nodes (required and optional):
\begin{itemize}
\item \xmlNode{outputExportOutStreams}, \xmlDesc{comma separated list,
required parameter} will specify the \xmlNode{OutStreams} that will be loaded as outputs of the SLAVE RAVEN.
Maximum two \xmlNode{OutStreams} can be listed here (1 for PointSet and/or 1 for HistorySet).
\item \xmlNode{conversionModule}, \xmlDesc{string,
optional parameter} will specify the path to a \textit{Python} module that can contain two methods:
\begin{itemize}
\item \textbf{\textit{manipulateScalarSampledVariables}}, a method that is aimed to manipulate sampled variables and to create more in case needed.
Example:
\begin{lstlisting}[language=python]
def manipulateScalarSampledVariables(sampledVariables):
"""
This method is aimed to manipulate scalar variables.
The user can create new variables based on the
variables sampled by RAVEN
@ In, sampledVariables, dict, dictionary of
sampled variables ({"var1":value1,"var2":value2})
@ Out, None, the new variables should be
added in the "sampledVariables" dictionary
"""
newVariableValue =
sampledVariables['Distributions|Uniform@name:a_dist|lowerBound']
+ 1.0
sampledVariables['Distributions|Uniform@name:a_dist|upperBound'] =
newVariableValue
return
\end{lstlisting}

\item \textbf{\textit{convertNotScalarSampledVariables}}, a method that is aimed to convert not scalar variables (e.g. 1D arrays) into multiple scalar variables
(e.g. \xmlNode{constant}(s) in a sampling strategy).
This method is going to be required in case not scalar variables are detected by the interface.
Example:
\begin{lstlisting}[language=python]
def convertNotScalarSampledVariables(noScalarVariables):
"""
This method is aimed to convert not scalar
variables into multiple scalar variables. The user MUST
create new variables based on the not Scalar Variables
sampled (and passed in) by RAVEN
@ In, noScalarVariables, dict, dictionary of sampled
variables that are not scalar ({"var1":1Darray1,"var2":1Darray2})
@ Out, newVars, dict, the new variables that have
been created based on the not scalar variables
contained in "noScalarVariables" dictionary
"""
oneDimensionalArray =
sampledVariables['temperatureHistory']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not sampledVariables be noScalarVariables?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

newVars = {}
for cnt, value in enumerate(oneDimensionalArray):
newVars['Samplers|MonteCarlo@name:myMC|constant'+
'@name=temperatureHistory'+str(cnt)] =
oneDimensionalArray[cnt]
return newVars
\end{lstlisting}
\end{itemize}
\end{itemize}

Code input example:
\begin{lstlisting}[style=XML]
<Code name="RAVENrunningRAVEN" subType="RAVEN">
<executable>../../../raven_framework</executable>
<outputExportOutStreams>
HistorySetOutStream,PointSetOutStream
</outputExportOutStreams>
<conversionModule>
~/Users/username/whateverConversionModule.py
</conversionModule>
</Code>
\end{lstlisting}

Like for every other interface, the syntax of the variable names is important to make the parser understand how to perturb an input file.
\\ For the RAVEN interface, a syntax inspired by the XPath nomenclature is used.
\begin{lstlisting}[style=XML]
<Samplers>
<MonteCarlo name="MC_external">
...
<variable name="Models|ROM@subType:SciKitLearn@name:ROM1|C">
<distribution>C_distrib</distribution>
</variable>
<variable name="Models|ROM@subType:SciKitLearn@name:ROM1|tol">
<distribution>toll_distrib</distribution>
</variable>
<variable name="Samplers|Grid@name:'+
'GridName|variable@name:var1|grid@construction:equal@type:value@steps">
<distribution>categorical_step_distrib</distribution>
</variable>
...
</MonteCarlo>
</Samplers>
\end{lstlisting}
In the above example, it can be inferred that each XML node (subnode) needs to be separated by a ``|'' separator. In addition,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, in XPath, / is used as a separator. Since XPath is not being followed exactly, the full syntax supported should probably be documented.

every time an XML node has attributes, the user can specify them using the ``@'' separator to specify a value for them.
The first variable above will be pointing to the following XML sub-node ( \xmlNode{C}):
\begin{lstlisting}[style=XML]
<Models>
<ROM name="ROM1" subType="SciKitLearn">
...
<C>10.0</C>
...
</ROM>
</Models>
\end{lstlisting}
The second variable above will be pointing to the following XML sub-node ( \xmlNode{tol}):
\begin{lstlisting}[style=XML]
<Models>
<ROM name="ROM1" subType="SciKitLearn">
...
<tol>0.0001</tol>
...
</ROM>
</Models>
\end{lstlisting}
The third variable above will be pointing to the following XML attribute ( \xmlAttr{steps}):
\begin{lstlisting}[style=XML]
<Samplers>
<Grid name="GridName">
...
<variable name="var1">
...
<grid construction="equal" type="value" steps="1">0 1</grid>
...
</variable>

...
</MonteCarlo>
</Samplers>
\end{lstlisting}

The above nomenclature must be used for all the variables to be sampled and for the variables generated by the two methods contained, in case, in
the module that gets specified by the \xmlNode{conversionModule} in the \xmlNode{Code} section.
\\ Finally the SLAVE RAVEN input file (s) must be ``tagged'' with the attribute \xmlAttr{type="raven"} in the Files section. For example,

\begin{lstlisting}[style=XML]
<Files>
<Input name="slaveRavenInputFile" type="raven" >
test_rom_trainer.xml
</Input>
</Files>
\end{lstlisting}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% RELAP5 INTERFACE %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
Loading