Simulation

During the simulation of a model, a Simulation object is constructed. The field names of the Simulation object is

  • model::Model: The model for which the Simulation is constructed.
  • path::String: The path of the directory into which all simulation-related files (log, data files etc.) are saved.
  • logger::AbstractLogger: The logger of the simulation constructed to log each stage of the Simulation .
  • state::Symbol: The state of the Simulation. The state may be :running if the simulation is running, :halted is the simulation is terminated without being completed, :done if it is terminated.
  • retcode::Symbol: The return code of the simulation. The retcode may be :success if the simulation is completed without errors, :failed if the an error occurs during the simulation.

Full API

Causal.SimulationType
mutable struct Simulation{MD, CK}

Constructs a Simulation object for the simulation of model. The Simulation object is used to monitor the state of the simulation of the model. simdir is the path of the directory into which the simulation files(log, data files etc.) are recorded. simname is the name of the Simulation and simprefix is the prefix of the name of the Simulation. logger is used to log the simulation steps of the model. See also: Model, Logging

Fields

  • model::Any

    Model to be simulated

  • clock::Any

    Simulation clock

  • path::String

    Path to which simulation files are recorded

  • logger::Union{Base.CoreLogging.SimpleLogger, Logging.ConsoleLogger}

    Simulation logger

  • state::Symbol

    Simulation state

  • retcode::Symbol

    Simulation return code

  • name::String

    Simulation name

source
Causal.SimulationErrorType
struct SimulationError <: Exception

Thrown when an error occurs during a simulation.

Fields

  • msg::String

    Error message

source
Causal.reportMethod
report(simulation)

Records the state of the simulation by writing all its fields into a data file. All the fields of the simulation is written into file. When the file is read back, the simulation object is constructed back. The data file is written under the path of the simulation.

source
Causal.setloggerMethod
setlogger(path, name; setglobal, loglevel)

Returns a logger. path is the path and name is the name of the file of the logger. If setglobal is true, the returned logger is a global logger.

Example

julia> logger = setlogger(tempdir(), "mylogger", setglobal=true)
Base.CoreLogging.SimpleLogger(IOStream(<file /tmp/mylogger>), Info, Dict{Any,Int64}())
source