simulation.h Source File

CPP API: simulation.h Source File
models/ide_secir/simulation.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Martin J Kuehn, Anna Wendler, Lena Ploetzke
5 *
6 * Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 #ifndef IDE_SECIR_SIMULATION_H
21 #define IDE_SECIR_SIMULATION_H
22 
23 #include "ide_secir/model.h"
24 #include "memilio/config.h"
26 #include <memory>
27 #include <cstdio>
28 
29 namespace mio
30 {
31 namespace isecir
32 {
33 
38 {
39 
40 public:
46  Simulation(Model const& model, ScalarType dt = 0.1)
47  : m_model(std::make_unique<Model>(model))
48  , m_dt(dt)
49  {
50  assert(m_dt > 0);
51  m_model->set_transitiondistributions_support_max(m_dt);
52  m_model->set_transitiondistributions_derivative(m_dt);
53  m_model->set_transitiondistributions_in_forceofinfection(m_dt);
54  }
55 
60  void advance(ScalarType tmax);
61 
68  {
69  return m_model->populations;
70  }
71 
78  {
79  return m_model->populations;
80  }
81 
88  {
89  return m_model->transitions;
90  }
91 
95  const Model& get_model() const
96  {
97  return *m_model;
98  }
99 
104  {
105  return *m_model;
106  }
107 
113  {
114  return m_dt;
115  }
116 
117 private:
118  std::unique_ptr<Model> m_model;
120 };
121 
131 
132 } // namespace isecir
133 } // namespace mio
134 
135 #endif //IDE_SECIR_SIMULATION_H
Definition: ide_secir/model.h:46
run the simulation in discrete steps and report results.
Definition: models/ide_secir/simulation.h:38
TimeSeries< ScalarType > const & get_transitions()
Get the transitions between the different InfectionStates.
Definition: models/ide_secir/simulation.h:87
TimeSeries< ScalarType > get_result()
Get the result of the simulation.
Definition: models/ide_secir/simulation.h:67
const Model & get_model() const
returns the simulation model used in simulation.
Definition: models/ide_secir/simulation.h:95
Simulation(Model const &model, ScalarType dt=0.1)
setup the Simulation for an IDE model.
Definition: models/ide_secir/simulation.h:46
ScalarType m_dt
Time step used for numerical computations in simulation.
Definition: models/ide_secir/simulation.h:119
ScalarType get_dt()
get the time step of the simulation.
Definition: models/ide_secir/simulation.h:112
std::unique_ptr< Model > m_model
Unique pointer to the Model simulated.
Definition: models/ide_secir/simulation.h:118
Model & get_model()
returns the simulation model used in simulation.
Definition: models/ide_secir/simulation.h:103
void advance(ScalarType tmax)
Run the simulation from the current time to tmax.
Definition: ide_secir/simulation.cpp:31
const TimeSeries< ScalarType > & get_result() const
Get the result of the simulation.
Definition: models/ide_secir/simulation.h:77
double ScalarType
Configuration of memilio library.
Definition: memilio/config.h:30
TimeSeries< ScalarType > simulate(ScalarType tmax, ScalarType dt, Model const &m_model)
Run a Simulation of an IDE-SECIR model.
Definition: ide_secir/simulation.cpp:58
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
Definition: io.h:94