Package nl.tudelft.simulation.dsol.model
Class AbstractDsolModel<T extends Number & Comparable<T>,S extends SimulatorInterface<T>>
java.lang.Object
org.djutils.event.LocalEventProducer
nl.tudelft.simulation.dsol.model.AbstractDsolModel<T,S>
- Type Parameters:
T
- the time typeS
- the simulator type to use
- All Implemented Interfaces:
Serializable
,Remote
,DsolModel<T,
,S> EventProducer
public abstract class AbstractDsolModel<T extends Number & Comparable<T>,S extends SimulatorInterface<T>>
extends LocalEventProducer
implements DsolModel<T,S>
AbstractDsolModel, an abstract helper class to easily construct a DsolModel. The model automatically acts as an
EventProducer, so events can be sent to statistics gathering classes.
Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
- Author:
- Alexander Verbraeck
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected InputParameterMap
the input parameters.protected List<SimulationStatistic<T>>
the output statistics.protected S
the simulator.protected StreamInformation
streams used in the replication.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Constructor Summary
ConstructorDescriptionAbstractDsolModel
(S simulator) Construct a DSOL model and set the simulator.AbstractDsolModel
(S simulator, StreamInformation streamInformation) Construct a DSOL model and set the simulator as well as the initial streams, so they can be used in the constructor of the model. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInputParameter
(AbstractInputParameter<?, ?> inputParameter) Add an input parameter to the list of input parameters.getInputParameter
(String key) Retrieve the value of an input parameter from the map of input parameters, based on a key.Get the input parameters for this model.Get the output statistics for this model.Return the simulator for this model.Return the available streams of the model stored in a StreamInformation object.void
setStreamInformation
(StreamInformation streamInformation) Set the initial streams of the model based on a StreamInformation object.Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nl.tudelft.simulation.dsol.model.DsolModel
constructModel, getDefaultStream, getStream, getStreams, resetStreams
-
Field Details
-
simulator
the simulator. -
inputParameterMap
the input parameters. -
outputStatistics
the output statistics. -
streamInformation
streams used in the replication.
-
-
Constructor Details
-
AbstractDsolModel
Construct a DSOL model and set the simulator.- Parameters:
simulator
- S; the simulator to use for this model- Throws:
NullPointerException
- when simulator is null
-
AbstractDsolModel
Construct a DSOL model and set the simulator as well as the initial streams, so they can be used in the constructor of the model.- Parameters:
simulator
- S; the simulator to use for this modelstreamInformation
- StreamInformation; the streams that have been prepared in a StreamInformation class- Throws:
NullPointerException
- when simulator or streamInformation is null
-
-
Method Details
-
setStreamInformation
Set the initial streams of the model based on a StreamInformation object. This method can be called right after the construction of the model object, or just before the model is constructed.
Note 1: If a model is run as part of an Experiment, the seeds of the random streams will be reset just before the call to constructModel(), so do not call this method from constructModel(), as it will reset the seeds to their initial values, and undo the seed management of the Experiment.
Note 2: The original streams are copied into the model, so they are not cloned (as the streams do not implement cloneable, and as they have inner state that needs to be preserved). So be careful with manipulating the streams in the streamInformation object afterward.- Specified by:
setStreamInformation
in interfaceDsolModel<T extends Number & Comparable<T>,
S extends SimulatorInterface<T>> - Parameters:
streamInformation
- StreamInformation; the streams that have been prepared in a StreamInformation class
-
getStreamInformation
Return the available streams of the model stored in a StreamInformation object.- Specified by:
getStreamInformation
in interfaceDsolModel<T extends Number & Comparable<T>,
S extends SimulatorInterface<T>> - Returns:
- streamInformation StreamInformation; the streams that have been prepared in a StreamInformation class
-
getSimulator
Return the simulator for this model.- Specified by:
getSimulator
in interfaceDsolModel<T extends Number & Comparable<T>,
S extends SimulatorInterface<T>> - Returns:
- the simulator for the model
-
getInputParameterMap
Get the input parameters for this model.- Specified by:
getInputParameterMap
in interfaceDsolModel<T extends Number & Comparable<T>,
S extends SimulatorInterface<T>> - Returns:
- List<InputParameter> the input parameters for this model
-
addInputParameter
public void addInputParameter(AbstractInputParameter<?, ?> inputParameter) throws InputParameterExceptionAdd an input parameter to the list of input parameters.- Parameters:
inputParameter
- AbstractInputParameter<?,?>; the input parameter to add- Throws:
InputParameterException
- in case an input parameter with the same key already exists
-
getInputParameter
Retrieve the value of an input parameter from the map of input parameters, based on a key. The key can use the 'dot notation' to access values in sub-maps of input parameters.- Parameters:
key
- String; the key of the input parameter to retrieve- Returns:
- the value belonging to the key, or null if the key could not be found
- Throws:
InputParameterException
- in case the input parameter with this key does not exist
-
getOutputStatistics
Get the output statistics for this model.- Specified by:
getOutputStatistics
in interfaceDsolModel<T extends Number & Comparable<T>,
S extends SimulatorInterface<T>> - Returns:
- List<StatisticsInterface> the output statistics for this model
-