.Modelica.Math.Random.Utilities.automaticGlobalSeed

Information

Syntax

seed = Utilities.automaticGlobalSeed();

Description

Returns an automatically computed seed (Integer). Typically, this seed is computed from:

  1. The current local time by computing the number of milli-seconds up to the current hour
  2. The process id (added to the first part by multiplying it with the prime number 6007).

If getTime and getPid functions are not available on the target where this Modelica function is called, other means to compute a seed may be used.

Note, this is an impure function that returns always a different value, when it is newly called. This function should be only called once during initialization.

Example

parameter Boolean useAutomaticSeed = false;
parameter Integer fixedSeed = 67867967;
final parameter Integer seed = if useAutomaticSeed then
                              Random.Utilities.automaticGlobalSeed() else fixedSeed;

See also

automaticLocalSeed.

Note

This function is impure!

Interface

impure function automaticGlobalSeed
  extends Modelica.Icons.Function;
  output Integer seed "Automatically generated seed";
end automaticGlobalSeed;

Revisions

Date Description
June 22, 2015
DLR logo Initial version implemented by A. Klöckner, F. v.d. Linden, D. Zimmer, M. Otter.
DLR Institute of System Dynamics and Control

Generated at 2024-11-21T19:25:40Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos