From 25229bb3b21230d7e9af66486fc74302f6c3c07c Mon Sep 17 00:00:00 2001
From: Matthew Carroll <28577806+MJC598@users.noreply.github.com>
Date: Tue, 22 Sep 2026 10:01:46 -0400
Subject: [PATCH 01/11] adding mermaid docs for dependency inversion and ioc
---
docs/src/dependency_inversion.mmd | 44 +++++++++++++++++++++++++++++++
docs/src/ioc.mmd | 39 +++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 docs/src/dependency_inversion.mmd
create mode 100644 docs/src/ioc.mmd
diff --git a/docs/src/dependency_inversion.mmd b/docs/src/dependency_inversion.mmd
new file mode 100644
index 00000000..0431e933
--- /dev/null
+++ b/docs/src/dependency_inversion.mmd
@@ -0,0 +1,44 @@
+---
+config:
+ theme: 'base'
+ themeVariables:
+ primaryColor: '#3d9be9'
+ secondaryColor: '#003771'
+ tertiaryColor: '#ffffff'
+ lineColor: '#f0325f'
+ primaryTextColor: '#ffffff'
+ primaryBorderColor: '#f0325f'
+ titleColor: '#003771'
+ fontFamily: 'Helvetica Bold, Helvetica'
+ fontSize: '22px'
+---
+
+flowchart TB
+ subgraph Layered["Layered architecture / dependency inversion"]
+ direction TB
+ subgraph Application["Application layer"]
+ direction LR
+ S[Simulation]
+ AM[Model]
+ end
+
+ subgraph Abstraction["Abstraction layer"]
+ direction LR
+ T["Transition interface"]
+ TS[Timestep]
+ end
+
+ subgraph Implementation["Implementation layer"]
+ direction TB
+ MIG[Migration]
+ BEH[Behavior]
+ INT[Intervention]
+ ODO[Overdose]
+ BGD[Background Mortality]
+ end
+
+ S --> AM
+ AM --> TS
+ TS -->|depends on| T
+ T <-.-|implements| Implementation
+ end
diff --git a/docs/src/ioc.mmd b/docs/src/ioc.mmd
new file mode 100644
index 00000000..40b471b6
--- /dev/null
+++ b/docs/src/ioc.mmd
@@ -0,0 +1,39 @@
+---
+config:
+ theme: 'base'
+ themeVariables:
+ primaryColor: '#3d9be9'
+ secondaryColor: '#003771'
+ tertiaryColor: '#ffffff'
+ lineColor: '#f0325f'
+ primaryTextColor: '#ffffff'
+ primaryBorderColor: '#f0325f'
+ titleColor: '#003771'
+ fontFamily: 'Helvetica Bold, Helvetica'
+ fontSize: '22px'
+---
+
+flowchart LR
+ subgraph Traditional["RESPONDv1 control flow"]
+ direction LR
+ R1[RESPOND]
+ R1 <-->|gets| D1[Data]
+ R1 <-->|runs| C1[Migration]
+ R1 <-->|runs| C2[Behaviors]
+ R1 <-->|runs| C3[Intervention]
+ R1 <-->|runs| C4[Overdoses]
+ R1 <-->|runs| C5[Fatal Overdoses]
+ R1 <-->|runs| C6[Background Mortality]
+ end
+
+ subgraph Inverted["RESPONDv2 control flow"]
+ direction TB
+ D[Data]
+ D -->|injected into| M[Model]
+ I["«interface»
Transition::Execute()"]
+ M -->|calls| I
+ I -.->|chosen at runtime| T1[Migration
Behaviors
Intervention
Overdoses
Fatal Overdoses
Background Mortality]
+ end
+
+ Traditional --- Inverted
+
From 3cfcddabc50d9cc560f08798f2a79d7c94a04c5b Mon Sep 17 00:00:00 2001
From: Matthew Carroll <28577806+MJC598@users.noreply.github.com>
Date: Tue, 22 Sep 2026 12:04:26 -0400
Subject: [PATCH 02/11] Adding updates for execution config and logging config
to improve constructor overloading
---
include/respond/execution_config.hpp | 28 ++++++++
include/respond/logging.hpp | 7 ++
include/respond/logging_config.hpp | 28 ++++++++
include/respond/model.hpp | 19 ++++++
include/respond/respond.hpp | 3 +
include/respond/runtime_config.hpp | 23 +++++++
include/respond/simulation.hpp | 96 +++++++++++++++++++++-------
src/internals/logging_internals.hpp | 10 +--
src/internals/markov.hpp | 45 ++++++++++---
src/logging.cpp | 31 ++++++---
src/model_factory.cpp | 12 ++++
tests/unit/logging_test.cpp | 14 ++++
tests/unit/markov_test.cpp | 8 +++
tests/unit/simulation_test.cpp | 49 ++++++++++++++
14 files changed, 326 insertions(+), 47 deletions(-)
create mode 100644 include/respond/execution_config.hpp
create mode 100644 include/respond/logging_config.hpp
create mode 100644 include/respond/runtime_config.hpp
diff --git a/include/respond/execution_config.hpp b/include/respond/execution_config.hpp
new file mode 100644
index 00000000..53ff8d70
--- /dev/null
+++ b/include/respond/execution_config.hpp
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+// File: execution_config.hpp //
+// Project: respond //
+// Created Date: 2026-09-22 //
+// Author: Matthew Carroll //
+// ----- //
+// Copyright (c) 2026 Syndemics Lab at Boston Medical Center //
+////////////////////////////////////////////////////////////////////////////////
+#ifndef RESPOND_EXECUTION_CONFIG_HPP_
+#define RESPOND_EXECUTION_CONFIG_HPP_
+
+namespace respond {
+/// @brief Controls how a Simulation distributes execution resources.
+struct ExecutionConfig {
+ /// @brief Total worker threads available for concurrent model execution.
+ /// A value of 0 selects the implementation's automatic default.
+ unsigned int total_threads = 0;
+
+ /// @brief Eigen worker threads used within a model.
+ /// Use 1 when models are executed concurrently to avoid oversubscription.
+ unsigned int eigen_threads = 1;
+
+ /// @brief Whether models may be executed concurrently by the simulation.
+ bool run_models_concurrently = false;
+};
+} // namespace respond
+
+#endif // RESPOND_EXECUTION_CONFIG_HPP_
diff --git a/include/respond/logging.hpp b/include/respond/logging.hpp
index 58878527..67ae6990 100644
--- a/include/respond/logging.hpp
+++ b/include/respond/logging.hpp
@@ -14,6 +14,8 @@
#include
+#include
+
namespace respond {
/// @brief Logging levels for the logger.
@@ -56,6 +58,11 @@ enum class LogPattern : int {
CreationStatus CreateFileLogger(const std::string &logger_name,
const std::string &filepath);
+/// @brief Initializes a logger from a logging configuration.
+/// @param config Logging name, destination, and shared-sink policy.
+/// @return CreationStatus indicating the result of logger creation.
+CreationStatus ConfigureLogger(const LoggingConfig &config);
+
// ============================================================================
// Parallel Execution Support: Shared File Sink
// ============================================================================
diff --git a/include/respond/logging_config.hpp b/include/respond/logging_config.hpp
new file mode 100644
index 00000000..c14ff7c9
--- /dev/null
+++ b/include/respond/logging_config.hpp
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+// File: logging_config.hpp //
+// Project: respond //
+// Created Date: 2026-09-22 //
+// Author: Matthew Carroll //
+// ----- //
+// Last Modified: 2026-09-22 //
+// Modified By: Matthew Carroll //
+// ----- //
+// Copyright (c) 2026 Syndemics Lab at Boston Medical Center //
+////////////////////////////////////////////////////////////////////////////////
+#ifndef RESPOND_LOGGING_CONFIG_HPP_
+#define RESPOND_LOGGING_CONFIG_HPP_
+
+#include
+
+#include
+
+namespace respond {
+/// @brief Describes the logging destination used by a library object.
+struct LoggingConfig {
+ std::string logger_name = RESPOND_DEFAULT_LOG;
+ std::string file_path = RESPOND_DEFAULT_LOG_FILE;
+ bool use_shared_sink = false;
+};
+} // namespace respond
+
+#endif // RESPOND_LOGGING_CONFIG_HPP_
diff --git a/include/respond/model.hpp b/include/respond/model.hpp
index 1376a154..b44fb473 100644
--- a/include/respond/model.hpp
+++ b/include/respond/model.hpp
@@ -20,6 +20,7 @@
#include
#include
+#include
#include
namespace respond {
@@ -44,6 +45,7 @@ class Model {
/// @param log_name Name of the logger for this model (default: "console").
/// @param log_filepath File path for the log file (default: "respond.log").
/// @return A unique_ptr to the newly created Model instance.
+ [[deprecated("Use Model::Create(name, RuntimeConfig) instead")]]
static std::unique_ptr
Create(const std::string &name,
const std::string &log_name = RESPOND_DEFAULT_LOG,
@@ -60,11 +62,28 @@ class Model {
/// @param log_name Name of the logger for this model (default: "console").
/// @param log_filepath File path for the log file (default: "respond.log").
/// @return A unique_ptr to the newly created Model instance.
+ [[deprecated("Use Model::Create(name, RuntimeConfig) instead")]]
static std::unique_ptr
Create(const std::string &name, const unsigned int processor_count,
const std::string &log_name = RESPOND_DEFAULT_LOG,
const std::string &log_filepath = RESPOND_DEFAULT_LOG_FILE);
+ /// @brief Creates a Model with explicit execution settings.
+ /// @param name The name identifier for the model to create.
+ /// @param execution_config Resource settings for model execution.
+ /// @param log_name Name of the logger for this model (default: "console").
+ /// @param log_filepath File path for the log file (default: "respond.log").
+ /// @return A unique_ptr to the newly created Model instance.
+ [[deprecated("Use Model::Create(name, RuntimeConfig) instead")]]
+ static std::unique_ptr
+ Create(const std::string &name, const ExecutionConfig &execution_config,
+ const std::string &log_name = RESPOND_DEFAULT_LOG,
+ const std::string &log_filepath = RESPOND_DEFAULT_LOG_FILE);
+
+ /// @brief Creates a Model with shared runtime settings.
+ static std::unique_ptr
+ Create(const std::string &name, const RuntimeConfig &runtime_config);
+
/// @brief Virtual destructor for proper polymorphic cleanup.
virtual ~Model() = default;
diff --git a/include/respond/respond.hpp b/include/respond/respond.hpp
index e0b20aad..98fb9487 100644
--- a/include/respond/respond.hpp
+++ b/include/respond/respond.hpp
@@ -13,9 +13,12 @@
#define RESPOND_RESPOND_HPP_
#include
+#include
#include
#include
+#include
#include
+#include
#include
#include
#include
diff --git a/include/respond/runtime_config.hpp b/include/respond/runtime_config.hpp
new file mode 100644
index 00000000..26bafc4f
--- /dev/null
+++ b/include/respond/runtime_config.hpp
@@ -0,0 +1,23 @@
+////////////////////////////////////////////////////////////////////////////////
+// File: runtime_config.hpp //
+// Project: respond //
+// Created Date: 2026-09-22 //
+// Author: Matthew Carroll //
+// ----- //
+// Copyright (c) 2026 Syndemics Lab at Boston Medical Center //
+////////////////////////////////////////////////////////////////////////////////
+#ifndef RESPOND_RUNTIME_CONFIG_HPP_
+#define RESPOND_RUNTIME_CONFIG_HPP_
+
+#include
+#include
+
+namespace respond {
+/// @brief Groups execution and logging settings shared by runtime objects.
+struct RuntimeConfig {
+ ExecutionConfig execution;
+ LoggingConfig logging;
+};
+} // namespace respond
+
+#endif // RESPOND_RUNTIME_CONFIG_HPP_
diff --git a/include/respond/simulation.hpp b/include/respond/simulation.hpp
index bd0d0eaf..8eb22415 100644
--- a/include/respond/simulation.hpp
+++ b/include/respond/simulation.hpp
@@ -4,7 +4,7 @@
// Created Date: 2026-02-05 //
// Author: Matthew Carroll //
// ----- //
-// Last Modified: 2026-07-22 //
+// Last Modified: 2026-09-22 //
// Modified By: Matthew Carroll //
// ----- //
// Copyright (c) 2026 Syndemics Lab at Boston Medical Center //
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include