RESPOND 2.4.0
Researching Effective Strategies to Prevent Opioid Death
Loading...
Searching...
No Matches
model.hpp
1
2// File: model.hpp //
3// Project: respond //
4// Created Date: 2026-02-05 //
5// Author: Matthew Carroll //
6// ----- //
7// Last Modified: 2026-02-12 //
8// Modified By: Matthew Carroll //
9// ----- //
10// Copyright (c) 2026 Syndemics Lab at Boston Medical Center //
12#ifndef RESPOND_MODEL_HPP_
13#define RESPOND_MODEL_HPP_
14
15#include <memory>
16#include <string>
17#include <vector>
18
19#include <Eigen/Dense>
20
21#include <respond/history.hpp>
22#include <respond/transition.hpp>
23
24namespace respond {
29class Model {
30public:
32 virtual ~Model() = default;
33
36 virtual void SetState(const Eigen::VectorXd &state) = 0;
37
40 virtual Eigen::VectorXd GetState() const = 0;
41
45 virtual void RunTransitions() = 0;
46
50 virtual void AddTransition(const std::unique_ptr<Transition> &t) = 0;
51
54 virtual std::vector<std::string> GetTransitionNames() const = 0;
55
58 virtual void ClearTransitions() = 0;
59
63 virtual std::map<std::string, History> GetHistories() const = 0;
64
68 virtual void CreateDefaultHistories() = 0;
69
72 virtual void SetHistories(const std::map<std::string, History> &h) = 0;
73
75 virtual void ClearHistories() = 0;
76
80 virtual void SetHistoryCaptureInterval(int interval) = 0;
81
84 virtual int GetHistoryCaptureInterval() const = 0;
85
88 virtual void SetFinalTimestep(int final_timestep) = 0;
89
92 virtual int GetFinalTimestep() const = 0;
93
96 virtual std::string GetModelName() const = 0;
97
100 virtual std::string GetLogName() const = 0;
101
106 static std::unique_ptr<Model>
107 Create(const std::string &name, const std::string &log_name = "console");
108
110 Model(const Model &) = delete;
113 Model &operator=(const Model &) = delete;
114
117 virtual std::unique_ptr<Model> clone() const = 0;
118
119protected:
122 Model() = default;
123};
124} // namespace respond
125
126#endif // RESPOND_MODEL_HPP_
Abstract base class representing a state transition model. Models manage a state vector,...
Definition: model.hpp:29
virtual Eigen::VectorXd GetState() const =0
Retrieves the current state of the model.
Model & operator=(const Model &)=delete
Deleted copy assignment operator (models are non-copyable by public API).
virtual std::unique_ptr< Model > clone() const =0
Creates a deep copy of this model.
virtual void SetState(const Eigen::VectorXd &state)=0
Sets 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 w...
virtual void ClearTransitions()=0
Clears all registered transitions. Deletes all stored Transition unique_ptrs.
virtual std::vector< std::string > GetTransitionNames() const =0
Retrieves the names of all registered transitions.
virtual std::map< std::string, History > GetHistories() const =0
Retrieves the history records for all state variables.
virtual std::string GetLogName() const =0
Retrieves the logger name used by 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 void AddTransition(const std::unique_ptr< Transition > &t)=0
Adds a transition to the model.
virtual std::string GetModelName() const =0
Retrieves the name identifier for this model.
virtual void SetHistories(const std::map< std::string, History > &h)=0
Sets the history records for the model.
Model(const Model &)=delete
Deleted copy constructor (models are non-copyable by public API).
virtual int GetFinalTimestep() const =0
Retrieves the final timestep forced into history output.
virtual ~Model()=default
Virtual destructor for proper polymorphic cleanup.
static std::unique_ptr< Model > Create(const std::string &name, const std::string &log_name="console")
Factory method to create a Model instance.
Model()=default
Protected default constructor for subclass initialization. Not intended for direct public use.
virtual void ClearHistories()=0
Clears all history records and resets history tracking state.
virtual void CreateDefaultHistories()=0
Creates default history tracking for the model. This method initializes standard history records base...
virtual void SetHistoryCaptureInterval(int interval)=0
Sets the global history capture interval for this model.