-
Notifications
You must be signed in to change notification settings - Fork 135
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
Logical Model #1232
Merged
Merged
Logical Model #1232
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9516ec8
add test for Logical Model
wangcj05 8f6d8ac
Merge branch 'devel' into wangc/hybrid_ext
wangcj05 78e05a9
rename test
wangcj05 79cbc71
initial structure of LogicalModel
wangcj05 b38950d
add LogicalModel
wangcj05 58b9e57
update submit
wangcj05 b557bbc
update logical model
wangcj05 27ceb1b
update tests
wangcj05 ac123d2
test for logical code
wangcj05 51ef98b
add test for logical model with rom
wangcj05 5c86704
add control function
wangcj05 1137e69
add files that needed for logical code test
wangcj05 f07a11e
add checks for LogicalModel
wangcj05 a0ae8ac
add LogicalModel section in user manual
wangcj05 40df7b1
fix issue in Features and Target of ROM, convert string type to strin…
wangcj05 d006f67
conitue fix issue for ROMs
wangcj05 f42acf6
fix issue in Adaptive Sobol
wangcj05 f4b8567
fix polyexponential
wangcj05 8bd91d0
address comments
wangcj05 17a8ae9
< is not allowed in element tree text context, change to less
wangcj05 0397d8b
fix failed build on tests doc
wangcj05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
% | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
%%%%%% Logical Model %%%%%% | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% | ||
|
||
\subsection{LogicalModel} | ||
\label{subsec:models_LogicalModel} | ||
The \textbf{LogicalModel} is a model aimed to execute ROMs, | ||
Codes and ExternalModels via a user provided control function. Basically, the control function | ||
utilizes the inputs generated by RAVEN and the control logic provided by the user to determine which | ||
model to execute. | ||
\nb For this type of model, we currently require all models listed under \textbf{LogicalModel} should | ||
have the same inputs and outputs from RAVEN point of view. | ||
|
||
The specifications of a LogicalModel must be defined within the XML block | ||
\xmlNode{LogicalModel}. | ||
% | ||
This XML node needs to contain the attributes: | ||
|
||
\vspace{-5mm} | ||
\begin{itemize} | ||
\itemsep0em | ||
\item \xmlAttr{name}, \xmlDesc{required string attribute}, user-defined name | ||
of this LogicalModel. | ||
% | ||
\nb As with the other objects, this is the name that can be used to refer to | ||
this specific entity from other input blocks in the XML. | ||
\item \xmlAttr{subType}, \xmlDesc{required string attribute}, must be kept | ||
empty. | ||
% | ||
\end{itemize} | ||
\vspace{-5mm} | ||
|
||
Within the \xmlNode{LogicalModel} XML node, the multiple entities that constitute | ||
this LogicalModel needs to be inputted. | ||
|
||
\begin{itemize} | ||
\item \xmlNode{Model}, \xmlDesc{XML node, required parameter}. | ||
% | ||
The text portion of this node needs to contain the name of the Model | ||
% | ||
\assemblerAttrDescription{Model} | ||
% | ||
\nb The user can provided various \xmlNode{Model} entities, including \xmlString{Code}, | ||
\xmlString{ROM} and \xmlString{ExternalModel}. | ||
|
||
\item \xmlNode{ControlFunction}, \xmlDesc{XML node, required parameter}. | ||
% | ||
The text portion of this node needs to contain the name of the function. | ||
% | ||
\assemblerAttrDescription{ControlFunction} | ||
\nb In order to work properly, this function must have a method named ``evaluate" | ||
that returns a single python str object representing the model that would be | ||
executed. | ||
\end{itemize} | ||
|
||
\textbf{Example (LogicalModel using external models):} | ||
\begin{lstlisting}[style=XML,morekeywords={subType,debug,name,class,type}] | ||
<Simulation> | ||
... | ||
<Models> | ||
<ExternalModel ModuleToLoad="sum" name="sum" subType=""> | ||
<variables>x, y, z</variables> | ||
</ExternalModel> | ||
|
||
<ExternalModel ModuleToLoad="minus" name="minus" subType=""> | ||
<variables>x, y, z</variables> | ||
</ExternalModel> | ||
|
||
<ExternalModel ModuleToLoad="multiply" name="multiply" subType=""> | ||
<variables>x, y, z</variables> | ||
</ExternalModel> | ||
|
||
<LogicalModel name="logical" subType=""> | ||
<Model class="Models" type="ExternalModel">sum</Model> | ||
<Model class="Models" type="ExternalModel">minus</Model> | ||
<Model class="Models" type="ExternalModel">multiply</Model> | ||
<ControlFunction class="Functions" type="External">control</ControlFunction> | ||
</LogicalModel> | ||
</Models> | ||
... | ||
<Steps> | ||
<MultiRun name="mc"> | ||
<Input class="DataObjects" type="PointSet">inputHolder</Input> | ||
<Model class="Models" type="LogicalModel">logical</Model> | ||
<Sampler class="Samplers" type="MonteCarlo">MonteCarlo</Sampler> | ||
<Output class="DataObjects" type="PointSet">outSet</Output> | ||
<Output class="DataObjects" type="PointSet">tagetSet</Output> | ||
<Output class="OutStreams" type="Print">dumpOut</Output> | ||
</MultiRun> | ||
</Steps> | ||
... | ||
</Simulation> | ||
|
||
\end{lstlisting} | ||
|
||
Corresponding Python function for \xmlNode{ControlFunction}: | ||
\begin{lstlisting}[language=python] | ||
def evaluate(self): | ||
""" | ||
Method required by RAVEN to run this as an external model. | ||
@ In, self, object, object to store members on | ||
@ Out, model, str, the name of external model that | ||
will be executed by hybrid model | ||
""" | ||
model = None | ||
if self.x > 0 and self.y >1: | ||
model = 'sum' | ||
elif self.x > 0 and self.y <= 1: | ||
model = 'multiply' | ||
else: | ||
model = 'minus' | ||
return model | ||
\end{lstlisting} | ||
|
||
\textbf{Example (LogicalModel using codes):} | ||
\begin{lstlisting}[style=XML,morekeywords={subType,debug,repeat,name,class,type}] | ||
<Simulation> | ||
... | ||
<Models> | ||
<Code name="poly" subType="GenericCode"> | ||
<executable>logicalCode/poly_code.py</executable> | ||
<clargs arg="python" type="prepend"/> | ||
<clargs arg="-i" extension=".one" type="input"/> | ||
<fileargs arg="aux" extension=".two" type="input"/> | ||
<fileargs arg="output" type="output"/> | ||
</Code> | ||
<Code name="exp" subType="GenericCode"> | ||
<executable>logicalCode/exp_code.py</executable> | ||
<clargs arg="python" type="prepend"/> | ||
<clargs arg="-i" extension=".one" type="input"/> | ||
<fileargs arg="aux" extension=".two" type="input"/> | ||
<fileargs arg="output" type="output"/> | ||
</Code> | ||
<LogicalModel name="logical" subType=""> | ||
<Model class="Models" type="Code">poly</Model> | ||
<Model class="Models" type="Code">exp</Model> | ||
<ControlFunction class="Functions" type="External">control</ControlFunction> | ||
</LogicalModel> | ||
</Models> | ||
... | ||
<Steps> | ||
<MultiRun name="logicalModelCode"> | ||
<Input class="Files" type="">gen.one</Input> | ||
<Input class="Files" type="">gen.two</Input> | ||
<Model class="Models" type="LogicalModel">logical</Model> | ||
<Sampler class="Samplers" type="Stratified">LHS</Sampler> | ||
<Output class="DataObjects" type="PointSet">samples</Output> | ||
<Output class="OutStreams" type="Print">samples</Output> | ||
</MultiRun> | ||
</Steps> | ||
... | ||
</Simulation> | ||
\end{lstlisting} | ||
|
||
Corresponding Python function for \xmlNode{ControlFunction}: | ||
\begin{lstlisting}[language=python] | ||
def evaluate(self): | ||
""" | ||
Method required by RAVEN to run this as an external model. | ||
@ In, self, object, object to store members on | ||
@ Out, model, str, the name of external model that | ||
will be executed by hybrid model | ||
""" | ||
model = None | ||
if self.x > 0.5 and self.y > 1.5: | ||
model = 'poly' | ||
else: | ||
model = 'exp' | ||
|
||
return model | ||
\end{lstlisting} | ||
% | ||
\nb For these examples, the user needs to provide all the inputs for the models listed | ||
under \textbf{LogicalModel}, i.e. Files for the \textbf{Code} and DataObject for | ||
the \textbf{ExternalModel} defined in the \textbf{LogicalModel}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we understand which input goes where? If I use codes that require the same input extension (e.g. *.i) how do I know which input goes to which code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you fine if I work on this issue in another pull request? Since the changes will also affect EnsembleModel and CodeInterface Entities. It may take longer and further discussion on the solution for this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Please, reference a new issue about this.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue #1240 is created.