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 "models/abm/person_id.h"
26 #include <cstdint>
27 
28 namespace mio
29 {
30 namespace abm
31 {
32 
33 class Person;
34 
49 class PersonalRandomNumberGenerator : public mio::RandomNumberGeneratorBase<PersonalRandomNumberGenerator>
50 {
51 public:
58  PersonalRandomNumberGenerator(mio::Key<uint64_t> key, uint32_t index, mio::Counter<uint32_t>& counter);
59 
65 
69  mio::Key<uint64_t> get_key() const
70  {
71  return m_key;
72  }
73 
77  mio::Counter<uint64_t> get_counter() const
78  {
79  return mio::rng_totalsequence_counter<uint64_t>(m_person_index, m_counter);
80  }
81 
86  {
87  ++m_counter;
88  }
89 
90 private:
91  mio::Key<uint64_t> m_key;
92  uint32_t m_person_index;
93  mio::Counter<uint32_t>& m_counter;
94 };
95 
96 } // namespace abm
97 } // namespace mio
98 
99 #endif // MIO_ABM_PERSONAL_RNG_H
Agents in the simulated Model that can carry and spread the Infection.
Definition: person.h:51
Random number generator of individual persons.
Definition: personal_rng.h:50
mio::Key< uint64_t > m_key
Global RNG Key.
Definition: personal_rng.h:91
uint32_t m_person_index
Index of the Person.
Definition: personal_rng.h:92
mio::Counter< uint32_t > & m_counter
Reference to the Person's rng counter.
Definition: personal_rng.h:93
mio::Key< uint64_t > get_key() const
Definition: personal_rng.h:69
mio::Counter< uint64_t > get_counter() const
Definition: personal_rng.h:77
void increment_counter()
Increment the counter.
Definition: personal_rng.h:85
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