public class Experiment extends NamedObject
connectToExperiment(Experiment e)
method of the model instance
and pass the new experiment as a parameter.Modifier and Type | Field and Description |
---|---|
static int |
ABORTED
Status of an Experiment finished and to be cleared.
|
static int |
CONNECTED
Status of an Experiment connected to a Model and ready to be started.
|
static java.lang.String |
DEFAULT_DEBUG_OUTPUT_TYPE
The default debug output
|
static java.lang.String |
DEFAULT_ERROR_OUTPUT_TYPE
The default error output
|
static java.lang.String |
DEFAULT_REPORT_OUTPUT_TYPE
The default report output
|
static java.lang.String |
DEFAULT_TRACE_OUTPUT_TYPE
The default trace output
|
static int |
INITIALIZED
Status of an Experiment instantiated with all needed accessories
available.
|
static int |
NOT_INITIALIZED
Status of an Experiment just created without any accessories created yet.
|
static int |
RUNNING
Status of an Experiment currently running the simulation.
|
static int |
STARTED
Status of an Experiment being started.
|
static int |
STOPPED
Status of an Experiment stopped after having run.
|
Constructor and Description |
---|
Experiment(java.lang.String name)
Constructs a new Experiment with a given name.
|
Experiment(java.lang.String name,
boolean output)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
java.lang.String pathName)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
java.lang.String outputPath,
java.util.ArrayList<java.lang.String> reportOutputs,
java.util.ArrayList<java.lang.String> traceOutputs,
java.util.ArrayList<java.lang.String> errorOutputs,
java.util.ArrayList<java.lang.String> debugOutputs)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
java.lang.String pathName,
java.lang.String reportOutputType,
java.lang.String traceOutputType,
java.lang.String errorOutputType,
java.lang.String debugOutputType)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
java.lang.String outputPath,
TimeFormatter formatter,
java.util.ArrayList<java.lang.String> reportOutputs,
java.util.ArrayList<java.lang.String> traceOutputs,
java.util.ArrayList<java.lang.String> errorOutputs,
java.util.ArrayList<java.lang.String> debugOutputs)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
java.lang.String pathName,
TimeFormatter formatter,
java.lang.String reportOutputType,
java.lang.String traceOutputType,
java.lang.String errorOutputType,
java.lang.String debugOutputType)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
TimeFormatter formatter)
Constructs a new Experiment with the given parameters.
|
Experiment(java.lang.String name,
java.util.concurrent.TimeUnit epsilon,
java.util.concurrent.TimeUnit referenceUnit,
TimeFormatter formatter)
Deprecated.
Please use
Experiment(String name, TimeFormatter formatter)
or other constructors without TimeUnit s and set your episilon and
reference time unit by calling setEpsilon(TimeUnit epsilon) and
setReferenceUnit(java.util.concurrent.TimeUnit referenceUnit) . |
Modifier and Type | Method and Description |
---|---|
void |
addDebugReceiver(MessageReceiver trcRec)
Adds a messagereceiver for debugnotes to the experiment.
|
void |
addErrorReceiver(MessageReceiver trcRec)
Adds a messagereceiver for error messages to the experiment.
|
void |
addReceiver(MessageReceiver trcRec,
java.lang.Class<?> messageType)
Adds a messagereceiver for the given subtype of message to the
experiment.
|
void |
addTraceReceiver(MessageReceiver trcRec)
Adds a messagereceiver for tracenotes to the experiment.
|
boolean |
debugIsOn()
Returns a boolean indicating whether debug notes are forwarded to the
debug ouput or not.
|
void |
debugOff(TimeInstant stopTime)
Switches the debug output off at the given point of simulation time.
|
void |
debugOn(TimeInstant startTime)
Switches the debug output on at the given point of simulation time.
|
void |
debugPeriod(TimeInstant startTime,
TimeInstant stopTime)
Switches the debug output on for the given period of simulation time.
|
void |
deRegister(FileOutput file)
De-registers a file at the experiment.
|
void |
finish()
Stopps all running simprocesses that might still be scheduled and closes
the output files.
|
long |
getDelayInMillis()
Returns the delay between each step of the scheduler
|
static java.lang.String |
getDesmoJLicense(boolean html)
Returns the DESMO-J license
|
static java.lang.String |
getDesmoJVersion()
Returns the current DESMO-J version
|
DistributionManager |
getDistributionManager()
Returns the distributionmanager for this experiment.
|
java.util.concurrent.TimeUnit |
getEpsilonUnit()
Returns the epsilon value representing the granularity
of simulation time for this experiment.
|
double |
getExecutionSpeedRate()
Returns the current execution Speed Rate.
|
MessageDistributor |
getMessageManager()
Returns the messagemanager for this experiment.
|
Model |
getModel()
Returns the model that is connected to this experiment or
null if no model is connected so far. |
java.util.List<java.util.List<java.lang.String>> |
getOutputAppendixes() |
java.lang.String |
getOutputPath()
Returns the name of the path the experiment's report-, trace-, debug- and
error-files are written to.
|
long |
getRealTimeStartTime() |
java.util.concurrent.TimeUnit |
getReferenceUnit()
Returns the reference unit for this experiment.
|
ResourceDB |
getResourceDB()
Returns the resource database for this experiment.
|
Scheduler |
getScheduler()
Returns the scheduler for this experiment.
|
SimClock |
getSimClock()
Returns the simclock for this experiment.
|
java.util.List<ModelCondition> |
getStopConditions()
Returns the Conditions which can cause an experiment to stop.
|
TimeInstant |
getStopTime()
Returns the TimeInstant when the experiment is expected to stop running.
|
boolean |
hasError()
Determines whether or not an error or warning has yet occurred during
this experiment.
|
boolean |
isAborted()
Displays the current state of the simulation run.
|
boolean |
isConnected()
Shows if this experiment has already been connected to a model.
|
boolean |
isPreparing()
Shows if this experiment has not run yet.
|
boolean |
isRandomizingConcurrentEvents()
Returns if the event-list processes concurrent Events in random order or
not.
|
boolean |
isRunning()
Displays the current state of the simulation run.
|
boolean |
isShowProgressBar()
Returns if a progress bar should be displayed for this experiment or not.
|
boolean |
isShowProgressBarAutoclose()
Returns if the progress bar windows should be automatically closed after
the experiment or not.
|
boolean |
isStopped()
Displays the current state of the simulation run.
|
void |
proceed()
Proceeds with a stopped experiment.
|
void |
randomizeConcurrentEvents(boolean randomizing)
Determines if the event-list processes concurrent Events in random order
or not.
|
void |
register(OutputType file)
Registers a file output (Report, Trace, Error, Debug) in specific formats
(e.g.
|
void |
registerFileOutput(FileOutput file)
Registers a custom file output at the experiment, e.g.
|
void |
removeDebugReceiver(MessageReceiver msgRec)
Removes a messagereceiver for debugnotes from the experiment's
messagedistributor.
|
void |
removeErrorReceiver(MessageReceiver msgRec)
Removes a messagereceiver for errormessages from the experiment's
messagedistributor.
|
void |
removeReceiver(MessageReceiver msgRec)
Removes a messagereceiver from the experiment's messagedistributor.
|
void |
removeReceiver(MessageReceiver msgRec,
java.lang.Class<?> messageType)
Removes a messagereceiver for the given subtype of message from the
Experiment's messagedistributor.
|
void |
removeStopConditions()
Removes all conditions set to stop the experiment.
|
void |
removeTraceReceiver(MessageReceiver msgRec)
Removes a messagereceiver for tracenotes from the experiment's
messagedistributor.
|
void |
rename(java.lang.String newName)
Overrides inherited
NamedObjectImp.rename(String newName)
method to prevent the user from changing the experiment's name during an
experiment. |
void |
report()
Writes a report about the model connected top this experiment, its
reportable components and all related submodels into the report output.
|
void |
report(Model m)
Writes a report about the given model which has to be connected to this
experiment as main model or as a submodel.
|
static void |
setCoroutineModel(CoroutineModel model)
Sets the coroutine model.
|
void |
setDelayInMillis(long delay)
Sets the delay between each step of the scheduler.
|
static void |
setEpsilon(java.util.concurrent.TimeUnit epsilon)
Sets the epsilon value representing the granularity of simulation time to
the given TimeUnit parameter.
|
void |
setExecutionSpeedRate(double rate)
Sets the speed rate for an execution that is proportional to wall-clock
time (real time).
|
void |
setRandomNumberGenerator(java.lang.Class<? extends UniformRandomGenerator> randomNumberGenerator)
Sets the underlying pseudo random number generator to be used by all
distributions created from now on.
|
static void |
setReferenceUnit(java.util.concurrent.TimeUnit referenceUnit)
Sets the reference time unit specifying what is meant by the simulation
time step of 1 in statements without an explicit declaration of a time
unit like in
new TimeSpan(5) . |
void |
setSeedGenerator(long seed)
Sets the seed of the SeedGenerator to the given value.
|
void |
setShowProgressBar(boolean newShowProgressBar)
Sets the new value for showing the progress bar for this experiment or
not.
|
void |
setShowProgressBarAutoclose(boolean autoclose)
Sets the new value for automatically dismissing the progress bar
for this experiment after completion.
|
void |
setSilent(boolean silent)
Sets the new value for displaying basic experiment notifications like
'experiment started', 'experiment stopped' oder 'experiment resumed'
at the system output.
|
static void |
setTimeFormatter(TimeFormatter format)
Sets the
TimeFormatter to be used for output of time strings. |
void |
start()
Starts the simulation with default start time 0.
|
void |
start(TimeInstant initTime)
Starts the experiment with the given simulation time as starting time.
|
void |
stop()
Stops the simulation at the current simulation time (immediately).
|
void |
stop(ModelCondition stopCond)
Specifies a ModelCondition to stop the simulation.
|
void |
stop(TimeInstant stopTime)
Stops the simulation at the given point of simulation time.
|
boolean |
traceIsOn()
Returns a boolean indicating whether trace notes are forwarded to the
trace ouput or not.
|
void |
traceOff(TimeInstant stopTime)
Switches the trace output off at the given point of simulation time.
|
void |
traceOn(TimeInstant startTime)
Switches the trace output on at the given point of simulation time.
|
void |
tracePeriod(TimeInstant startTime,
TimeInstant stopTime)
Switches the trace output on for the given period of simulation time.
|
void |
writeReport(Model m,
java.lang.String suffix)
Triggers the reporters of the given model or submodel to write their
report data into the report output registered at the experiment's
messagemanager.
|
void |
writeReport(java.lang.String suffix)
Triggers the reporters to write their data into the report output
registered at the experiment's messagemanager.
|
getName, getQuotedName, toString
public static final java.lang.String DEFAULT_REPORT_OUTPUT_TYPE
public static final java.lang.String DEFAULT_TRACE_OUTPUT_TYPE
public static final java.lang.String DEFAULT_ERROR_OUTPUT_TYPE
public static final java.lang.String DEFAULT_DEBUG_OUTPUT_TYPE
public static final int NOT_INITIALIZED
public static final int INITIALIZED
public static final int CONNECTED
public static final int STARTED
public static final int STOPPED
public static final int RUNNING
public static final int ABORTED
public Experiment(java.lang.String name)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.public Experiment(java.lang.String name, boolean output)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.output
- boolean : This flag indicates if the experiment should write
output files in the default format (HTML) or no output files
at all.public Experiment(java.lang.String name, java.lang.String pathName)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.pathName
- java.lang.String : The output path for report filespublic Experiment(java.lang.String name, TimeFormatter formatter)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.formatter
- desmoj.core.simulator.TimeFormatter: Defines how time values
will be formatted in the output files.TimeUnit
public Experiment(java.lang.String name, java.lang.String pathName, java.lang.String reportOutputType, java.lang.String traceOutputType, java.lang.String errorOutputType, java.lang.String debugOutputType)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.pathName
- java.lang.String : The output path for report filesreportOutputType
- traceOutputType
- errorOutputType
- debugOutputType
- public Experiment(java.lang.String name, java.lang.String pathName, TimeFormatter formatter, java.lang.String reportOutputType, java.lang.String traceOutputType, java.lang.String errorOutputType, java.lang.String debugOutputType)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.pathName
- java.lang.String : The output path for report filesformatter
- desmoj.core.simulator.TimeFormatter: Defines how time values
will be formatted in the output files.public Experiment(java.lang.String name, java.lang.String outputPath, TimeFormatter formatter, java.util.ArrayList<java.lang.String> reportOutputs, java.util.ArrayList<java.lang.String> traceOutputs, java.util.ArrayList<java.lang.String> errorOutputs, java.util.ArrayList<java.lang.String> debugOutputs)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.outputPath
- java.lang.String : The output path for report filesformatter
- desmoj.core.simulator.TimeFormatter: Defines how time values
will be formatted in the output files.TimeUnit
public Experiment(java.lang.String name, java.lang.String outputPath, java.util.ArrayList<java.lang.String> reportOutputs, java.util.ArrayList<java.lang.String> traceOutputs, java.util.ArrayList<java.lang.String> errorOutputs, java.util.ArrayList<java.lang.String> debugOutputs)
name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.outputPath
- java.lang.String : The output path for report files@Deprecated public Experiment(java.lang.String name, java.util.concurrent.TimeUnit epsilon, java.util.concurrent.TimeUnit referenceUnit, TimeFormatter formatter)
Experiment(String name, TimeFormatter formatter)
or other constructors without TimeUnit
s and set your episilon and
reference time unit by calling setEpsilon(TimeUnit epsilon)
and
setReferenceUnit(java.util.concurrent.TimeUnit referenceUnit)
.name
- String : The name of the experiment determining the
outputfile's names, too. So please avoid characters that your
local filesystem does not support in filenames.epsilon
- java.util.concurrent.TimeUnit: Ignored.referenceUnit
- java.util.concurrent.TimeUnit: Ignored.formatter
- desmoj.core.simulator.TimeFormatter: Defines how time values
will be formatted in the output files.public void addDebugReceiver(MessageReceiver trcRec)
trcRec
- desmoj.report.MessageReceiver : The new messagereceiver for
the given type of messagespublic void addErrorReceiver(MessageReceiver trcRec)
trcRec
- desmoj.report.MessageReceiver : The new messagereceiver for
the given type of messagespublic void addReceiver(MessageReceiver trcRec, java.lang.Class<?> messageType)
trcRec
- desmoj.report.MessageReceiver : The new messagereceiver for
the given type of messagesmessageType
- Class : The type of message to be sent to the given
messagereceiverpublic void addTraceReceiver(MessageReceiver trcRec)
trcRec
- desmoj.report.MessageReceiver : The new messagereceiver for
the given type of messagespublic boolean debugIsOn()
debugOn(TimeInstant startTime)
or
debugOff(TimeInstant stopTime)
public void debugOff(TimeInstant stopTime)
stopTime
- TimeInstant : The point in simulation time to switch off debugpublic void debugOn(TimeInstant startTime)
startTime
- TimeInstant : The point in simulation time to switch on debugpublic void debugPeriod(TimeInstant startTime, TimeInstant stopTime)
startTime
- TimeInstant : The point in simulation time to switch debug onstopTime
- TimeInstant : The point in simulation time to switch debug offpublic void deRegister(FileOutput file)
file
- desmoj.report.FileOutput : The file to be closed with the end
of an Experimentpublic void finish()
public DistributionManager getDistributionManager()
public java.util.concurrent.TimeUnit getEpsilonUnit()
public double getExecutionSpeedRate()
public MessageDistributor getMessageManager()
public Model getModel()
null
if no model is connected so far.null
if no connection is established.public java.lang.String getOutputPath()
public java.util.List<java.util.List<java.lang.String>> getOutputAppendixes()
public long getRealTimeStartTime()
public java.util.concurrent.TimeUnit getReferenceUnit()
public ResourceDB getResourceDB()
Res
objects need access to the resource database to note their resource
allocations and requests and for deadlock detection.public Scheduler getScheduler()
public SimClock getSimClock()
public TimeInstant getStopTime()
public java.util.List<ModelCondition> getStopConditions()
public void removeStopConditions()
public boolean isAborted()
true
if the simulation is aborted,
false
if it has not started yet or is still runningpublic boolean isConnected()
true
, if experiment is connected to a
model, false
otherwisepublic boolean isPreparing()
true
, if experiment is not running yet,
false
otherwisepublic boolean isRandomizingConcurrentEvents()
true
if concurrent Events are randomized,
false
otherwisepublic boolean isRunning()
true
if the simulation is running,
false
if it has not started yet or has already
finishedpublic boolean isShowProgressBar()
true
if a progress bar should be displayed
for this experiment, false
otherwise.public boolean isStopped()
true
, if experiment is stopped,
false
otherwisepublic boolean hasError()
True
if at least one error has occurred
in the model connected to this experiment or one of its submodels,
false
otherwisepublic void proceed()
RUNNING
to some other
state, the scheduler runs out of scheduled events or if the
check()
method of the given stop Condition
returns true
after an event has been processed.public void setDelayInMillis(long delay)
delay
- : Delay time in milliseconds as a long valuepublic long getDelayInMillis()
public void register(OutputType file)
file
- desmoj.report.FileOutput : The file to be closed with the end
of an experimentpublic void registerFileOutput(FileOutput file)
file
- desmoj.report.FileOutput : The file to be closed with the end
of an experimentpublic void removeDebugReceiver(MessageReceiver msgRec)
removeReceiverAll(MessageReceiver msgRec)
to remove a
messagereceiver from all types of messages.msgRec
- desmoj.report.MessageReceiver : The new messagereceiver to be
removed from the messagedistributor's list for the given
messagetypepublic void removeErrorReceiver(MessageReceiver msgRec)
removeReceiverAll(MessageReceiver msgRec)
to remove a
messagereceiver from all types of messages.msgRec
- desmoj.report.MessageReceiver : The new messagereceiver to be
removed from the vessagedistributor's list for the given
messagetypepublic void removeReceiver(MessageReceiver msgRec)
removeReceiver(MessageReceiver msgRec, Class
messageType)
to remove the messagereceiver from one type of
messages only.msgRec
- desmoj.report.MessageReceiver : The new messagereceiver to be
removed from the messagedistributor's list for the given
messagetypepublic void removeReceiver(MessageReceiver msgRec, java.lang.Class<?> messageType)
removeReceiverAll(MessageReceiver msgRec)
to remove a
messagereceiver from all types of messages.msgRec
- desmoj.report.MessageReceiver : The new messagereceiver to be
removed from the messagedistributor's list for the given
messagetypemessageType
- Class : The type of message not to be sent to the given
messagereceiverpublic void removeTraceReceiver(MessageReceiver msgRec)
removeReceiverAll(MessageReceiver msgRec)
to remove a
messagereceiver from all types of messages.msgRec
- desmoj.report.MessageReceiver : The new messagereceiver to be
removed from the messagedistributor's list for the given
messagetypepublic void rename(java.lang.String newName)
NamedObjectImp.rename(String newName)
method to prevent the user from changing the experiment's name during an
experiment. Renaming is not allowed with experiments, since it would not
allow the user to identify the reports produced by an experiment. The
method simply returns without changing the experiment's name, ignoring
the given parameter.newName
- java.lang.String : The parameter given is not taken as the new
name, method simply returnspublic void report()
public void report(Model m)
public static void setTimeFormatter(TimeFormatter format)
TimeFormatter
to be used for output of time strings.
Observe that if this method is called before creating an Experiment
object, a non-null TimeFormatter
passed to the Experiment
's
constructor will overwrite the setting of this method-format
- TimeFormatter : the formatter to be used for formatting time
Strings.public void randomizeConcurrentEvents(boolean randomizing)
randomizing
- boolean :true
forces random order,
false
forces "linear" orderpublic void setExecutionSpeedRate(double rate)
rate
- double : The execution speed ratepublic void setSeedGenerator(long seed)
seed
- long : The seed for the SeedGeneratorpublic void setRandomNumberGenerator(java.lang.Class<? extends UniformRandomGenerator> randomNumberGenerator)
randomNumberGenerator
- Class : The random number generator class to be usedLinearCongruentialRandomGenerator
,
UniformRandomGenerator
public void setShowProgressBar(boolean newShowProgressBar)
newShowProgressBar
- boolean : set it to true
if a progress bar should
be displayed; for not showing the progress bar of this
experiment set it to false
.public void setShowProgressBarAutoclose(boolean autoclose)
Not that a call to this method has no impact if the progress bar
is suppessed by invoking setShowProgressBar(false)
.
Must be called before the experiment is started.
autoclose
- boolean : if set to true
, the progress bar will be
automaticalled closed one the experiment terminates. If set to
false
(default), the progress bar window persists after the
experiment terminates until closed by the user.public boolean isShowProgressBarAutoclose()
setShowProgressBar(false)
.true
if a progress bar should be automatically
closed after this experiment, while false
(default) indicates
that the progress bar window persists after the experiment terminates
until closed by the user..public static void setEpsilon(java.util.concurrent.TimeUnit epsilon)
TimeInstant
, TimeSpan
) have been created as
existing TimeSpan
and TimeInstant
objects will
point to wrong spans/durations.
Default is TimeUnit.MICROSECONDS
.epsilon
- TimeUnit : The granularity of simulation time, i.e. the
smallest distinguishable span of simulation time.public static void setReferenceUnit(java.util.concurrent.TimeUnit referenceUnit)
new TimeSpan(5)
.
Default is TimeUnit.SECONDS
.referenceUnit
- TimeUnit : the reference time unitpublic void setSilent(boolean silent)
silent
- boolean : set it to true
to suppress notifications
or false
to print them.public void start()
stop(TimeInstant stopTime)
method has to be called first!public void start(TimeInstant initTime)
stop
method has to be called first.
StopCondition
s can be given alternatively.initTime
- TimeInstant : The starting time instantpublic void stop(ModelCondition stopCond)
stopCond
- ModelCondition : A condition to stop the simulation once
it's check() methode returns true.public void stop(TimeInstant stopTime)
stopTime
- desmoj.TimeInstant : The point of simulation time to stop the
simulationpublic void stop()
public boolean traceIsOn()
traceOn(TimeInstant startTime)
and
traceOff(TimeInstant stopTime)
true
public void traceOff(TimeInstant stopTime)
stopTime
- TimeInstant : The point in simulation time to switch trace offpublic void traceOn(TimeInstant startTime)
startTime
- TimeInstant : The point in simulation time to switch trace onpublic void tracePeriod(TimeInstant startTime, TimeInstant stopTime)
startTime
- TimeInstant : The point in simulation time to switch trace onstopTime
- TimeInstant : The point in simulation time to switch trace offpublic void writeReport(Model m, java.lang.String suffix)
m
- desmoj.Modelsuffix
- java.lang.String : Suffix for report filename if multiple
reports are drawnpublic void writeReport(java.lang.String suffix)
suffix
- java.lang.String : Suffix for report filename if multiple
reports are drawnpublic static java.lang.String getDesmoJVersion()
public static java.lang.String getDesmoJLicense(boolean html)
html
- boolean: Include link (HTML, true) or not (plain text, false)html
is set true.public static void setCoroutineModel(CoroutineModel model)