diff --git a/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo b/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo index 4243c54cd0b..d80c900c2d1 100644 --- a/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo +++ b/Buildings/Occupants/BaseClasses/Validation/BinaryVariableGeneration.mo @@ -2,24 +2,32 @@ within Buildings.Occupants.BaseClasses.Validation; model BinaryVariableGeneration "Test model for binary variable generation function" extends Modelica.Icons.Example; - parameter Integer seed = 5 "Seed for the random number generator"; + parameter Integer localSeed = 10 + "Local seed to be used to generate the initial state of the random number generator"; + parameter Integer globalSeed = 30129 + "Global seed to be combined with the local seed"; Real p "Time-varying real number as input"; output Real y "Output"; protected parameter Modelica.Units.SI.Time t0(final fixed=false) "First sample time instant"; - Real curSeed "Current value for seed as a real-valued variable"; + Integer state[Modelica.Math.Random.Generators.Xorshift1024star.nState] + "State of the random number generator"; + Boolean r "Return value of random number generator"; initial equation y = 0; t0 = time; - curSeed = t0*seed; + state = Modelica.Math.Random.Generators.Xorshift1024star.initialState( + localSeed = localSeed, + globalSeed = globalSeed); + r = false; equation p = time; when sample(0, 0.1) then - curSeed = seed*1E6*time; - if Buildings.Occupants.BaseClasses.binaryVariableGeneration(p, globalSeed=integer(curSeed)) then + (r, state) = Buildings.Occupants.BaseClasses.binaryVariableGeneration(p, pre(state)); + if r then y = 1; else y = 0; @@ -37,6 +45,12 @@ Buildings.Occupants.BaseClasses.binaryVariableGeneration. ", revisions="