household.h Source File

CPP API: household.h Source File
household.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Daniel Abele, Sascha Korf, Khoa Nguyen
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_HOUSEHOLD_H
22 #define MIO_ABM_HOUSEHOLD_H
23 
24 #include "abm/model.h"
27 #include <numeric>
28 #include <vector>
29 
30 namespace mio
31 {
32 namespace abm
33 {
34 
52 {
53 public:
58  HouseholdMember(size_t num_agegroups)
59  : m_age_weights({AgeGroup(num_agegroups)}, 0)
60  {
61  }
62 
69  void set_age_weight(mio::AgeGroup age_group, int weight)
70  {
71  assert(age_group < m_age_weights.size<mio::AgeGroup>());
72  m_age_weights[age_group] = weight;
73  }
74 
79  {
80  return m_age_weights;
81  }
82 
83 private:
85 };
86 
91 class Household
92 {
93 public:
99  {
101  m_space_per_member = 0;
102  }
103 
108  {
109  return m_number_of_members;
110  }
111 
116  void set_space_per_member(int space_per_member)
117  {
118  m_space_per_member = space_per_member;
119  }
120 
125  {
126  return m_space_per_member;
127  }
128 
132  const std::vector<std::tuple<HouseholdMember, int>>& get_members() const
133  {
135  }
136 
142  void add_members(HouseholdMember household_member, int number_of_members);
143 
144 private:
147  std::vector<std::tuple<HouseholdMember, int>> m_household_member_list;
149 };
150 
156 {
157 public:
162  : m_household_list()
163  {
165  }
166 
171  {
172  return m_number_of_households;
173  }
174 
179  const std::vector<std::tuple<Household, int>>& get_households() const
180  {
181  return m_household_list;
182  }
183 
189  void add_households(Household household, int number_of_households);
190 
191 private:
193  std::vector<std::tuple<Household, int>> m_household_list;
195 };
196 
203 void add_household_to_model(Model& model, const Household& household);
204 
210 void add_household_group_to_model(Model& model, const HouseholdGroup& household_group);
211 
212 } // namespace abm
213 } // namespace mio
214 
215 #endif //MIO_ABM_HOUSEHOLD_H
mio::Index< Tag > size() const
returns the size along the dimension provided as template parameter
Definition: custom_index_array.h:204
A HouseholdGroup represented by different Households.
Definition: household.h:156
int m_number_of_households
Number of Households in this group.
Definition: household.h:192
int get_total_number_of_households() const
Returns the number of Households in the HouseholdGroup.
Definition: household.h:170
HouseholdGroup()
Constructs a new HouseholdGroup.
Definition: household.h:161
std::vector< std::tuple< Household, int > > m_household_list
A list of types of Households and the amount of times it is in the group.
Definition: household.h:193
const std::vector< std::tuple< Household, int > > & get_households() const
Returns the Households of the HouseholdGroup.
Definition: household.h:179
void add_households(Household household, int number_of_households)
Adds a number of Households of the same kind, e.g. same members, to a HouseholdGroup.
Definition: household.cpp:53
A HouseholdMember represented by a weighted age distribution.
Definition: household.h:52
const CustomIndexArray< int, mio::AgeGroup > & get_age_weights() const
Returns the CustomIndexArray with the weights of each AgeGroup.
Definition: household.h:78
CustomIndexArray< int, mio::AgeGroup > m_age_weights
Weights of every AgeGroup.
Definition: household.h:84
void set_age_weight(mio::AgeGroup age_group, int weight)
Sets the weight of an AgeGroup.
Definition: household.h:69
HouseholdMember(size_t num_agegroups)
Constructs a new HouseholdMember.
Definition: household.h:58
A Household represented by a vector with HouseholdMembers.
Definition: household.h:92
int get_space_per_member() const
Get the space per member of the Household, measured in cubic meters.
Definition: household.h:124
void add_members(HouseholdMember household_member, int number_of_members)
Adds a number of the same HouseholdMembers to a Household.
Definition: household.cpp:47
const std::vector< std::tuple< HouseholdMember, int > > & get_members() const
Get the HouseholdMembers of the Household.
Definition: household.h:132
int m_number_of_members
Total number of Persons in the Household.
Definition: household.h:145
void set_space_per_member(int space_per_member)
Set the space per member for the computation of the LocationCapacity of the Household.
Definition: household.h:116
int get_total_number_of_members() const
Returns the number of members, i.e. Persons in the Household.
Definition: household.h:107
std::vector< std::tuple< HouseholdMember, int > > m_household_member_list
HouseholdMembers of the Household and the respective number of Persons.
Definition: household.h:147
Household()
Constructs a new Household.
Definition: household.h:97
int m_space_per_member
Space per Person in cubic meters (constant maximal capacity over time).
Definition: household.h:146
The Model of the Simulation.
Definition: abm/model.h:54
void add_household_to_model(Model &model, const Household &household)
Adds a specific Household to the Model.
Definition: household.cpp:59
void add_household_group_to_model(Model &model, const HouseholdGroup &household_group)
Adds Households from a HouseholdGroup to the Model.
Definition: household.cpp:78
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32