Package jasima.core.simulation.util
Interface SimOperations
-
- All Known Subinterfaces:
SimComponent,SimComponentContainer
- All Known Implementing Classes:
DynamicJobSource,DynamicShopExperiment,JobSource,MimacExperiment,Shop,ShopExperiment,SimComponentBase,SimComponentContainerBase,SimComponentRoot,SimEntity,Simulation,SimulationExperiment,StaticJobSource,StaticShopExperiment,WorkStation
public interface SimOperationsCommon location of simulation operations. Operations are either defined here or are calling the corresponding method inSimulation. This allows to access frequently used simulation methods in several places (e.g.,SimComponentwithout having to duplicate code, redirecting to simulation. Furthermore some code can be moved out ofSimulationto reduce its size.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSimOperations.SimEventTypeWhether an event is a normal/app event or a utility event.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T extends SimEntity>
TactivateEntity(T e)default voidaddComponent(SimComponent... scs)Convenience method to add a one or more new component(s) to the root component of this simulation.default voidaddResult(String name, Object value)default intcurrentPrio()Returns the current event's priority.default voidend()After calling end() the simulation is terminated (after handling the current event).default SimComponentContainergetRootComponent()SimulationgetSim()default RandominitRndGen(String streamName)Creates an instance of Java'sRandomclass initialized with a seed derived from the parameterstreamName.default <T extends DblSequence>
TinitRndGen(T s, String streamName)Initializes the random number generator associated with theDblSequences.default booleanisEndRequested()Returns true, ifend()was called and the simulation run ends after processing the current event.default booleanisTraceEnabled()Returns true is trace messages should be produced.default SimEventschedule(SimEvent event)Schedules a new event.default SimEventscheduleAt(double time, int prio, Runnable method)Schedules a call tomethodat a certain point in time.default SimEventscheduleAt(double time, int prio, Runnable method, SimOperations.SimEventType eventType)default SimEventscheduleAt(double time, Runnable method)default SimEventscheduleAt(double time, Runnable method, SimOperations.SimEventType eventType)default SimEventscheduleAt(long numUnits, TemporalUnit unit, int prio, Runnable method)Schedules a call tomethodat a certain amount of time specified bynumUnitsandunit.default SimEventscheduleAt(long numUnits, TemporalUnit unit, Runnable method)default SimEventscheduleAt(String description, double time, int prio, Runnable action)Schedules a call tomethodat a certain point in time.default SimEventscheduleAt(String description, double time, int prio, Runnable action, SimOperations.SimEventType eventType)Schedules a call tomethodat a certain point in time.default SimEventscheduleAt(String description, double time, Runnable action)default SimEventscheduleAt(String description, double time, Runnable action, SimOperations.SimEventType eventType)default SimEventscheduleAt(String description, long numUnits, TemporalUnit unit, int prio, Runnable method)Schedules a call tomethodat a certain amount of time specified bynumUnitsandunit.default SimEventscheduleAt(String description, long numUnits, TemporalUnit unit, Runnable method)default SimEventscheduleAt(String description, Instant time, int prio, Runnable method)Schedules a call tomethodat a certain point in time given as a Java Instant.default SimEventscheduleAt(String description, Instant time, Runnable method)default SimEventscheduleAt(Instant time, int prio, Runnable method)Schedules a call tomethodat a certain point in time given as a Java Instant.default SimEventscheduleAt(Instant time, Runnable method)default SimEventscheduleIn(double time, int prio, Runnable method)Schedules a call tomethodin a certain amount of time.default SimEventscheduleIn(double time, int prio, Runnable method, SimOperations.SimEventType eventType)default SimEventscheduleIn(double time, Runnable method)default SimEventscheduleIn(double time, Runnable method, SimOperations.SimEventType eventType)default SimEventscheduleIn(long numUnits, TemporalUnit unit, int prio, Runnable method)Schedules a call tomethodin a certain amount of time specified bynumUnitsandunit.default SimEventscheduleIn(long numUnits, TemporalUnit unit, Runnable method)default SimEventscheduleIn(String description, double time, int prio, Runnable method)Schedules a call tomethodin a certain amount of time.default SimEventscheduleIn(String description, double time, int prio, Runnable method, SimOperations.SimEventType eventType)Schedules a call tomethodin a certain amount of time.default SimEventscheduleIn(String description, double time, Runnable method)default SimEventscheduleIn(String description, double time, Runnable method, SimOperations.SimEventType eventType)default SimEventscheduleIn(String description, long numUnits, TemporalUnit unit, int prio, Runnable method)Schedules a call tomethodin a certain amount of time specified bynumUnitsandunit.default SimEventscheduleIn(String description, long numUnits, TemporalUnit unit, Runnable method)default SimEventscheduleIn(String description, Duration duration, int prio, Runnable method)Schedules a call tomethodin a certain amount of time.default SimEventscheduleIn(String description, Duration duration, Runnable method)default SimEventscheduleIn(Duration duration, int prio, Runnable method)Schedules a call tomethodin a certain amount of time.default SimEventscheduleIn(Duration duration, Runnable method)default voidschedulePeriodically(double firstInvocation, double interval, int prio, Runnable method)Periodically calls a certain method until the simulation terminates.default voidschedulePeriodically(double firstInvocation, double interval, int prio, BooleanSupplier method)Periodically calls a certain method.default voidscheduleProcess(double firstInvocation, int prio, DoubleSupplier method)default voidscheduleProcess(int prio, DoubleSupplier method)Calls a certain method at the times returned by the method itself.default doublesimTime()Returns the current simulation time.default InstantsimTimeAbs()Converts the current simulation time to a JavaInstant.default InstantsimTimeToInstant(double time)Returns the given simulation time as an Instant.default doubletoSimTime(long numUnits, TemporalUnit u)default doubletoSimTime(Duration d)default doubletoSimTime(Instant instant)default voidtrace(Object... params)Produces a trace message.
-
-
-
Method Detail
-
getSim
Simulation getSim()
-
getRootComponent
default SimComponentContainer getRootComponent()
-
addComponent
default void addComponent(SimComponent... scs)
Convenience method to add a one or more new component(s) to the root component of this simulation.
-
activateEntity
default <T extends SimEntity> T activateEntity(T e)
- See Also:
Simulation.activateEntity(SimEntity)
-
end
default void end()
After calling end() the simulation is terminated (after handling the current event). This method might also be called from an external thread.
-
isEndRequested
default boolean isEndRequested()
Returns true, ifend()was called and the simulation run ends after processing the current event.
-
simTime
default double simTime()
Returns the current simulation time.- See Also:
Simulation.simTime()
-
currentPrio
default int currentPrio()
Returns the current event's priority.- See Also:
Simulation.currentPrio()
-
simTimeAbs
default Instant simTimeAbs()
Converts the current simulation time to a JavaInstant.- See Also:
simTimeToInstant(double)
-
simTimeToInstant
default Instant simTimeToInstant(double time)
Returns the given simulation time as an Instant.- See Also:
Simulation.simTimeToInstant(double)
-
schedule
default SimEvent schedule(SimEvent event)
Schedules a new event.- See Also:
Simulation.schedule(SimEvent)
-
scheduleAt
default SimEvent scheduleAt(double time, int prio, Runnable method)
Schedules a call tomethodat a certain point in time. Instead of calling this method it is usually better to usescheduleAt(String, double, int, Runnable)instead, as the additional description parameter usually makes debugging easier.- Parameters:
time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(double time, Runnable method)
- See Also:
scheduleAt(double, int, Runnable)
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, double time, int prio, Runnable action)
Schedules a call tomethodat a certain point in time.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).action- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(double time, int prio, Runnable method, SimOperations.SimEventType eventType)
-
scheduleAt
default SimEvent scheduleAt(double time, Runnable method, SimOperations.SimEventType eventType)
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, double time, int prio, Runnable action, @Nullable SimOperations.SimEventType eventType)
Schedules a call tomethodat a certain point in time.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).action- The method to call at the given moment.eventType- Whether the event is a normal/app event or a utility event.nullis treated like an app event.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, double time, Runnable action, SimOperations.SimEventType eventType)
-
scheduleAt
default SimEvent scheduleAt(Instant time, int prio, Runnable method)
Schedules a call tomethodat a certain point in time given as a Java Instant. Usually usingscheduleAt(String, Instant, int, Runnable)should be preferred.- Parameters:
time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(Instant time, Runnable method)
- See Also:
scheduleAt(Instant, int, Runnable)
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, Instant time, int prio, Runnable method)
Schedules a call tomethodat a certain point in time given as a Java Instant.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, Instant time, Runnable method)
-
scheduleAt
default SimEvent scheduleAt(long numUnits, TemporalUnit unit, int prio, Runnable method)
Schedules a call tomethodat a certain amount of time specified bynumUnitsandunit.Usually using
scheduleAt(String, long, TemporalUnit, int, Runnable)should be preferred.- Parameters:
numUnits- The time duration.unit- The time unit ofnumUnits.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(long numUnits, TemporalUnit unit, Runnable method)
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, long numUnits, TemporalUnit unit, int prio, Runnable method)
Schedules a call tomethodat a certain amount of time specified bynumUnitsandunit.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).numUnits- The time.unit- The time unit ofnumUnits.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleAt
default SimEvent scheduleAt(@Nullable String description, long numUnits, TemporalUnit unit, Runnable method)
-
scheduleIn
default SimEvent scheduleIn(double time, int prio, Runnable method)
Schedules a call tomethodin a certain amount of time. In contrast toscheduleAt(double, int, Runnable)this method expects a relative time instead of an absolute one.Usually using
scheduleIn(String, double, int, Runnable)should be preferred.- Parameters:
time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(double time, Runnable method)
- See Also:
scheduleIn(double, int, Runnable)
-
scheduleIn
default SimEvent scheduleIn(double time, int prio, Runnable method, SimOperations.SimEventType eventType)
-
scheduleIn
default SimEvent scheduleIn(double time, Runnable method, SimOperations.SimEventType eventType)
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, double time, int prio, Runnable method)
Schedules a call tomethodin a certain amount of time. In contrast toscheduleAt(double, int, Runnable)this method expects a relative time instead of an absolute one.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, double time, int prio, Runnable method, SimOperations.SimEventType eventType)
Schedules a call tomethodin a certain amount of time. In contrast toscheduleAt(double, int, Runnable)this method expects a relative time instead of an absolute one.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).time- The time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.eventType- Whether the event is a normal/app event or a utility event.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, double time, Runnable method, SimOperations.SimEventType eventType)
- See Also:
#scheduleIn(String, double, int, Runnable, boolean)
-
scheduleIn
default SimEvent scheduleIn(Duration duration, int prio, Runnable method)
Schedules a call tomethodin a certain amount of time. In contrast toscheduleAt(double, int, Runnable)this method expects a relative time specified by aDurationinstead of an absolute one.Usually using
scheduleIn(String, Duration, int, Runnable)should be preferred.- Parameters:
duration- The duration from the current simulation time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(Duration duration, Runnable method)
- See Also:
scheduleIn(Duration, int, Runnable)
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, Duration duration, int prio, Runnable method)
Schedules a call tomethodin a certain amount of time. In contrast toscheduleAt(double, int, Runnable)this method expects a relative time specified by aDurationinstead of an absolute one.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).duration- The duration from the current simulation time when to callmethod.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, Duration duration, Runnable method)
-
scheduleIn
default SimEvent scheduleIn(long numUnits, TemporalUnit unit, int prio, Runnable method)
Schedules a call tomethodin a certain amount of time specified bynumUnitsandunit.Usually using
scheduleIn(String, long, TemporalUnit, int, Runnable)should be preferred.- Parameters:
numUnits- The time duration.unit- The time unit ofnumUnits.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(long numUnits, TemporalUnit unit, Runnable method)
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, long numUnits, TemporalUnit unit, int prio, Runnable method)
Schedules a call tomethodin a certain amount of time specified bynumUnitsandunit.- Parameters:
description- Some description that is added as an additional parameter to the Event object (makes debugging easier).numUnits- The time duration.unit- The time unit ofnumUnits.prio- Priority of the event (to deterministically sequence events at the same time).method- The method to call at the given moment.- Returns:
- The
SimEventthat was added to the event queue (to allow usage in, e.g.,Simulation.unschedule(SimEvent)).
-
scheduleIn
default SimEvent scheduleIn(@Nullable String description, long numUnits, TemporalUnit unit, Runnable method)
-
schedulePeriodically
default void schedulePeriodically(double firstInvocation, double interval, int prio, BooleanSupplier method)Periodically calls a certain method. While this method returns true, a next invocation after the given time interval is scheduled.
-
schedulePeriodically
default void schedulePeriodically(double firstInvocation, double interval, int prio, Runnable method)Periodically calls a certain method until the simulation terminates.
-
scheduleProcess
default void scheduleProcess(int prio, DoubleSupplier method)Calls a certain method at the times returned by the method itself. The first invocation is performed at the current time (asynchronously, i.e.,scheduleProcess()returns beforemethodis called for the first time). Subsequent calls are scheduled at the absolute times returned by the previous method invocation. No more invocations are scheduled ifmethodreturned NaN or a negative value.
-
scheduleProcess
default void scheduleProcess(double firstInvocation, int prio, DoubleSupplier method)
-
toSimTime
default double toSimTime(Instant instant)
- See Also:
Simulation.toSimTime(Instant)
-
toSimTime
default double toSimTime(Duration d)
- See Also:
Simulation.toSimTime(Duration)
-
toSimTime
default double toSimTime(long numUnits, TemporalUnit u)- See Also:
Simulation.toSimTime(long, TemporalUnit)
-
addResult
default void addResult(String name, Object value)
- See Also:
Simulation.addResult(String, Object)
-
trace
default void trace(Object... params)
Produces a trace message.- See Also:
Simulation.trace(Object...)
-
isTraceEnabled
default boolean isTraceEnabled()
Returns true is trace messages should be produced.- See Also:
Simulation.isTraceEnabled()
-
initRndGen
default <T extends DblSequence> T initRndGen(T s, String streamName)
Initializes the random number generator associated with theDblSequences. This just delegates to theRandomFactoryof a simulation.
-
initRndGen
default Random initRndGen(String streamName)
Creates an instance of Java'sRandomclass initialized with a seed derived from the parameterstreamName. This just delegates to the methodRandomFactory.createInstance(String)of a simulation.- See Also:
Simulation.initRndGen(String)
-
-