Package org.opentrafficsim.swing.script
Class AbstractSimulationScript
java.lang.Object
org.opentrafficsim.swing.script.AbstractSimulationScript
- All Implemented Interfaces:
EventListener,Checkable,EventListener
Template for simulation script. This class allows the user to run a single visualized simulation, or to batch-run the same
model. Parameters can be given through the command-line using djutils-ext. Fields can be added to sub-classes using the
@Options and similar annotations. Default values of the properties in this abstract class can be overwritten by the
sub-class using CliUtil.changeDefaultValue().
Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSimulationScript(String name, String description) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheck()protected OtsSimulationPanelDecoratorReturns a decorator.Returns the network.longgetSeed()Returns the seed.org.djunits.value.vdouble.scalar.DurationReturns the simulation time.Returns the simulator.org.djunits.value.vdouble.scalar.DurationReturns the start time.org.djunits.value.vdouble.scalar.DurationReturns the warm-up time.booleanReturns whether to auto-run.voidprotected voidMethod that is called when the simulation has ended.protected abstract RoadNetworkSets up the simulation based on provided properties.voidstart()Starts the simulation.
-
Constructor Details
-
AbstractSimulationScript
Constructor.- Parameters:
name- namedescription- description
-
-
Method Details
-
getSeed
public long getSeed()Returns the seed.- Returns:
- seed
-
getStartTime
public org.djunits.value.vdouble.scalar.Duration getStartTime()Returns the start time.- Returns:
- start time
-
getWarmupTime
public org.djunits.value.vdouble.scalar.Duration getWarmupTime()Returns the warm-up time.- Returns:
- warm-up time
-
getSimulationTime
public org.djunits.value.vdouble.scalar.Duration getSimulationTime()Returns the simulation time.- Returns:
- simulation time
-
isAutorun
public boolean isAutorun()Returns whether to auto-run.- Returns:
- whether to auto-run
-
check
-
start
Starts the simulation.- Throws:
Exception- on any exception
-
notify
- Specified by:
notifyin interfaceEventListener
-
getSimulator
Returns the simulator.- Returns:
- simulator
-
getNetwork
Returns the network.- Returns:
- network
-
onSimulationEnd
protected void onSimulationEnd()Method that is called when the simulation has ended. This can be used to store data. -
getDecorator
Returns a decorator. The default implementation returns all default implementations of the decorator methods.- Returns:
- decorator
-
setupSimulation
Sets up the simulation based on provided properties. Properties can be obtained withgetProperty(). Setting up a simulation should at least create a network and some demand. Additionally this may setup traffic control, sampling, etc.- Parameters:
sim- simulator- Returns:
- network
- Throws:
Exception- on any exception
-