location.h Source File

CPP API: location.h Source File
location.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Daniel Abele, Elisabeth Kluth, Khoa Nguyen, David Kerkmann
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 MIO_ABM_LOCATION_H
21 #define MIO_ABM_LOCATION_H
22 
23 #include "abm/location_id.h"
24 #include "abm/mask_type.h"
25 #include "abm/parameters.h"
26 #include "abm/location_type.h"
27 
30 #include "boost/atomic/atomic.hpp"
31 
32 namespace mio
33 {
34 namespace abm
35 {
36 
37 struct CellIndex : public mio::Index<CellIndex> {
38  CellIndex(size_t i)
39  : mio::Index<CellIndex>(i)
40  {
41  }
42 };
43 
46 
52 struct CellCapacity {
54  : volume(0)
55  , persons(std::numeric_limits<int>::max())
56  {
57  }
58  uint32_t volume;
59  uint32_t persons;
60 
63  {
64  return Members("CellCapacity").add("volume", volume).add("persons", persons);
65  }
66 };
67 
72 struct Cell {
74 
80 
83  {
84  return Members("Cell").add("capacity", m_capacity);
85  }
86 }; // namespace mio
87 
91 class Location
92 {
93 public:
102  explicit Location(LocationType loc_type, LocationId loc_id, size_t num_agegroups = 1, int model_id = 0,
103  uint32_t num_cells = 1);
104 
110  explicit Location(const Location& other, LocationId id, int model_id = 0)
111  : Location(other)
112  {
113  m_id = id;
114  m_model_id = model_id;
115  }
116 
120  bool operator==(const Location& other) const
121  {
122  return (m_id == other.m_id);
123  }
124 
125  bool operator!=(const Location& other) const
126  {
127  return !(*this == other);
128  }
129 
135  {
136  return m_type;
137  }
138 
144  {
145  return m_id;
146  }
147 
154  {
155  return m_parameters;
156  }
157 
159  {
160  return m_parameters;
161  }
168  const std::vector<Cell>& get_cells() const
169  {
170  return m_cells;
171  }
172 
178  {
179  return m_required_mask;
180  }
181 
187  {
188  m_required_mask = type;
189  }
190 
197  void set_capacity(uint32_t persons, uint32_t volume, uint32_t cell_idx = 0)
198  {
199  assert(cell_idx < m_cells.size() && "Given cell index is too large.");
200  m_cells[cell_idx].m_capacity.persons = persons;
201  m_cells[cell_idx].m_capacity.volume = volume;
202  }
203 
209  CellCapacity get_capacity(uint32_t cell_idx = 0) const
210  {
211  assert(cell_idx < m_cells.size() && "Given cell index is too large.");
212  return m_cells[cell_idx].m_capacity;
213  }
214 
219  bool is_mask_required() const
220  {
222  }
223 
229  {
231  }
232 
238  {
239  m_geographical_location = location;
240  }
241 
244  {
245  return Members("Location")
246  .add("type", m_type)
247  .add("id", m_id)
248  .add("parameters", m_parameters)
249  .add("cells", m_cells)
250  .add("required_mask", m_required_mask)
251  .add("geographical_location", m_geographical_location);
252  }
253 
258  int get_model_id() const
259  {
260  return m_model_id;
261  }
262 
263 private:
265  Location() = default;
266 
270  std::vector<Cell> m_cells{};
275 };
276 
277 } // namespace abm
278 } // namespace mio
279 
280 #endif
A class template for an array with custom indices.
Definition: custom_index_array.h:136
An Index with more than one template parameter combines several Index objects.
Definition: index.h:181
All Locations in the simulated Model where Persons gather.
Definition: location.h:92
LocationId m_id
Unique identifier for the Location in the Model owning it.
Definition: location.h:268
const std::vector< Cell > & get_cells() const
Get the Cells of this Location.
Definition: location.h:168
void set_required_mask(MaskType type)
Set the required type of mask for entering this Location.
Definition: location.h:186
LocationType m_type
Type of the Location.
Definition: location.h:267
mio::geo::GeographicalLocation get_geographical_location() const
Get the geographical location of the Location.
Definition: location.h:228
MaskType m_required_mask
Least secure type of Mask that is needed to enter the Location.
Definition: location.h:271
void set_capacity(uint32_t persons, uint32_t volume, uint32_t cell_idx=0)
Set the CellCapacity of a Cell in the Location in persons and volume.
Definition: location.h:197
mio::geo::GeographicalLocation m_geographical_location
Geographical location (longitude and latitude) of the Location.
Definition: location.h:273
LocationId get_id() const
Get the location's identifier in a Model.
Definition: location.h:143
std::vector< Cell > m_cells
A vector of all Cells that the Location is divided in.
Definition: location.h:270
bool is_mask_required() const
Get the information whether masks are required to enter this Location.
Definition: location.h:219
CellCapacity get_capacity(uint32_t cell_idx=0) const
Get the capacity of a specific Cell in persons and volume.
Definition: location.h:209
int get_model_id() const
Get the model id the location is in.
Definition: location.h:258
LocationType get_type() const
Get the type of this Location.
Definition: location.h:134
MaskType get_required_mask() const
Get the type of Mask that is demanded when entering this Location.
Definition: location.h:177
int m_model_id
Model id the location is in. Only used for ABM graph model or hybrid graph model.
Definition: location.h:274
bool operator!=(const Location &other) const
Definition: location.h:125
auto default_serialize()
This method is used by the default serialization feature.
Definition: location.h:243
bool operator==(const Location &other) const
Compare two Locations.
Definition: location.h:120
void set_geographical_location(mio::geo::GeographicalLocation location)
Set the geographical location of the Location.
Definition: location.h:237
LocalInfectionParameters & get_infection_parameters()
Get the Location specific Infection parameters.
Definition: location.h:153
LocalInfectionParameters m_parameters
Infection parameters for the Location.
Definition: location.h:269
const LocalInfectionParameters & get_infection_parameters() const
Get the Location specific Infection parameters.
Definition: location.h:158
Location(const Location &other, LocationId id, int model_id=0)
Construct a copy of a Location with a new ID.
Definition: location.h:110
Class representing a geographical location on the Earth's surface.
Definition: geolocation.h:42
double ScalarType
Configuration of memilio library.
Definition: memilio/config.h:30
LocationType
Type of a Location.
Definition: location_type.h:34
VirusVariant
Virus variants in ABM.
Definition: virus_variant.h:38
MaskType
Type of a Mask.
Definition: mask_type.h:35
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
auto i
Definition: io.h:809
auto max(const Eigen::MatrixBase< A > &a, B &&b)
coefficient wise maximum of two matrices.
Definition: eigen_util.h:171
Definition: io.h:94
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32
Creates an instance of T for later initialization.
Definition: default_serialize.h:173
List of a class's members.
Definition: default_serialize.h:113
Members< ValueTypes..., T > add(const char *member_name, T &member)
Add a class member.
Definition: default_serialize.h:139
CellCapacity describes the size of a Cell.
Definition: location.h:52
auto default_serialize()
This method is used by the default serialization feature.
Definition: location.h:62
CellCapacity()
Definition: location.h:53
uint32_t volume
Volume of the Cell.
Definition: location.h:58
uint32_t persons
Maximal number of Persons at the Cell.
Definition: location.h:59
Definition: location.h:37
CellIndex(size_t i)
Definition: location.h:38
The Location can be split up into several Cells.
Definition: location.h:72
ScalarType compute_space_per_person_relative() const
Computes a relative cell size for the Cell.
Definition: location.cpp:45
CellCapacity m_capacity
Definition: location.h:73
auto default_serialize()
This method is used by the default serialization feature.
Definition: location.h:82
Unique identifier for a Location within a Model.
Definition: location_id.h:34