Skip to content

Commit

Permalink
Merge pull request #2 from ApexRMS/syncrosim-3.0
Browse files Browse the repository at this point in the history
Syncrosim 3.0
  • Loading branch information
katieb1 authored Oct 10, 2024
2 parents a867c07 + 83bde2e commit 3683cb1
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 193 deletions.
2 changes: 1 addition & 1 deletion helloworldPipeline1/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<package name="helloworldPipeline1" displayName="Hello World Step 1" description="Example demonstrating how to use pipelines" version="1.0.0" url="https://apexrms.github.io/helloworldEnhanced/">
<package name="helloworldPipeline1" displayName="Hello World Step 1" description="Example demonstrating how to use pipelines" version="2.0.0" url="https://apexrms.github.io/helloworldEnhanced/">

<dataSheet name="RunControl" displayName="Run Control" isRunControl="True" timestepTitle="Timestep" showMinIteration="False">
</dataSheet>
Expand Down
2 changes: 1 addition & 1 deletion helloworldPipeline2/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<package name="helloworldPipeline2" displayName="Hello World Step 2" description="Example demonstrating how to use pipelines" version="1.0.0" url="https://apexrms.github.io/helloworldEnhanced/">
<package name="helloworldPipeline2" displayName="Hello World Step 2" description="Example demonstrating how to use pipelines" version="2.0.0" url="https://apexrms.github.io/helloworldEnhanced/">

<builtFor package="helloworldPipeline1" version="1.0.0"/>

Expand Down
7 changes: 3 additions & 4 deletions src/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ mSD <- myInputDataframe$mSD
b <- myInputDataframe$b

# Setup empty R dataframe ready to accept output in SyncroSim datasheet format
myOutputDataframe <- datasheet(
myScenario,
name = "helloworldPipeline_IntermediateDatasheet"
)
myOutputDataframe <- data.frame(Iteration = numeric(0),
Timestep = numeric(0),
y = numeric(0))

# For loop through iterations
for (iter in runSettings$MinimumIteration:runSettings$MaximumIteration) {
Expand Down
5 changes: 3 additions & 2 deletions src/model2.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ myInputDataframe <- datasheet(myScenario,
name = "helloworldPipeline_IntermediateDatasheet")

# Setup empty R dataframe ready to accept output in SyncroSim datasheet format
myOutputDataframe <- datasheet(myScenario,
name = "helloworldPipeline_OutputDatasheet")
myOutputDataframe <- data.frame(Iteration = numeric(0),
Timestep = numeric(0),
yCum = numeric(0))

# For loop through iterations
for (iter in runSettings$MinimumIteration:runSettings$MaximumIteration) {
Expand Down
234 changes: 49 additions & 185 deletions src/package.xml
Original file line number Diff line number Diff line change
@@ -1,188 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<package name="helloworldPipeline" displayName="Example demonstrating how to use pipelines" version="1.1.0" url="https://apexrms.github.io/helloworldEnhanced/">
<transformers>
<package name="helloworldPipeline" displayName= "Hello World Pipeline (R)" description = "Example demonstrating how to use pipelines with an R model" version="2.0.0" url="https://apexrms.github.io/helloworldEnhanced/">

<!--Run Control-->
<dataSheet name="RunControl" displayName="Run Control" isRunControl="True" timestepTitle="Timestep" showMinIteration="False"></dataSheet>

<!--First Model Inputs-->
<dataSheet name="InputDatasheet" displayName="Inputs" isSingleRow="True">
<column name="mMean" dataType="Double" displayName="Slope Distribution Mean"/>
<column name="mSD" dataType="Double" displayName="Slope Distribution Standard Deviation"/>
<column name="b" dataType="Integer" displayName="Value for b"/>
</dataSheet>

<!--First Model Outputs / Second Model Inputs-->
<dataSheet name="IntermediateDatasheet" displayName="Intermediate Outputs" hasIteration="True" hasTimestep="True">
<column name="y" dataType="Double" displayName="Value for y"/>
</dataSheet>

<!--Second Model Outputs-->
<dataSheet name="OutputDatasheet" displayName="Outputs" hasIteration="True" hasTimestep="True">
<column name="yCum" dataType="Double" displayName="Cumulative y"/>
</dataSheet>

<!--First Transformer-->
<transformer name="firstModel" displayName="Hello World Pipeline 1 (R)" programName="Rscript" programArguments="model.R">
<dataSheet name="RunControl" type="Input"/>
<dataSheet name="InputDataSheet" type="Input"/>
<dataSheet name="IntermediateDataSheet" type="Output"/>
</transformer>

<!--Second Transformer-->
<transformer name="secondModel" displayName="Hello World Pipeline 2 (R)" programName="Rscript" programArguments="model2.R">
<dataSheet name="RunControl" type="Input"/>
<dataSheet name="IntermediateDataSheet" type="Input"/>
<dataSheet name="OutputDataSheet" type="Output"/>
</transformer>

<!--Scenario Datafeeds Layout-->
<layout type = "Scenario">
<item name="RunControl"/>
<item name="InputDataSheet"/>
<item name="IntermediateDataSheet"/>
<item name="OutputDataSheet"/>
</layout>

<!--Charts Layout-->
<layout type = "Chart">
<item name="y" displayName="y" dataSheet="IntermediateDatasheet" column="y"/>
<item name="yCum" displayName="Cumulative y" dataSheet="OutputDatasheet" column="yCum"/>
</layout>

<!--Primary Transformer-->
<transformer
name="Primary"
isPrimary="True"
programName="Rscript"
programArguments="model.R">

<!--Chart Transformer-->
<include>
<transformer name="corestime_Runtime"/>
<transformer name="firstModel"/>
<transformer name="secondModel"/>
</include>

<datafeeds>

<!--Run Control-->
<datafeed name="RunControl" displayName="Run Control" dataScope="Scenario">
<datasheets>
<datasheet name="RunControl" displayName="Run Control" isSingleRow="True">
<columns>
<column name="RunControlID" dataType="Integer" isPrimary="True"/>
<column name="ScenarioID" dataType="Integer"/>
<column
name="MinimumIteration"
displayName="Minimum Iteration"
dataType="Integer"
defaultValue="1"
validationType="WholeNumber"
validationCondition="GreaterEqual"
formula1="1"
isVisible="False"/>
<column
name="MaximumIteration"
displayName="Number of Iterations"
dataType="Integer"
defaultValue="5"
validationType="WholeNumber"
validationCondition="GreaterEqual"
formula1="1"/>
<column
name="MinimumTimestep"
displayName="Minimum Timestep"
dataType="Integer"
defaultValue="0"
validationType="WholeNumber"
validationCondition="GreaterEqual"
formula1="0"/>
<column
name="MaximumTimestep"
displayName="Maximum Timestep"
dataType="Integer"
defaultValue="10"
validationType="WholeNumber"
validationCondition="GreaterEqual"
formula1="0"/>
</columns>
</datasheet>
</datasheets>
</datafeed>

<!--First Model Inputs-->
<datafeed name="InputDatafeed" displayName="Inputs" dataScope="Scenario">
<datasheets>
<datasheet name="InputDatasheet" isSingleRow="True">
<columns>
<column name="InputDatasheetID" dataType="Integer" isPrimary="True"/>
<column name="ScenarioID" dataType="Integer"/>
<column name="mMean" dataType="Double" displayName="Slope Distribution Mean"/>
<column
name="mSD"
dataType="Double"
displayName="Slope Distribution Standard Deviation"/>
<column name="b" dataType="Integer" displayName="Value for b"/>
</columns>
</datasheet>
</datasheets>
</datafeed>

<!--First Model Outputs / Second Model Inputs-->
<datafeed
name="IntermediateDatafeed"
displayName="Intermediate Outputs"
dataScope="Scenario">
<datasheets>
<datasheet name="IntermediateDatasheet">
<columns>
<column
name="IntermediateDatasheetID"
dataType="Integer"
isPrimary="True"/>
<column name="ScenarioID" dataType="Integer"/>
<column name="Iteration" dataType="Integer"/>
<column name="Timestep" dataType="Integer" displayName="Timestep"/>
<column name="y" dataType="Double" displayName="Value for y"/>
</columns>
</datasheet>
</datasheets>
</datafeed>

<!--Second Model Outputs-->
<datafeed name="OutputDatafeed" displayName="Outputs" dataScope="Scenario">
<datasheets>
<datasheet name="OutputDatasheet">
<columns>
<column name="OutputDatasheetID" dataType="Integer" isPrimary="True"/>
<column name="ScenarioID" dataType="Integer"/>
<column name="Iteration" dataType="Integer"/>
<column name="Timestep" dataType="Integer" displayName="Timestep"/>
<column name="yCum" dataType="Double" displayName="Cumulative y"/>
</columns>
</datasheet>
</datasheets>
</datafeed>

</datafeeds>
</transformer>

<!--First Transformer-->
<transformer
name="firstModel"
displayName="First Model"
isRunnable="True"
programName="Rscript"
programArguments="model.R"
configurationSheet="RunControl">
<pipeline>
<datafeed name="RunControl" type="Input"/>
<datafeed name="InputDatafeed" type="Input"/>
<datafeed name="IntermediateDatafeed" type="Output"/>
</pipeline>
</transformer>

<!--Second Transformer-->
<transformer
name="secondModel"
displayName="Second Model"
isRunnable="True"
programName="Rscript"
programArguments="model2.R"
configurationSheet="RunControl">
<pipeline>
<datafeed name="RunControl" type="Input"/>
<datafeed name="IntermediateDatafeed" type="Input"/>
<datafeed name="OutputDatafeed" type="Output"/>
</pipeline>
</transformer>

</transformers>
<layouts>

<!--Results Transformer Layout-->
<layout name="coreforms_ResultTransformers">
<item name="corestime_ChartTransformer"/>
</layout>

<!--Library Datafeeds Layout-->
<layout name="coreforms_LibraryDatafeeds">
<item name="core_Rconfig"/>
</layout>

<!--Scenario Datafeeds Layout-->
<layout name="coreforms_ScenarioDatafeeds">
<group name="RunControl" displayName="Run Control">
<item name="RunControl" displayName="General"/>
<item name="core_Pipeline"/>
</group>
<item name="InputDatafeed"/>
<item name="IntermediateDatafeed"/>
<item name="OutputDatafeed"/>
</layout>

<!--Charts Layout-->
<layout name="corestimeforms_Charts" configurationSheet="RunControl">
<item name="y" displayName="y" dataSheet="IntermediateDatasheet" column="y"/>
<item
name="yCum"
displayName="Cumulative y"
dataSheet="OutputDatasheet"
column="yCum"/>
</layout>

</layouts>
</package>

0 comments on commit 3683cb1

Please sign in to comment.