personal_rng.h Source File

CPP API: personal_rng.h Source File
personal_rng.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Daniel Abele, Elisabeth Kluth, David Kerkmann, Khoa Nguyen, Rene Schmieding
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 
21 #ifndef MIO_ABM_PERSONAL_RNG_H
22 #define MIO_ABM_PERSONAL_RNG_H
23 
25 #include <cstdint>
26 
27 namespace mio
28 {
29 namespace abm
30 {
31 
32 class Person;
33 
48 class PersonalRandomNumberGenerator : public mio::RandomNumberGeneratorBase<PersonalRandomNumberGenerator>
49 {
50 public:
57  PersonalRandomNumberGenerator(mio::Key<uint64_t> key, uint32_t index, mio::Counter<uint32_t>& counter);
58 
63  PersonalRandomNumberGenerator(const RandomNumberGenerator& model_rng, Person& person);
64 
68  mio::Key<uint64_t> get_key() const
69  {
70  return m_key;
71  }
72 
76  mio::Counter<uint64_t> get_counter() const
77  {
78  return mio::rng_totalsequence_counter<uint64_t>(m_person_index, m_counter);
79  }
80 
85  {
86  ++m_counter;
87  }
88 
89 private:
90  mio::Key<uint64_t> m_key;
91  uint32_t m_person_index;
92  mio::Counter<uint32_t>& m_counter;
93 };
94 
95 } // namespace abm
96 } // namespace mio
97 
98 #endif // MIO_ABM_PERSONAL_RNG_H
Agents in the simulated Model that can carry and spread the Infection.
Definition: person.h:50
Random number generator of individual persons.
Definition: personal_rng.h:49
mio::Key< uint64_t > m_key
Global RNG Key.
Definition: personal_rng.h:90
uint32_t m_person_index
Index of the Person.
Definition: personal_rng.h:91
mio::Counter< uint32_t > & m_counter
Reference to the Person's rng counter.
Definition: personal_rng.h:92
mio::Key< uint64_t > get_key() const
Definition: personal_rng.h:68
mio::Counter< uint64_t > get_counter() const
Definition: personal_rng.h:76
void increment_counter()
Increment the counter.
Definition: personal_rng.h:84
PersonalRandomNumberGenerator(mio::Key< uint64_t > key, uint32_t index, mio::Counter< uint32_t > &counter)
Creates a RandomNumberGenerator for a person.
Definition: personal_rng.cpp:30
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30