RESPOND 2.4.0
Researching Effective Strategies to Prevent Opioid Death
Loading...
Searching...
No Matches
respond::Simulation Class Reference

Manages and executes multiple models in a coordinated simulation. A Simulation aggregates Model instances and coordinates their execution, maintaining history records and providing access to simulation results.

#include <simulation.hpp>

Public Member Functions

 Simulation ()
 Default constructor initializing with "console" logger.
 
 Simulation (const std::string &log_name)
 Constructs a Simulation with a specified logger.
 
 ~Simulation ()=default
 Virtual destructor for polymorphic cleanup.
 
void Run ()
 Executes one step of the simulation for all models. Calls RunTransitions() on each registered model in sequence.
 
void AddModel (const std::unique_ptr< Model > &model)
 Adds a model to the simulation. The model is cloned and managed by the simulation.
 
const std::vector< std::unique_ptr< Model > > & GetModels () const
 Retrieves all models in the simulation.
 
std::vector< std::string > GetModelNames () const
 Retrieves the names of all models in the simulation.
 
void ClearModels ()
 Removes all models from the simulation.
 
const std::vector< std::map< std::string, std::vector< Eigen::VectorXd > > > GetModelHistories () const
 Retrieves the complete state histories for all models.
 
const std::vector< std::map< std::string, History > > GetModelSparseHistories () const
 Retrieves sparse history objects for all models.
 
const std::vector< std::pair< std::string, std::string > > GetModelHistoryNames () const
 Retrieves pairs of (model name, history name) for all histories.
 
std::string GetLogName () const
 Retrieves the logger name used by this simulation.
 
 Simulation (const Simulation &other)
 Copy constructor creating an independent deep copy of the simulation. All models are cloned; modifications to the copy do not affect the original.
 
Simulationoperator= (const Simulation &other)
 Copy assignment operator for deep copying simulation state.
 

Constructor & Destructor Documentation

◆ Simulation()

respond::Simulation::Simulation ( const std::string &  log_name)
inline
Parameters
log_nameName of the logger for this simulation (default: "console").

Member Function Documentation

◆ AddModel()

void respond::Simulation::AddModel ( const std::unique_ptr< Model > &  model)
inline
Parameters
modelA unique_ptr to a Model instance to add.

◆ GetLogName()

std::string respond::Simulation::GetLogName ( ) const
inline
Returns
The name of the associated logger.

◆ GetModelHistories()

const std::vector< std::map< std::string, std::vector< Eigen::VectorXd > > > respond::Simulation::GetModelHistories ( ) const
inline
Returns
Vector of maps (one per model) mapping history names to state vector trajectories.

◆ GetModelHistoryNames()

const std::vector< std::pair< std::string, std::string > > respond::Simulation::GetModelHistoryNames ( ) const
inline
Returns
Vector of pairs associating each history with its parent model.

◆ GetModelNames()

std::vector< std::string > respond::Simulation::GetModelNames ( ) const
inline
Returns
Vector of model names in the order they were added.

◆ GetModels()

const std::vector< std::unique_ptr< Model > > & respond::Simulation::GetModels ( ) const
inline
Returns
Const reference to the vector of Model unique_ptrs.

◆ GetModelSparseHistories()

const std::vector< std::map< std::string, History > > respond::Simulation::GetModelSparseHistories ( ) const
inline
Returns
Vector of maps (one per model) mapping history names to sparse History objects.

◆ operator=()

Simulation & respond::Simulation::operator= ( const Simulation other)
inline
Parameters
otherThe simulation to copy from.
Returns
Reference to this simulation after assignment.

The documentation for this class was generated from the following file: