public class RandomWithSeedAccess extends java.util.Random implements SeedAccessibleRNG, java.io.Serializable
To use it, this class has to be instantiated as a custom generator in the experiment's Randomness section.
If you use incremented seeds from a fixed base, AnyLogic's threading strategies mean that the actual seed per run may not be what you expect. When giving a base seed S in the experiment, then for
(Use the three-parameter constructor in your experiments to see this.)
Constructor and Description |
---|
RandomWithSeedAccess()
Create an instance with a 'random' seed; we actually use the current
system time in milliseconds, which will always vary between instantiations.
|
RandomWithSeedAccess(long seed)
Convenience constructor to create an instance with the specified seed.
|
RandomWithSeedAccess(long seed,
boolean incrementFromFixedBase)
Create an instance with the given seed, specifying whether you want
future invocations to increment the actual seed from the one given here.
|
RandomWithSeedAccess(long seed,
boolean incrementFromFixedBase,
com.anylogic.engine.Engine _e)
Test-only version of the constructor where the relevant AnyLogic Engine
instance is passed in, and AnyLogic traceln calls are made to show you
information about the instantiation calls.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Long |
getBaseSeed()
Get the base seed used where you have created instances with incrementFromFixedBase
set to true (otherwise returns null).
|
long |
getSeed()
Get the seed value used for this instance (as per SeedAccessibleRNG interface).
|
public RandomWithSeedAccess()
public RandomWithSeedAccess(long seed)
seed
- The seed value.public RandomWithSeedAccess(long seed, boolean incrementFromFixedBase)
See the notes at the top of this class for important information about what incremented seeds will actually get applied for each run.
seed
- The seed value.incrementFromFixedBase
- Whether to use the seed value as a base for future invocations
(where the seed value specified will be ignored).public RandomWithSeedAccess(long seed, boolean incrementFromFixedBase, com.anylogic.engine.Engine _e)
seed
- The seed value. (Will be ignored if incrementFromFixedBase is
true and this is not the first instantiation.)incrementFromFixedBase
- Whether to increment the seeds used in each future
instantiation from the seed value (as a fixed base)._e
- A reference to the AnyLogic Engine. In an Experiment's
randomness settings, this is available as _e or via the
getEngine() call.public static java.lang.Long getBaseSeed()
public long getSeed()
getSeed
in interface SeedAccessibleRNG