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

Buildings.Occupants use non-initialized localSeed #3549

Closed
mwetter opened this issue Oct 3, 2023 · 0 comments · Fixed by #3550
Closed

Buildings.Occupants use non-initialized localSeed #3549

mwetter opened this issue Oct 3, 2023 · 0 comments · Fixed by #3550
Assignees

Comments

@mwetter
Copy link
Member

mwetter commented Oct 3, 2023

Occupancy models in Buildings.Occupants don't initialize the localSeed, such as in

function binaryVariableGeneration "Binary variables random generator"
  input Real p(min=0, max=1) "Probaility of 1";
  input Integer globalSeed "Seed for the random number generator";
  output Boolean y "Random number";
protected 
  Integer localSeed "Local seed";
  Integer state[Modelica.Math.Random.Generators.Xorshift1024star.nState];
  Real r(min=0, max=1) "Generated random number";
algorithm 
  state := Modelica.Math.Random.Generators.Xorshift1024star.initialState(localSeed, globalSeed);
  (r, state) := Modelica.Math.Random.Generators.Xorshift1024star.random(state);
  y := r < p;
...
end binaryVariableGeneration;

This gives results that can change from one simulation to the other, as reported by OpenModelica.

The fix is to initialize localSeed.

@mwetter mwetter self-assigned this Oct 3, 2023
mwetter added a commit that referenced this issue Oct 3, 2023
mwetter added a commit that referenced this issue Oct 3, 2023
mwetter added a commit that referenced this issue Oct 3, 2023
mwetter added a commit that referenced this issue Oct 4, 2023
mwetter added a commit that referenced this issue Oct 4, 2023
mwetter added a commit that referenced this issue Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant