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

Abstract base class representing a state transition operation. Transitions apply transformation matrices to state vectors and update history records. Subclasses define specific types of transitions (e.g., Markov, background death, behavior).

#include <transition.hpp>

Public Member Functions

virtual ~Transition ()=default
 Virtual destructor for proper polymorphic cleanup.
 
virtual Eigen::VectorXd Execute (const Eigen::Ref< const Eigen::VectorXd > &s, std::map< std::string, History > &h) const =0
 Executes this transition, applying it to a state vector. The input state is not modified; history records are updated with the transition effects.
 
virtual void AddMatrix (Eigen::Ref< const Eigen::MatrixXd > m)=0
 Adds a transformation matrix to this transition. The matrix is stored for use during Execute() calls.
 
virtual std::vector< Eigen::MatrixXd > GetMatrices () const =0
 Retrieves the stored transition matrices for this transition.
 
virtual std::string GetName () const =0
 Retrieves the name/type of this transition.
 
virtual void ClearMatrices ()=0
 Clears all stored transition matrices.
 
 Transition (const Transition &)=delete
 Deleted copy constructor (transitions are non-copyable by public API).
 
Transitionoperator= (const Transition &)=delete
 Deleted copy assignment operator (transitions are non-copyable by public API).
 
virtual std::unique_ptr< Transitionclone () const =0
 Creates a deep copy of this transition.
 
virtual void Serialize (std::ostream &os) const =0
 Helper function to overload to the stream insertion operator for Transition serialization.
 

Static Public Member Functions

static std::unique_ptr< TransitionCreate (const std::string &type, const std::string &name=RESPOND_DEFAULT_TRANSITION_NAME, const std::string &log_name=RESPOND_DEFAULT_LOG, const std::string &log_file=RESPOND_DEFAULT_LOG_FILE)
 Creates a transition of the specified type.
 

Protected Member Functions

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

Member Function Documentation

◆ AddMatrix()

virtual void respond::Transition::AddMatrix ( Eigen::Ref< const Eigen::MatrixXd >  m)
pure virtual
Parameters
mThe transition matrix to add (not modified by this transition).

◆ clone()

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

◆ Create()

static std::unique_ptr< Transition > respond::Transition::Create ( const std::string &  type,
const std::string &  name = RESPOND_DEFAULT_TRANSITION_NAME,
const std::string &  log_name = RESPOND_DEFAULT_LOG,
const std::string &  log_file = RESPOND_DEFAULT_LOG_FILE 
)
static
Parameters
typeThe type of transition to create. Supported types (case-insensitive):
  • "migration": Population migration transitions
  • "behavior": Behavioral state transitions
  • "intervention": Intervention-driven transitions
  • "overdose": Overdose-related transitions
  • "background_death": Background mortality transitions
log_nameThe logger name for error reporting (e.g., "console").
Returns
A unique_ptr to the created Transition, or nullptr if type is unsupported.

◆ Execute()

virtual Eigen::VectorXd respond::Transition::Execute ( const Eigen::Ref< const Eigen::VectorXd > &  s,
std::map< std::string, History > &  h 
) const
pure virtual
Parameters
sThe current state vector (not modified).
hThe history records to update (may be modified by this transition).
Returns
The resulting state vector after applying this transition.

◆ GetMatrices()

virtual std::vector< Eigen::MatrixXd > respond::Transition::GetMatrices ( ) const
pure virtual
Returns
A vector of references to the stored transition matrices.

◆ GetName()

virtual std::string respond::Transition::GetName ( ) const
pure virtual
Returns
The transition's identifier as a string.

◆ Serialize()

virtual void respond::Transition::Serialize ( std::ostream &  os) const
pure virtual

This function is intended to be overridden by subclasses to provide custom serialization logic. It should write the transition's state, metadata, and any relevant information to the provided output stream.

Note
The output format is implementation-defined and may vary between subclasses. Users should refer to the specific subclass documentation for details on the serialization format.
Parameters
osThe output stream to which the transition's serialized data will be written.

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