Package jsl.modeling.elements
Class RandomElement<T>
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.modeling.elements.RandomElement<T>
-
- All Implemented Interfaces:
RandomElementIfc,ObservableIfc,StreamOptionIfc,GetNameIfc,IdentityIfc,GetRandomNumberStreamIfc,RNStreamControlIfc,SetRandomNumberStreamIfc
- Direct Known Subclasses:
NWayByChanceQObjectSender
public class RandomElement<T> extends ModelElement implements RandomElementIfc
RandomElement allows for randomly selecting objects of type T according to a DEmpiricalList. This essentially allows DEmpiricalList to be a ModelElement
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.ModelElement
ModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
-
-
Field Summary
Fields Modifier and Type Field Description protected DEmpiricalList<T>myRandomListprotected booleanmyResetNextSubStreamOptionindicates whether or not the random variable's distribution has it stream reset to the next substream stream, or not, prior to each replication.protected booleanmyResetStartStreamOptionindicates whether or not the random variable's distribution has it stream reset to the default stream, or not prior to each experiment.-
Fields inherited from class jsl.simulation.ModelElement
AFTER_EXPERIMENT, AFTER_REPLICATION, BEFORE_EXPERIMENT, BEFORE_REPLICATION, CONDITIONAL_ACTION_REGISTRATION, DEFAULT_TIMED_EVENT_PRIORITY, INITIALIZED, MONTE_CARLO, myAfterExperimentOption, myAfterReplicationOption, myBeforeExperimentOption, myBeforeReplicationOption, myInitializationOption, myLengthOfWarmUp, myModelElements, myMonteCarloOption, myObservableComponent, myReplicationEndedOption, myTimedUpdateActionListener, myTimedUpdateEvent, myTimedUpdateInterval, myTimedUpdateOption, myTimedUpdatePriority, myWarmUpActionListener, myWarmUpEvent, myWarmUpIndicator, myWarmUpOption, myWarmUpPriority, NONE, REMOVED_FROM_MODEL, REPLICATION_ENDED, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TIMED_UPDATE, UPDATE, WARMUP
-
-
Constructor Summary
Constructors Constructor Description RandomElement(ModelElement parent, java.util.List<T> elements, double[] cdf)RandomElement(ModelElement parent, java.util.List<T> elements, double[] cdf, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvanceToNextSubstream()Positions the RNG at the beginning of its next substreamprotected voidafterReplication()after each replication reset the underlying random number generator to the next substreamprotected voidbeforeExperiment()before any replications reset the underlying random number generator to the starting streambooleancontains(java.lang.Object arg0)booleancontainsAll(java.util.Collection<?> arg0)booleangetAntitheticOption()java.util.List<T>getList()Returns an unmodifiable view of the list of elementsTgetRandomElement()RNStreamIfcgetRandomNumberStream()booleangetResetNextSubStreamOption()Gets the current reset next substream option true means, that it is set to jump to the next substream after each replicationbooleangetResetStartStreamOption()Gets the current Reset Start Stream OptionintindexOf(java.lang.Object arg0)booleanisEmpty()voidresetStartStream()The resetStartStream method will position the RNG at the beginning of its stream.voidresetStartSubstream()Resets the position of the RNG at the start of the current substreamvoidsetAntitheticOption(boolean flag)Tells the stream to start producing antithetic variatesvoidsetRandomNumberStream(RNStreamIfc stream)Sets the underlying random number streamvoidsetResetNextSubStreamOption(boolean b)Sets the current reset next substream option true means, that it is set to jump to the next substream after each replicationvoidsetResetStartStreamOption(boolean b)Sets the reset start stream option, true means that it will be reset to the starting streamintsize()-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication_, asString, beforeExperiment_, beforeReplication, beforeReplication_, buildEventGenerator, cancelTimedUpdateEvent, cancelWarmUpEvent, changeParentModelElement, checkForAfterExperiment, checkForAfterReplication, checkForBeforeExperiment, checkForBeforeReplication, checkForConditionalActionRegistration, checkForInitialize, checkForMonteCarlo, checkForRemoveFromModel, checkForReplicationEnded, checkForTimedUpdate, checkForUpdate, checkForWarmUp, checkObserverState, checkWarmUpOption, clearModelElementObservers, contains, countObservers, createEntity, createEntity, createQObject, day, deleteObserver, deleteObserverFromModelElements, deleteObservers, findModelElementWithWarmUpEvent, getAfterExperimentOption, getAfterReplicationOption, getAllCounters, getAllModelElements, getAllRandomElements, getAllResponseVariables, getAllVariables, getBeforeExperimentOption, getBeforeReplicationOption, getChildModelElementIterator, getCurrentReplicationNumber, getDefaultEntityType, getExecutive, getExperiment, getId, getInitializationOption, getInitializationOrderAsString, getLeftPreOrderTraversalCount, getLengthOfWarmUp, getModel, getModelElementCompartor, getModelElementsAsString, getModelElementsAsString, getModelElementsAsString, getMonteCarloOption, getName, getNumberOfModelElements, getObserverState, getParentModelElement, getPreviousObserverState, getReplicationEndedOption, getRightPreOrderTraversalCount, getSimulation, getSpatialModel, getStringLabel, getThisElementsCounters, getThisElementsModelElements, getThisElementsRandomVariables, getThisElementsResponseVariables, getThisElementsVariables, getTime, getTimedUpdateInterval, getTimedUpdateOption, getUpdateNotificationFlag, getVariable, getWarmUpEventTime, getWarmUpOption, hour, indent, initialize, initialize_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, removedFromModel, removeFromModel, replicationEnded, replicationEnded_, schedule, second, seize, setAfterExperimentOption, setAfterExperimentOptionForModelElements, setAfterReplicationOption, setAfterReplicationOptionForModelElements, setBeforeExperimentOption, setBeforeExperimentOptionForModelElements, setBeforeReplicationOption, setBeforeReplicationOptionForModelElements, setInitializationOption, setInitializationOptionForModelElements, setLengthOfWarmUp, setModel, setMonteCarloOption, setMonteCarloOptionForModelElements, setName, setObserverState, setParentModelElement, setReplicationEndedOption, setReplicationEndedOptionForModelElements, setSpatialModel, setStringLabel, setTimedUpdateInterval, setTimedUpdateOption, setTimedUpdateOptionForModelElements, setUpdateNotificationFlag, setWarmUpOption, setWarmUpOptionForModelElements, stopExecutive, stopExecutive, timedUpdate, timedUpdate_, toString, update, useControls, warmUp, warmUp_, week
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.random.rng.GetRandomNumberStreamIfc
getStreamNumber
-
Methods inherited from interface jsl.utilities.random.rng.SetRandomNumberStreamIfc
setRandomNumberStream
-
-
-
-
Field Detail
-
myResetStartStreamOption
protected boolean myResetStartStreamOption
indicates whether or not the random variable's distribution has it stream reset to the default stream, or not prior to each experiment. Resetting allows each experiment to use the same underlying random numbers i.e. common random numbers, this is the defaultSetting it to true indicates that it does reset
-
myResetNextSubStreamOption
protected boolean myResetNextSubStreamOption
indicates whether or not the random variable's distribution has it stream reset to the next substream stream, or not, prior to each replication. Resetting allows each replication to better ensure that each replication will be start at the same place in the substreams, thereby, improving sychronization when using common random numbers.Setting it to true indicates that it does jump to the next substream, true is the default
-
myRandomList
protected DEmpiricalList<T> myRandomList
-
-
Constructor Detail
-
RandomElement
public RandomElement(ModelElement parent, java.util.List<T> elements, double[] cdf)
- Parameters:
parent-
-
RandomElement
public RandomElement(ModelElement parent, java.util.List<T> elements, double[] cdf, java.lang.String name)
- Parameters:
parent-name-
-
-
Method Detail
-
getResetStartStreamOption
public final boolean getResetStartStreamOption()
Gets the current Reset Start Stream Option- Specified by:
getResetStartStreamOptionin interfaceStreamOptionIfc- Returns:
-
setResetStartStreamOption
public final void setResetStartStreamOption(boolean b)
Sets the reset start stream option, true means that it will be reset to the starting stream- Specified by:
setResetStartStreamOptionin interfaceStreamOptionIfc- Parameters:
b-
-
getResetNextSubStreamOption
public final boolean getResetNextSubStreamOption()
Gets the current reset next substream option true means, that it is set to jump to the next substream after each replication- Specified by:
getResetNextSubStreamOptionin interfaceStreamOptionIfc- Returns:
-
setResetNextSubStreamOption
public final void setResetNextSubStreamOption(boolean b)
Sets the current reset next substream option true means, that it is set to jump to the next substream after each replication- Specified by:
setResetNextSubStreamOptionin interfaceStreamOptionIfc- Parameters:
b-
-
getRandomNumberStream
public final RNStreamIfc getRandomNumberStream()
- Specified by:
getRandomNumberStreamin interfaceGetRandomNumberStreamIfc- Returns:
- the random number stream reference
-
setRandomNumberStream
public final void setRandomNumberStream(RNStreamIfc stream)
Description copied from interface:SetRandomNumberStreamIfcSets the underlying random number stream- Specified by:
setRandomNumberStreamin interfaceSetRandomNumberStreamIfc- Parameters:
stream- the reference to the random number stream, must not be null
-
getRandomElement
public final T getRandomElement()
- Returns:
- See Also:
DEmpiricalList.getRandomElement()
-
contains
public final boolean contains(java.lang.Object arg0)
- Parameters:
arg0-- Returns:
- See Also:
List.contains(java.lang.Object)
-
containsAll
public final boolean containsAll(java.util.Collection<?> arg0)
- Parameters:
arg0-- Returns:
- See Also:
List.containsAll(java.util.Collection)
-
indexOf
public final int indexOf(java.lang.Object arg0)
- Parameters:
arg0-- Returns:
- See Also:
List.indexOf(java.lang.Object)
-
isEmpty
public final boolean isEmpty()
- Returns:
- See Also:
List.isEmpty()
-
size
public final int size()
- Returns:
- See Also:
List.size()
-
getList
public final java.util.List<T> getList()
Returns an unmodifiable view of the list of elements- Returns:
-
advanceToNextSubstream
public final void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfcPositions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstreamin interfaceRNStreamControlIfc
-
resetStartStream
public final void resetStartStream()
Description copied from interface:RNStreamControlIfcThe resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.- Specified by:
resetStartStreamin interfaceRNStreamControlIfc
-
resetStartSubstream
public final void resetStartSubstream()
Description copied from interface:RNStreamControlIfcResets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstreamin interfaceRNStreamControlIfc
-
setAntitheticOption
public final void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfcTells the stream to start producing antithetic variates- Specified by:
setAntitheticOptionin interfaceRNStreamControlIfc- Parameters:
flag- true means that it produces antithetic variates.
-
getAntitheticOption
public final boolean getAntitheticOption()
- Specified by:
getAntitheticOptionin interfaceRNStreamControlIfc- Returns:
- true means on
-
beforeExperiment
protected void beforeExperiment()
before any replications reset the underlying random number generator to the starting stream- Overrides:
beforeExperimentin classModelElement
-
afterReplication
protected void afterReplication()
after each replication reset the underlying random number generator to the next substream- Overrides:
afterReplicationin classModelElement
-
-