Class FWSimSimulation
java.lang.Object
net.simplace.sim.FWSimSimulation
- All Implemented Interfaces:
Callable<FWSimVarMap>
A simulation is one configured run of the simulation model. It holds its own clone of the template
FWSimModel of the FWSimSolution, with a FWSimVarMap containing the start values (the
FWSimVariables) of this run, and the result caches of the outputs. It implements Callable, so several
simulations of a session can run in parallel in an executor; call() initializes, runs and finishes the
model and returns the final variable map.- Author:
- Andreas Enders
-
Constructor Summary
ConstructorsConstructorDescriptionFWSimSimulation(FWSimVarMap aVarMap, FWSimModel aModel) Creates a simulation: clones the template model with the given variable map. -
Method Summary
Modifier and TypeMethodDescriptioncall()Creates a copy of this simulation with cloned model and variable map.booleanTwo simulations are equal if they have the same simulation id.voidfinish()Finishes the simulation run: finishes the simulation outputs, notifies the session that the simulation has ended and logs the duration.getID()getModel()getName()getResultCache(String aName) getVariableValue(String aName) inthashCode()Identity hash code, deliberately not based on the simulation id likeequals(Object): the id of a simulation is only set when it runs, and existing hash maps (e.g.voidinit()Initializes the simulation run: initializes the model and notifies the session that the simulation has started.voidregisterResultCache(FWSimResultCache aCache) Registers a result cache of this simulation under its name.voidsetValue(String aColName, FWSimVariable.DATA_TYPE aDataType, Object aObject) Sets a value in the variable map of this simulation as variable of content typevar, so it can be used in the model.toString()
-
Constructor Details
-
FWSimSimulation
Creates a simulation: clones the template model with the given variable map. The name is taken from the variable map.- Parameters:
aVarMap- variable map with the start values of this simulationaModel- template model of the solution
-
-
Method Details
-
call
Runs the simulation:init(), the model run andfinish(). AnAbortSimulationExceptionis logged as warning.- Specified by:
callin interfaceCallable<FWSimVarMap>- Returns:
- the variable map after the model run, or
nullif the simulation was aborted - See Also:
-
init
public void init()Initializes the simulation run: initializes the model and notifies the session that the simulation has started. Errors are logged and passed to the session asFWSimulationErrorEvent.- Throws:
AbortSimulationException- if the model aborts during initialization; the simulation outputs are finished before
-
finish
public void finish()Finishes the simulation run: finishes the simulation outputs, notifies the session that the simulation has ended and logs the duration. Errors are logged and passed to the session asFWSimulationErrorEvent. -
registerResultCache
Registers a result cache of this simulation under its name.- Parameters:
aCache- the result cache
-
setValue
Sets a value in the variable map of this simulation as variable of content typevar, so it can be used in the model. Range errors are logged.- Parameters:
aColName- name of the variableaDataType- data type of the variableaObject- the value
-
getVarMap
- Returns:
- the variable map of the model of this simulation
-
getName
- Returns:
- the name of the simulation
-
getID
- Returns:
- the simulation id from the variable map
-
getVariableValue
-
getResultCache
- Parameters:
aName- name of the result cache- Returns:
- the result cache, or
nullif none is registered under this name
-
getCacheNames
-
getModel
- Returns:
- the model (clone of the template model) of this simulation
-
clone
Creates a copy of this simulation with cloned model and variable map.- Parameters:
aSimulationNumber- simulation number of the copy- Returns:
- the copy
-
equals
-
hashCode
public int hashCode()Identity hash code, deliberately not based on the simulation id likeequals(Object): the id of a simulation is only set when it runs, and existing hash maps (e.g. result caches per simulation in the result chart filler) rely on the identity order. -
toString
-