public abstract class Model extends Reportable
The modelcomponents belonging to a model have to be instantiated in the
init()
method. They must not be instantiated in the model's
constructor since most components need access to a valid experiment object.
This can only be accessed after a model has been connected to an experiment
using method connectToExperiment(Experiment exp)
which
implicitly calls the init()
method after receiving the valid
reference to an experiment.
Constructor and Description |
---|
Model(Model owner,
java.lang.String name,
boolean showInReport,
boolean showInTrace)
Constructs a model, with the given name and parameters for report and
trace files.
|
Modifier and Type | Method and Description |
---|---|
void |
connectToExperiment(Experiment exp)
Connects this model to an experiment.
|
ModelReporter |
createDefaultReporter()
Creates the default reporter associated with this model.
|
abstract java.lang.String |
description()
Should return the description of the model.
|
abstract void |
doInitialSchedules()
Implement this method to schedule the entities and/or events needed for
your model to start in a defined setting.
|
java.util.List<Entity> |
getEntities(boolean includeSubmodels)
Returns a list of this model's entities.
|
Entity |
getEntity(long ident)
Returns the entity to the belonging identifier.
|
Experiment |
getExperiment()
Returns the experiment that is connected to this model or
null if the model is not yet connected to an experiment. |
ModelParameterManager |
getParameterManager()
Returns the Model's viewpoint of the ParameterManager
|
java.util.List<Reportable> |
getReportables()
Returns a copy of the dynamic list containing all reportable
components of this model.
|
boolean |
hasSubModels()
Shows, if there are submodels registered with this model.
|
abstract void |
init()
Implement this method to do initialization work for your model.
|
void |
init(ModelOptions options)
Initializes the model by calling method
init() to set up
all model related components as specified in that method. |
boolean |
isConnected()
Shows if this model has already been connected to an experiment.
|
boolean |
isMainModel()
Shows if this model is a main model and thus is not submodel of other
models.
|
boolean |
isSubModel()
Shows if this model is submodel to another model and thus is not the main
models.
|
void |
register(Reportable r)
Registers a reportable at this model.
|
void |
reset()
Resets the statistic counters of this model and of all its registered
reportables.
|
getCorrespondingSchedulable, getDescription, getObservations, getReporter, incrementObservations, incrementObservations, reportIsOn, reportOff, reportOn, resetAt, setCorrespondingSchedulable, setDescription, setReporter
current, currentEntity, currentEntityAll, currentEvent, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
getName, getQuotedName, toString
public Model(Model owner, java.lang.String name, boolean showInReport, boolean showInTrace)
name
- java.lang.String : The name of this modelowner
- Model : The main model this model is associated toshowInTrace
- boolean : Flag for showing this model in trace-files. Set it
to true
if model should show up in trace,
false
if model should not be shown in trace.public void connectToExperiment(Experiment exp)
public ModelReporter createDefaultReporter()
description()
and appends the
simulation time of the last reset. If the user's model offers more
information, create a special class derived from class
desmoj.report.ModelReporter
to extract and present that
extra information.public abstract java.lang.String description()
public abstract void doInitialSchedules()
start()
method is called.public Entity getEntity(long ident)
Entity
or null if no such exists.public java.util.List<Entity> getEntities(boolean includeSubmodels)
includeSubmodels
- boolean : Do include (true) or exclude (false) submodels' entities in the list.Entity
.public Experiment getExperiment()
null
if the model is not yet connected to an experiment.null
if no connection is establishedpublic java.util.List<Reportable> getReportables()
public ModelParameterManager getParameterManager()
public boolean hasSubModels()
public abstract void init()
Caution! Do not use the Model's constructor method to instantiate your
modelcomponents!
This prevents the modelcomponents to get contact to the associated
Experiment since a Model can only be connected to an Experiment after
itself has been instantiated correctly. Thus it is necessary to put all
initialization and instantiation work into this method. Do not use this
method to do the initial schedules needed for the scheduler to start
with. Use method doInitialSchedules()
instead. If there
are no events scheduled in the event-list, the scheduler will stop the
simulation immediately because there is nothing for him to do. If you are
using submodels, take care that each of the submodels has its own
init
method properly set up.
public void init(ModelOptions options)
init()
to set up
all model related components as specified in that method. After
initializing the model, the given ModelOption's setOption()
method is called with this model as parameter. This enables the user to
specify different model parameter settings for different experiments. It
even allows automated parameter variation to give a small but handy aid
for model optimization. Implement the ModelOptions to set the parameters
for your model. Make sure to react properly on the ModelOptions given.
Note that specifiying ModelOptions is up to the user.options
- ModelOptions : The parameter settings for this modelpublic boolean isConnected()
true
, if model is connected to an
experiment, false
otherwisepublic boolean isMainModel()
true
if the model is a main
model, false
if it is a submodel of other modelspublic boolean isSubModel()
true
if the model is a submodel
of other models, false
if it is a main modelpublic void register(Reportable r)
r
- desmoj.core.simulator.Reportable : The reportable to be registeredpublic void reset()
reset()
methods.reset
in class Reportable