Class AbstractSimulationScript

java.lang.Object
org.opentrafficsim.swing.script.AbstractSimulationScript
All Implemented Interfaces:
EventListener, Checkable, EventListener

public abstract class AbstractSimulationScript extends Object implements EventListener, Checkable
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 Details

    • AbstractSimulationScript

      protected AbstractSimulationScript(String name, String description)
      Constructor.
      Parameters:
      name - name
      description - 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

      public void check() throws Exception
      Specified by:
      check in interface Checkable
      Throws:
      Exception
    • start

      public void start() throws Exception
      Starts the simulation.
      Throws:
      Exception - on any exception
    • notify

      public void notify(Event event)
      Specified by:
      notify in interface EventListener
    • getSimulator

      public OtsSimulatorInterface getSimulator()
      Returns the simulator.
      Returns:
      simulator
    • getNetwork

      public RoadNetwork 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

      protected OtsSimulationPanelDecorator getDecorator()
      Returns a decorator. The default implementation returns all default implementations of the decorator methods.
      Returns:
      decorator
    • setupSimulation

      protected abstract RoadNetwork setupSimulation(OtsSimulatorInterface sim) throws Exception
      Sets up the simulation based on provided properties. Properties can be obtained with getProperty(). 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