Package util
Record Class Randomness
java.lang.Object
java.lang.Record
util.Randomness
- Record Components:
seed
- The seed of this source of randomness. Values derived from this source are deterministic for a given seed and ID.
Provides random number generator seeds to support reproducible randomness that is robust to
different compositions of submodels with unique string identifiers.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.generatorFor
(String id) Return a random number generator to be used by a submodel with ID `id`.final int
hashCode()
Returns a hash code value for this object.next()
Return a new source of randomness that is next (after this one) in a deterministic sequence of randomness sources.randomnessFor
(String id) Return a new source of randomness to be used by a submodel with ID `id`.long
seed()
Returns the value of theseed
record component.long
Return an RNG seed to be used by a submodel with ID `id`.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
seed
private final long seedThe field for theseed
record component.
-
-
Constructor Details
-
Randomness
public Randomness(long seed) Creates an instance of aRandomness
record class.- Parameters:
seed
- the value for theseed
record component
-
-
Method Details
-
next
Return a new source of randomness that is next (after this one) in a deterministic sequence of randomness sources. This should only be called once on a source, as returned values are identical. This is useful for programs that want to run a sequence of independent simulations that is reproducible from a single initial seed. -
randomnessFor
Return a new source of randomness to be used by a submodel with ID `id`. This facilitates hierarchical submodels. -
seedFor
Return an RNG seed to be used by a submodel with ID `id`. -
generatorFor
Return a random number generator to be used by a submodel with ID `id`. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
seed
public long seed()Returns the value of theseed
record component.- Returns:
- the value of the
seed
record component
-