Package org.opentrafficsim.core.dsol
Class OTSSimulator
java.lang.Object
nl.tudelft.simulation.event.EventProducer
nl.tudelft.simulation.dsol.simulators.Simulator<A,R,T>
nl.tudelft.simulation.dsol.simulators.DEVSSimulator<Time,Duration,SimTimeDoubleUnit>
nl.tudelft.simulation.dsol.simulators.DEVSSimulator.TimeDoubleUnit
org.opentrafficsim.core.dsol.OTSSimulator
- All Implemented Interfaces:
Serializable,Runnable,Remote,DEVSSimulatorInterface<Time,Duration,SimTimeDoubleUnit>,DEVSSimulatorInterface.TimeDoubleUnit,SimulatorInterface<Time,Duration,SimTimeDoubleUnit>,SimulatorInterface.TimeDoubleUnit,nl.tudelft.simulation.event.EventProducerInterface,OTSSimulatorInterface
public class OTSSimulator extends DEVSSimulator.TimeDoubleUnit implements OTSSimulatorInterface, Serializable
Construct a DSOL DEVSSimulator the easy way.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2018-10-30 14:03:57 +0100 (Tue, 30 Oct 2018) $, @version $Revision: 4727 $, by $Author: pknoppers $,
initial version 12 nov. 2014
- Author:
- Peter Knoppers
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class nl.tudelft.simulation.dsol.simulators.DEVSSimulator
DEVSSimulator.CalendarDouble, DEVSSimulator.CalendarFloat, DEVSSimulator.CalendarLong, DEVSSimulator.TimeDouble, DEVSSimulator.TimeDoubleUnit, DEVSSimulator.TimeFloat, DEVSSimulator.TimeFloatUnit, DEVSSimulator.TimeLongNested classes/interfaces inherited from interface nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface
DEVSSimulatorInterface.CalendarDouble, DEVSSimulatorInterface.CalendarFloat, DEVSSimulatorInterface.CalendarLong, DEVSSimulatorInterface.TimeDouble, DEVSSimulatorInterface.TimeDoubleUnit, DEVSSimulatorInterface.TimeFloat, DEVSSimulatorInterface.TimeFloatUnit, DEVSSimulatorInterface.TimeLongNested classes/interfaces inherited from interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
SimulatorInterface.CalendarDouble, SimulatorInterface.CalendarFloat, SimulatorInterface.CalendarLong, SimulatorInterface.TimeDouble, SimulatorInterface.TimeDoubleUnit, SimulatorInterface.TimeFloat, SimulatorInterface.TimeFloatUnit, SimulatorInterface.TimeLong -
Field Summary
Fields inherited from class nl.tudelft.simulation.dsol.simulators.Simulator
replication, running, semaphore, simulatorTime, workerFields inherited from interface nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface
EVENTLIST_CHANGED_EVENTFields inherited from interface nl.tudelft.simulation.event.EventProducerInterface
FIRST_POSITION, LAST_POSITIONFields inherited from interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
END_REPLICATION_EVENT, START_EVENT, START_REPLICATION_EVENT, STEP_EVENT, STOP_EVENT, TIME_CHANGED_EVENT, WARMUP_EVENT -
Constructor Summary
Constructors Constructor Description OTSSimulator()Construct an OTSSimulator. -
Method Summary
Modifier and Type Method Description OTSReplicationgetReplication()voidinitialize(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model)Initialize a simulation engine without animation; the easy way.voidinitialize(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model, int replicationNr)Initialize a simulation engine without animation and prescribed replication number; the easy way.SimEvent<SimTimeDoubleUnit>scheduleEvent(Time executionTime, short priority, Object source, Object target, String method, Object[] args)Construct and schedule a SimEvent using a Time to specify the execution time.StringtoString()Methods inherited from class nl.tudelft.simulation.dsol.simulators.DEVSSimulator
autoPauseSimulator, cancelEvent, endReplication, getEventList, initialize, isPauseOnError, run, runUpTo, runUpToAndIncluding, scheduleEvent, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventNow, scheduleEventNow, scheduleEventNow, scheduleEventNow, scheduleEventRel, scheduleEventRel, scheduleEventRel, scheduleEventRel, setEventList, setPauseOnError, stepMethods inherited from class nl.tudelft.simulation.dsol.simulators.Simulator
cleanUp, getSimTime, getSimulatorTime, isRunning, start, start, step, stop, stopMethods inherited from class nl.tudelft.simulation.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, removeAllListeners, removeAllListeners, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface
cancelEvent, getEventList, isPauseOnError, runUpTo, runUpToAndIncluding, scheduleEvent, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventAbs, scheduleEventNow, scheduleEventNow, scheduleEventNow, scheduleEventNow, scheduleEventRel, scheduleEventRel, scheduleEventRel, scheduleEventRel, setEventList, setPauseOnErrorMethods inherited from interface nl.tudelft.simulation.event.EventProducerInterface
addListener, addListener, addListener, addListener, removeListenerMethods inherited from interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
endReplication, getSimTime, getSimulatorTime, initialize, isRunning, start, start, step, step, stop, stop
-
Constructor Details
-
OTSSimulator
public OTSSimulator()Construct an OTSSimulator.
-
-
Method Details
-
initialize
public void initialize(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model) throws SimRuntimeException, NamingExceptionInitialize a simulation engine without animation; the easy way. PauseOnError is set to true;- Specified by:
initializein interfaceOTSSimulatorInterface- Parameters:
startTime- Time; the start time of the simulationwarmupPeriod- Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what this is)runLength- Duration; the duration of the simulationmodel- OTSModelInterface; the simulation to execute- Throws:
SimRuntimeException- when e.g., warmupPeriod is larger than runLengthNamingException- when the context for the replication cannot be created
-
initialize
public void initialize(Time startTime, Duration warmupPeriod, Duration runLength, OTSModelInterface model, int replicationNr) throws SimRuntimeException, NamingExceptionInitialize a simulation engine without animation and prescribed replication number; the easy way. PauseOnError is set to true;- Specified by:
initializein interfaceOTSSimulatorInterface- Parameters:
startTime- Time; the start time of the simulationwarmupPeriod- Duration; the warm up period of the simulation (use new Duration(0, SECOND) if you don't know what this is)runLength- Duration; the duration of the simulationmodel- OTSModelInterface; the simulation to executereplicationNr- int; the replication number- Throws:
SimRuntimeException- when e.g., warmupPeriod is larger than runLengthNamingException- when context for the animation cannot be created
-
scheduleEvent
public final SimEvent<SimTimeDoubleUnit> scheduleEvent(Time executionTime, short priority, Object source, Object target, String method, Object[] args) throws SimRuntimeExceptionConstruct and schedule a SimEvent using a Time to specify the execution time.- Specified by:
scheduleEventin interfaceOTSSimulatorInterface- Parameters:
executionTime- Time; the time at which the event must happenpriority- short; should be between SimEventInterface.MAX_PRIORITY and SimEventInterface.MIN_PRIORITY; most normal events should use SimEventInterface.NORMAL_PRIORITYsource- Object; the object that creates/schedules the eventtarget- Object; the object that must execute the eventmethod- String; the name of the method oftargetthat must execute the eventargs- Object[]; the arguments of themethodthat must execute the event- Returns:
- SimEvent<SimTimeDoubleUnit>; the event that was scheduled (the caller should save this if a need to cancel the event may arise later)
- Throws:
SimRuntimeException- when theexecutionTimeis in the past
-
getReplication
- Specified by:
getReplicationin interfaceOTSSimulatorInterface- Specified by:
getReplicationin interfaceSimulatorInterface<Time,Duration,SimTimeDoubleUnit>- Overrides:
getReplicationin classDEVSSimulator.TimeDoubleUnit
-
toString
-