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>
myRandomList
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.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.-
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 void
advanceToNextSubstream()
Positions the RNG at the beginning of its next substreamprotected void
afterReplication()
after each replication reset the underlying random number generator to the next substreamprotected void
beforeExperiment()
before any replications reset the underlying random number generator to the starting streamboolean
contains(java.lang.Object arg0)
boolean
containsAll(java.util.Collection<?> arg0)
boolean
getAntitheticOption()
java.util.List<T>
getList()
Returns an unmodifiable view of the list of elementsT
getRandomElement()
RNStreamIfc
getRandomNumberStream()
boolean
getResetNextSubStreamOption()
Gets the current reset next substream option true means, that it is set to jump to the next substream after each replicationboolean
getResetStartStreamOption()
Gets the current Reset Start Stream Optionint
indexOf(java.lang.Object arg0)
boolean
isEmpty()
void
resetStartStream()
The resetStartStream method will position the RNG at the beginning of its stream.void
resetStartSubstream()
Resets the position of the RNG at the start of the current substreamvoid
setAntitheticOption(boolean flag)
Tells the stream to start producing antithetic variatesvoid
setRandomNumberStream(RNStreamIfc stream)
Sets the underlying random number streamvoid
setResetNextSubStreamOption(boolean b)
Sets the current reset next substream option true means, that it is set to jump to the next substream after each replicationvoid
setResetStartStreamOption(boolean b)
Sets the reset start stream option, true means that it will be reset to the starting streamint
size()
-
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:
getResetStartStreamOption
in 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:
setResetStartStreamOption
in 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:
getResetNextSubStreamOption
in 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:
setResetNextSubStreamOption
in interfaceStreamOptionIfc
- Parameters:
b
-
-
getRandomNumberStream
public final RNStreamIfc getRandomNumberStream()
- Specified by:
getRandomNumberStream
in interfaceGetRandomNumberStreamIfc
- Returns:
- the random number stream reference
-
setRandomNumberStream
public final void setRandomNumberStream(RNStreamIfc stream)
Description copied from interface:SetRandomNumberStreamIfc
Sets the underlying random number stream- Specified by:
setRandomNumberStream
in 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:RNStreamControlIfc
Positions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
resetStartStream
public final void resetStartStream()
Description copied from interface:RNStreamControlIfc
The 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:
resetStartStream
in interfaceRNStreamControlIfc
-
resetStartSubstream
public final void resetStartSubstream()
Description copied from interface:RNStreamControlIfc
Resets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstream
in interfaceRNStreamControlIfc
-
setAntitheticOption
public final void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfc
Tells the stream to start producing antithetic variates- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
flag
- true means that it produces antithetic variates.
-
getAntitheticOption
public final boolean getAntitheticOption()
- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on
-
beforeExperiment
protected void beforeExperiment()
before any replications reset the underlying random number generator to the starting stream- Overrides:
beforeExperiment
in classModelElement
-
afterReplication
protected void afterReplication()
after each replication reset the underlying random number generator to the next substream- Overrides:
afterReplication
in classModelElement
-
-