RESPOND 2.5.1
Researching Effective Strategies to Prevent Opioid Death
Loading...
Searching...
No Matches
transition.hpp
1
2// File: transition.hpp //
3// Project: respond //
4// Created Date: 2026-02-02 //
5// Author: Matthew Carroll //
6// ----- //
7// Last Modified: 2026-09-24 //
8// Modified By: Matthew Carroll //
9// ----- //
10// Copyright (c) 2026 Syndemics Lab at Boston Medical Center //
12
13#ifndef RESPOND_TRANSITION_HPP_
14#define RESPOND_TRANSITION_HPP_
15
16#include <map>
17#include <memory>
18#include <string>
19#include <vector>
20
21#include <Eigen/Dense>
22
23#include <respond/constants.hpp>
24#include <respond/history.hpp>
25#include <respond/logging_config.hpp>
26
27namespace respond {
28
34public:
36 virtual ~Transition() = default;
37
45 virtual Eigen::VectorXd
46 Execute(const Eigen::Ref<const Eigen::VectorXd> &s,
47 std::map<std::string, History> &h) const = 0;
48
52 virtual void AddMatrix(Eigen::Ref<const Eigen::MatrixXd> m) = 0;
53
56 virtual std::vector<Eigen::MatrixXd> GetMatrices() const = 0;
57
60 virtual std::string GetName() const = 0;
61
63 virtual void ClearMatrices() = 0;
64
67 Transition(const Transition &) = delete;
70 Transition &operator=(const Transition &) = delete;
71
74 virtual std::unique_ptr<Transition> clone() const = 0;
75
88 [[deprecated("Use Transition::Create(type, name, LoggingConfig) instead")]]
89 static std::unique_ptr<Transition>
90 Create(const std::string &type,
91 const std::string &name = RESPOND_DEFAULT_TRANSITION_NAME,
92 const std::string &log_name = RESPOND_DEFAULT_LOG,
93 const std::string &log_file = RESPOND_DEFAULT_LOG_FILE);
94
95 static std::unique_ptr<Transition>
96 Create(const std::string &type, const std::string &name,
97 const LoggingConfig &logging_config);
98
110 virtual void Serialize(std::ostream &os) const = 0;
111
112protected:
115 Transition() = default;
116};
117
122inline std::ostream &operator<<(std::ostream &os,
123 const Transition &transition) {
124 transition.Serialize(os);
125 return os;
126}
127
128} // namespace respond
129
130#endif
Abstract base class representing a state transition operation. Transitions apply transformation matri...
Definition: transition.hpp:33
virtual std::vector< Eigen::MatrixXd > GetMatrices() const =0
Retrieves the stored transition matrices for this transition.
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 rec...
virtual void Serialize(std::ostream &os) const =0
Helper function to overload to the stream insertion operator for Transition serialization.
virtual ~Transition()=default
Virtual destructor for proper polymorphic cleanup.
virtual std::string GetName() const =0
Retrieves the name/type of this transition.
Transition()=default
Protected default constructor for subclass initialization. Not intended for direct public use.
Transition(const Transition &)=delete
Deleted copy constructor (transitions are non-copyable by public API).
virtual void ClearMatrices()=0
Clears all stored transition matrices.
virtual std::unique_ptr< Transition > clone() const =0
Creates a deep copy of this transition.
Transition & operator=(const Transition &)=delete
Deleted copy assignment operator (transitions are non-copyable by public API).
static std::unique_ptr< 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)
Creates a transition of the specified type.
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.
Describes the logging destination used by a library object.
Definition: logging_config.hpp:21