Skip to content

Commit

Permalink
Merge pull request #2 from ApexRMS/TST-StateAttributes
Browse files Browse the repository at this point in the history
Tst state attributes
  • Loading branch information
alexembrey authored Aug 24, 2020
2 parents b1fc64a + eedd6ea commit f7740df
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
// by using the '*' as shown below:
// <Assembly: AssemblyVersion("1.0.*")>

[assembly: AssemblyVersion("3.2.13.0")]
[assembly: AssemblyFileVersion("3.2.13.0")]
[assembly: AssemblyVersion("3.2.14.0")]
[assembly: AssemblyFileVersion("3.2.14.0")]
[assembly: NeutralResourcesLanguage("en-US")]


Expand Down
35 changes: 14 additions & 21 deletions src/Runtime/StockFlowTransformer.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,24 @@ private void GetStockValues(int stockTypeId, StochasticTimeRaster rastStockType)
}

private double GetAttributeValue(
int stateAttributeTypeId, int stratumId, int? secondaryStratumId, int? tertiaryStratumId,
int stateClassId, int iteration, int timestep, int age)
{
double val = 0.0;

double? v = this.STSimTransformer.GetAttributeValueByAge(
stateAttributeTypeId, stratumId, secondaryStratumId, tertiaryStratumId,
stateClassId, iteration, timestep, age);
int stateAttributeTypeId, int stratumId, int? secondaryStratumId, int? tertiaryStratumId,
int stateClassId, int iteration, int timestep, int age, TstCollection cellTst)
{
double val = 0.0;

if (!v.HasValue)
{
v = this.STSimTransformer.GetAttributeValueNoAge(
stateAttributeTypeId, stratumId, secondaryStratumId, tertiaryStratumId,
stateClassId, iteration, timestep);
}
double? v = this.STSimTransformer.GetAttributeValue(
stateAttributeTypeId, stratumId, secondaryStratumId, tertiaryStratumId,
stateClassId, iteration, timestep, age, cellTst);

if (v.HasValue)
{
val = v.Value;
}
if (v.HasValue)
{
val = v.Value;
}

return val;
}
return val;
}

protected bool AnyOutputOptionsSelected()
protected bool AnyOutputOptionsSelected()
{
DataRow dr = this.ResultScenario.GetDataSheet(Constants.DATASHEET_OO_NAME).GetDataRow();

Expand Down
11 changes: 8 additions & 3 deletions src/Runtime/StockFlowTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,13 @@ private void OnSTSimCellInitialized(object sender, CellEventArgs e)

foreach (InitialStockNonSpatial s in this.m_InitialStocksNonSpatial)
{
StockLimit lim = this.m_StockLimitMap.GetStockLimit(s.StockTypeId, e.SimulationCell.StratumId, e.SimulationCell.SecondaryStratumId, e.SimulationCell.TertiaryStratumId, e.SimulationCell.StateClassId, e.Iteration, e.Timestep);
double val = this.GetAttributeValue(s.StateAttributeTypeId, e.SimulationCell.StratumId, e.SimulationCell.SecondaryStratumId, e.SimulationCell.TertiaryStratumId, e.SimulationCell.StateClassId, e.Iteration, e.Timestep, e.SimulationCell.Age);
StockLimit lim = this.m_StockLimitMap.GetStockLimit(
s.StockTypeId, e.SimulationCell.StratumId, e.SimulationCell.SecondaryStratumId, e.SimulationCell.TertiaryStratumId,
e.SimulationCell.StateClassId, e.Iteration, e.Timestep);

double val = this.GetAttributeValue(
s.StateAttributeTypeId, e.SimulationCell.StratumId, e.SimulationCell.SecondaryStratumId, e.SimulationCell.TertiaryStratumId,
e.SimulationCell.StateClassId, e.Iteration, e.Timestep, e.SimulationCell.Age, e.SimulationCell.TstValues);

double v = val * this.m_STSimTransformer.AmountPerCell;
v = GetLimitBasedInitialStock(v, lim);
Expand Down Expand Up @@ -982,7 +987,7 @@ private double CalculateFlowAmount(FlowPathway fp, Cell cell, int iteration, int
{
FlowAmount = this.GetAttributeValue(
fp.StateAttributeTypeId.Value, cell.StratumId, cell.SecondaryStratumId,
cell.TertiaryStratumId, cell.StateClassId, iteration, timestep, cell.Age);
cell.TertiaryStratumId, cell.StateClassId, iteration, timestep, cell.Age, cell.TstValues);

FlowAmount *= this.m_STSimTransformer.AmountPerCell;
}
Expand Down
2 changes: 1 addition & 1 deletion src/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="stsimsf" displayName="Integrates stocks and flows into the ST-Sim simulation model" version="3.2.13" isAddOn="True" extendsPackage="stsim" url="https://github.com/ApexRMS/stsimsf">
<package name="stsimsf" displayName="Integrates stocks and flows into the ST-Sim simulation model" version="3.2.14" isAddOn="True" extendsPackage="stsim" url="https://github.com/ApexRMS/stsimsf">
<transformers>
<transformer name="Primary" displayName="Stocks and Flows" className="SyncroSim.STSimStockFlow.StockFlowTransformer" classAssembly="SyncroSim.STSimStockFlow" isPrimary="True" extendsTransformer="stsim_Runtime">
<datafeeds>
Expand Down

0 comments on commit f7740df

Please sign in to comment.