Virtual Belgium  2.0
A micro-simulation platform for the Belgian population
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Household.hpp
Go to the documentation of this file.
1 /****************************************************************
2  * HOUSEHOLD.HPP
3  *
4  * This file contains all the households related class and methods.
5  * The households are as agents containing individual agents and
6  * localised in a municipality.
7  *
8  * Authors: J. Barthelemy and L. Hollaert
9  * Date : 17 july 2012
10  ****************************************************************/
11 
16 #ifndef HOUSEHOLD_HPP_
17 #define HOUSEHOLD_HPP_
18 
19 
20 #include "repast_hpc/SVDataSet.h"
21 #include "repast_hpc/SharedContext.h"
22 #include "repast_hpc/Random.h"
23 #include "repast_hpc/io.h"
24 #include "repast_hpc/logger.h"
25 #include "repast_hpc/initialize_random.h"
26 #include "repast_hpc/Utilities.h"
27 
28 #include <sstream>
29 #include <cstdlib>
30 #include <algorithm>
31 #include <stdexcept>
32 #include <math.h>
33 #include <vector>
34 #include <boost/serialization/access.hpp>
35 
36 #include <boost/lexical_cast.hpp>
37 #include <boost/mpi.hpp>
38 #include <boost/mpi/collectives.hpp>
39 
40 #include "Individual.hpp"
41 #include "Data.hpp"
42 
43 class Individual;
44 
45 
47 
51 
53 
55 
59  template <class Archive>
60  void serialize ( Archive & ar , const unsigned int version ) {
61  ar & id;
62  ar & init_proc;
63  ar & agent_type;
64  ar & cur_proc;
65  ar & ins;
66  ar & list_ind;
67  ar & type;
68  ar & n_children;
69  ar & n_adults;
70  ar & house;
71  }
72 
74  HouseholdPackage(int aId, int aInitProc, int aAgentType, int aCurProc, int aIns, std::vector<repast::AgentId> aListInd,
75  std::string aType, int aNChildren, int aNAdults, long aHouse);
76 
77  int id;
78  int init_proc;
79  int agent_type;
80  int cur_proc;
81  int ins;
82  std::vector<repast::AgentId> list_ind;
83  std::string type;
84  int n_children;
85  int n_adults;
86  long house;
87 
89 
92  repast::AgentId getId() const {
93  return repast::AgentId( id , init_proc, agent_type, cur_proc );
94  }
95 
96 };
97 
99 
110 class Household : public repast::Agent {
111 
113 
114 private :
115 
116  repast::AgentId _id;
117  int _ins;
118  std::vector<repast::AgentId> _list_ind;
119  std::string _type;
121  int _n_adults;
122  long _house;
123 
124 public :
125 
127 
135  Household( repast::AgentId id, int ins, std::vector<repast::AgentId> list_ind,
136  std::string type, int n_children, int n_adults );
137 
139 
148  Household( repast::AgentId id, int ins, std::vector<repast::AgentId> list_ind,
149  std::string type, int n_children, int n_adults, long house );
150 
152  virtual ~Household () ;
153 
155 
158  std::string getType () const {
159  return _type;
160  }
161 
163 
166  void setType ( std::string val ) {
167  _type = val ;
168  }
169 
171 
174  int getNChildren () const {
175  return _n_children;
176  }
177 
179 
182  void setNChildren ( int val ) {
183  _n_children = val ;
184  }
185 
187 
190  int getNAdults () const {
191  return _n_adults;
192  }
193 
195 
198  void setNAdults ( int val ) {
199  _n_adults = val ;
200  }
201 
203 
206  std::vector<repast::AgentId> & getListInd () {
207  return _list_ind ;
208  }
209 
211 
214  void setListInd ( std::vector<repast::AgentId> val ) {
215  _list_ind = val;
216  }
217 
219 
222  long getHouse() const {
223  return _house;
224  }
225 
227 
230  void setHouse(long val) {
231  _house = val;
232  }
233 
235 
238  int getIns() const {
239  return _ins;
240  }
241 
243 
246  void setIns( int val ) {
247  _ins = val;
248  }
249 
251 
254  repast::AgentId & getId () {
255  return _id ;
256  }
257 
259 
262  const repast::AgentId & getId () const {
263  return _id ;
264  }
265 
267 
270  std::vector<Individual * > getIndividuals( repast::SharedContext<Individual> & agentsInd );
271 
273 
276  void computeHhType( repast::SharedContext<Individual> & agentsInd );
277 
279 
282  void removeIndFromList( repast::AgentId aId );
283 
285 
288  void localizeHouse( Data dataset );
289 
291 
294  void addBaby( repast::AgentId aBabyId );
295 
296 };
297 
298 #endif /* HOUSEHOLD_HPP_ */
void setNChildren(int val)
Set the number of children.
Definition: Household.hpp:182
Individual agents related classes and methods declarations.
long house
household's housing unit node id
Definition: Household.hpp:86
const repast::AgentId & getId() const
Return the household repast agent id (required by Repast).
Definition: Household.hpp:262
repast::AgentId getId() const
Return household's agent id.
Definition: Household.hpp:92
int agent_type
household agent type
Definition: Household.hpp:79
long _house
id of the network's node where the household is living
Definition: Household.hpp:122
int cur_proc
current household process
Definition: Household.hpp:80
std::string getType() const
Return the current household type.
Definition: Household.hpp:158
Household(repast::AgentId id, int ins, std::vector< repast::AgentId > list_ind, std::string type, int n_children, int n_adults)
Constructor.
Definition: Household.cpp:46
int n_children
number of children
Definition: Household.hpp:84
int _n_adults
household's number of additional adults
Definition: Household.hpp:121
friend class boost::serialization::access
Definition: Household.hpp:112
std::string type
household type
Definition: Household.hpp:83
int id
id of the household
Definition: Household.hpp:77
void removeIndFromList(repast::AgentId aId)
Removes an individual from the household.
Definition: Household.cpp:136
void addBaby(repast::AgentId aBabyId)
Adding a baby to the household.
Definition: Household.cpp:150
Data related class and methods.
The package structure for Household agents.
Definition: Household.hpp:50
friend class boost::serialization::access
Definition: Household.hpp:52
int getIns() const
Return the ins code of the household's municipality.
Definition: Household.hpp:238
int n_adults
number of additional adults
Definition: Household.hpp:85
void setNAdults(int val)
Set the number of additional adults.
Definition: Household.hpp:198
std::string _type
household's type
Definition: Household.hpp:119
std::vector< repast::AgentId > & getListInd()
Return a list of the household's member.
Definition: Household.hpp:206
void setType(std::string val)
Set household's type.
Definition: Household.hpp:166
void setListInd(std::vector< repast::AgentId > val)
Set the list of household members.
Definition: Household.hpp:214
void serialize(Archive &ar, const unsigned int version)
Serializing procedure of the package.
Definition: Household.hpp:60
std::vector< Individual * > getIndividuals(repast::SharedContext< Individual > &agentsInd)
Return a vector of pointers to the individual agents belonging to the household.
Definition: Household.cpp:65
void setIns(int val)
Set the household ins code.
Definition: Household.hpp:246
int _ins
household's municipality ins code
Definition: Household.hpp:117
repast::AgentId _id
household's unique id
Definition: Household.hpp:116
void localizeHouse(Data dataset)
Choose randomly a node of the network inside of the household's municipality as the household's house...
Definition: Household.cpp:143
HouseholdPackage()
Definition: Household.cpp:16
int ins
ins code of the household's municipality
Definition: Household.hpp:81
void setHouse(long val)
Set the node id of the household's home.
Definition: Household.hpp:230
std::vector< repast::AgentId > _list_ind
household's members id
Definition: Household.hpp:118
A data class.
Definition: Data.hpp:100
int _n_children
household's number of children (< 18 years old)
Definition: Household.hpp:120
int init_proc
initial household process
Definition: Household.hpp:78
int getNChildren() const
Get the number of children.
Definition: Household.hpp:174
long getHouse() const
Return the node id of the household's home.
Definition: Household.hpp:222
The individual agent class.
Definition: Individual.hpp:122
int getNAdults() const
Return the number of additional adults.
Definition: Household.hpp:190
std::vector< repast::AgentId > list_ind
ids of households' members
Definition: Household.hpp:82
The household agent class.
Definition: Household.hpp:110
void computeHhType(repast::SharedContext< Individual > &agentsInd)
Determines the household type.
Definition: Household.cpp:78
virtual ~Household()
Destructor.
Definition: Household.cpp:60
repast::AgentId & getId()
Return the household repast agent id (required by Repast).
Definition: Household.hpp:254