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

Abstract base class representing a state transition model. Models manage a state vector, execute transitions, and maintain history of state changes. Subclasses must implement state management, transition execution, and history tracking.

#include <model.hpp>

Public Member Functions

virtual ~Model ()=default
 Virtual destructor for proper polymorphic cleanup.
 
virtual void SetState (const Eigen::VectorXd &state)=0
 Sets the current state of the model.
 
virtual Eigen::VectorXd GetState () const =0
 Retrieves the current state of the model.
 
virtual void RunTransitions ()=0
 Executes all registered transitions on the current state. Transitions are applied in the order they were added and may modify history.
 
virtual void AddTransition (const std::unique_ptr< Transition > &t)=0
 Adds a transition to the model.
 
virtual std::vector< std::string > GetTransitionNames () const =0
 Retrieves the names of all registered transitions.
 
virtual void ClearTransitions ()=0
 Clears all registered transitions. Deletes all stored Transition unique_ptrs.
 
virtual std::map< std::string, HistoryGetHistories () const =0
 Retrieves the history records for all state variables.
 
virtual void CreateDefaultHistories ()=0
 Creates default history tracking for the model. This method initializes standard history records based on the model's state.
 
virtual void SetHistories (const std::map< std::string, History > &h)=0
 Sets the history records for the model.
 
virtual void ClearHistories ()=0
 Clears all history records and resets history tracking state.
 
virtual void SetHistoryCaptureInterval (int interval)=0
 Sets the global history capture interval for this model.
 
virtual int GetHistoryCaptureInterval () const =0
 Retrieves the global history capture interval.
 
virtual void SetFinalTimestep (int final_timestep)=0
 Sets the final timestep that must always be recorded.
 
virtual int GetFinalTimestep () const =0
 Retrieves the final timestep forced into history output.
 
virtual std::string GetModelName () const =0
 Retrieves the name identifier for this model.
 
virtual std::string GetLogName () const =0
 Retrieves the logger name used by this model.
 
 Model (const Model &)=delete
 Deleted copy constructor (models are non-copyable by public API).
 
Modeloperator= (const Model &)=delete
 Deleted copy assignment operator (models are non-copyable by public API).
 
virtual std::unique_ptr< Modelclone () const =0
 Creates a deep copy of this model.
 

Static Public Member Functions

static std::unique_ptr< ModelCreate (const std::string &name, const std::string &log_name="console")
 Factory method to create a Model instance.
 

Protected Member Functions

 Model ()=default
 Protected default constructor for subclass initialization. Not intended for direct public use.
 

Member Function Documentation

◆ AddTransition()

virtual void respond::Model::AddTransition ( const std::unique_ptr< Transition > &  t)
pure virtual
Parameters
tA unique_ptr to a Transition object. The model assumes ownership.

◆ clone()

virtual std::unique_ptr< Model > respond::Model::clone ( ) const
pure virtual
Returns
A unique_ptr to an independent copy of this model.

◆ Create()

static std::unique_ptr< Model > respond::Model::Create ( const std::string &  name,
const std::string &  log_name = "console" 
)
static
Parameters
nameThe name identifier for the model to create.
log_nameName of the logger for this model (default: "console").
Returns
A unique_ptr to the newly created Model instance.

◆ GetFinalTimestep()

virtual int respond::Model::GetFinalTimestep ( ) const
pure virtual
Returns
The configured final simulation timestep, or -1 if unset.

◆ GetHistories()

virtual std::map< std::string, History > respond::Model::GetHistories ( ) const
pure virtual
Returns
A map of history names to History objects containing state trajectories.

◆ GetHistoryCaptureInterval()

virtual int respond::Model::GetHistoryCaptureInterval ( ) const
pure virtual
Returns
The active capture interval. A value of 1 means full capture.

◆ GetLogName()

virtual std::string respond::Model::GetLogName ( ) const
pure virtual
Returns
The name of the associated logger.

◆ GetModelName()

virtual std::string respond::Model::GetModelName ( ) const
pure virtual
Returns
The model's name as a string.

◆ GetState()

virtual Eigen::VectorXd respond::Model::GetState ( ) const
pure virtual
Returns
A copy of the current state vector (limited to observation).

◆ GetTransitionNames()

virtual std::vector< std::string > respond::Model::GetTransitionNames ( ) const
pure virtual
Returns
Vector of transition names in the order they were added.

◆ SetFinalTimestep()

virtual void respond::Model::SetFinalTimestep ( int  final_timestep)
pure virtual
Parameters
final_timestepThe final simulation timestep.

◆ SetHistories()

virtual void respond::Model::SetHistories ( const std::map< std::string, History > &  h)
pure virtual
Parameters
hA map of history names to History objects.

◆ SetHistoryCaptureInterval()

virtual void respond::Model::SetHistoryCaptureInterval ( int  interval)
pure virtual
Parameters
intervalRecord every interval timesteps. Values less than 1 default to full capture.

◆ SetState()

virtual void respond::Model::SetState ( const Eigen::VectorXd &  state)
pure virtual
Parameters
stateThe state vector to set. A copy is made internally.

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