Virtual Belgium  2.0
A micro-simulation platform for the Belgian population
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Individual.hpp
Go to the documentation of this file.
1 /****************************************************************
2  * INDIVIDUAL.HPP
3  *
4  * This file contains all the Individuals related classes and
5  * functions.
6  *
7  * Authors: J. Barthelemy and L. Hollaert
8  * Date : 17 july 2012
9  ****************************************************************/
10 
16 #ifndef INDIVIDUAL_HPP_
17 #define INDIVIDUAL_HPP_
18 
19 #include "repast_hpc/TDataSource.h"
20 #include "repast_hpc/SharedContext.h"
21 #include "repast_hpc/Schedule.h"
22 #include "repast_hpc/Random.h"
23 #include "repast_hpc/Properties.h"
24 #include "repast_hpc/Utilities.h"
25 #include "repast_hpc/io.h"
26 #include "repast_hpc/logger.h"
27 #include "repast_hpc/initialize_random.h"
28 
29 #include <sstream>
30 #include <cstdlib>
31 #include <algorithm>
32 #include <stdexcept>
33 #include <math.h>
34 #include <vector>
35 #include <boost/serialization/access.hpp>
36 #include <boost/lexical_cast.hpp>
37 #include <boost/mpi.hpp>
38 #include <boost/mpi/collectives.hpp>
39 
40 #include "Data.hpp"
41 #include "Random.hpp"
42 #include "Activity.hpp"
43 
45 
49 
51 
53 
57  template <class Archive>
58  void serialize ( Archive & ar , const unsigned int version ) {
59  ar & id;
60  ar & init_proc;
61  ar & agent_type;
62  ar & cur_proc;
63  ar & hh_id;
64  ar & municipality;
65  ar & gender;
66  ar & age_class;
67  ar & age;
68  ar & education;
69  ar & hh_relationship;
70  ar & sps_status;
71  ar & driving_license;
72  ar & act_chain;
73  ar & house;
74  }
75 
78  IndividualPackage(int aId, int aInitProc, int aAgentType, int aCurProc, repast::AgentId aHhId, int aMunId,
79  char aGender, int aAgeClass, int aAge, char aEducation, char aHhRelationship, char aSPStatus,
80  char aDrivingLicence, std::vector<Activity> aActChain, long aHouse);
81 
82  int id;
83  int init_proc;
84  int agent_type;
85  int cur_proc;
86  repast::AgentId hh_id;
88  char gender;
89  int age_class;
90  int age;
91  char education;
93  char sps_status;
95  std::vector<Activity> act_chain;
96  long house;
97 
99 
102  repast::AgentId getId () const {
103  return repast::AgentId( id, init_proc, agent_type, cur_proc );
104  }
105 
106 };
107 
109 
122 class Individual : public repast::Agent {
123 
124  // Repast need this line
126 
127 private :
128 
129  repast::AgentId _id;
130  repast::AgentId _hh_id;
132  char _gender;
134  int _age;
135  char _education;
136  char _sps_status;
139  long _house;
140  std::vector<Activity> _act_chain;
141 
142 public :
143 
145 
154  Individual( repast::AgentId id , repast :: AgentId hh_id, int municipality,
155  char gender, int age_class, char education, char hh_relationship );
156 
158 
167  Individual( repast::AgentId id , repast :: AgentId hh_id, int municipality,
168  char gender, int age_class, int age, char education );
169 
171 
181  Individual( repast::AgentId id, repast::AgentId hh_id, int municipality,
182  char gender, int age_class, char education, char hh_relationship,
183  long house );
184 
186 
197  Individual( repast::AgentId id, repast::AgentId hh_id, int municipality,
198  char gender, int age_class, int age, char education, char hh_relationship,
199  long house );
200 
202 
215  Individual( repast::AgentId id, repast::AgentId hh_id, int municipality,
216  char gender, int age_class, char education, char sps_status,
217  char driving_license, char hh_relationship, long house,
218  std::vector<Activity> act_chain );
219 
221 
235  Individual( repast::AgentId id, repast::AgentId hh_id, int municipality,
236  char gender, int age_class, int age, char education, char sps_status,
237  char driving_license, char hh_relationship, long house, std::vector<Activity> act_chain );
238 
240  virtual ~Individual() ;
241 
243 
246  char getGender() const {
247  return _gender;
248  }
249 
251 
254  void setGender( char val ) {
255  _gender = val ;
256  }
257 
259 
262  int getAgeClass() const {
263  return _age_class;
264  }
265 
267 
270  void setAgeClass( int val ) {
271  _age_class = val ;
272  }
273 
275 
278  int getAge() const {
279  return _age;
280  }
281 
283 
286  void setAge( int val ) {
287  _age = val ;
288  }
289 
291 
294  int getMunicipality() const {
295  return _municipality;
296  }
297 
299 
302  void setMunicipality( int val ) {
303  _municipality = val ;
304  }
305 
307 
310  char getEducation() const {
311  return _education;
312  }
313 
315 
318  void setEducation( char val ) {
319  _education = val ;
320  }
321 
323 
326  char getSpsStatus() const {
327  return _sps_status;
328  }
329 
331 
334  void setSpsStatus( char val ) {
335  _sps_status = val;
336  }
337 
339 
342  char getDrivingLicense() const {
343  return _driving_license;
344  }
345 
347 
350  void setDrivingLicense( char val ) {
351  _driving_license = val ;
352  }
353 
355 
358  char getHhRelationship() const {
359  return _hh_relationship;
360  }
361 
363 
366  void setHhRelationship( char val ) {
367  _hh_relationship = val ;
368  }
369 
371 
374  std::vector<Activity> getActChain() const {
375  return _act_chain;
376  }
377 
379 
382  void setActChain( std::vector<Activity> val ) {
383  _act_chain = val;
384  }
385 
387 
390  void addActChain( Activity val ) {
391  _act_chain.push_back(val);
392  }
393 
395  repast::AgentId & getHhId() {
396  return _hh_id ;
397  }
398 
400  const repast::AgentId & getHhId() const {
401  return _hh_id ;
402  }
403 
405 
408  void setHhId( repast::AgentId val ) {
409  _hh_id = val;
410  }
411 
413 
416  long getHouse() const {
417  return _house;
418  }
419 
421 
424  void setHouse(long val) {
425  _house = val;
426  }
427 
429 
432  repast::AgentId & getId() {
433  return _id ;
434  }
435 
437 
440  const repast::AgentId & getId() const {
441  return _id ;
442  }
443 
445  void aging();
446 
448  void initAge();
449 
451  bool isDying();
452 
454  bool givingbirth();
455 
457  Individual birthInd(long babyId);
458 
459 };
460 
461 #endif /* INDIVIDUAL_HPP_ */
char _sps_status
Socio-professional status.
Definition: Individual.hpp:136
char driving_license
driving license ownership of the individual
Definition: Individual.hpp:94
int cur_proc
individual curent process
Definition: Individual.hpp:85
char education
education level of the individual
Definition: Individual.hpp:91
int _municipality
Municipality of the individual.
Definition: Individual.hpp:131
A class representing activities.
Definition: Activity.hpp:27
The package structure for Individual agents.
Definition: Individual.hpp:48
VirtualBelgium's activity-based model related classes and methods.
void setMunicipality(int val)
Set individual's muncipality.
Definition: Individual.hpp:302
IndividualPackage()
Constructor.
Definition: Individual.cpp:16
char _hh_relationship
Household status relationship.
Definition: Individual.hpp:138
int init_proc
initial individual process
Definition: Individual.hpp:83
repast::AgentId & getHhId()
Return Repast AgentId of the individual's household.
Definition: Individual.hpp:395
long house
house of the individual, i.e. a node id
Definition: Individual.hpp:96
void initAge()
Initialize the age of an Individual.
Definition: Individual.cpp:153
Individual birthInd(long babyId)
Generate a baby by the individual.
Definition: Individual.cpp:224
int age
age of the individual
Definition: Individual.hpp:90
Random number generators and related tools.
char hh_relationship
household relationship status of the individual
Definition: Individual.hpp:92
const repast::AgentId & getId() const
Return the individual Repast agent id (required by Repast).
Definition: Individual.hpp:440
std::vector< Activity > act_chain
activity chain of the individual
Definition: Individual.hpp:95
char _driving_license
Driving license ownership.
Definition: Individual.hpp:137
bool isDying()
Death process.
Definition: Individual.cpp:193
repast::AgentId _id
Individual's Repast::AgentId.
Definition: Individual.hpp:129
repast::AgentId _hh_id
Household's Repast::AgentId.
Definition: Individual.hpp:130
char getEducation() const
Return individual's education level.
Definition: Individual.hpp:310
repast::AgentId getId() const
Return individual's agent id.
Definition: Individual.hpp:102
const repast::AgentId & getHhId() const
Return Repast AgentId of the individual's household.
Definition: Individual.hpp:400
int getAge() const
Return individual's age.
Definition: Individual.hpp:278
char getSpsStatus() const
Return individual's socio-professional status.
Definition: Individual.hpp:326
int age_class
age class of the individual
Definition: Individual.hpp:89
void serialize(Archive &ar, const unsigned int version)
Serializing procedure of the package.
Definition: Individual.hpp:58
char getGender() const
Return individual's gender.
Definition: Individual.hpp:246
Data related class and methods.
char getHhRelationship() const
Return individual's household relationship status (head, mate, child, adult).
Definition: Individual.hpp:358
char gender
gender of the individual
Definition: Individual.hpp:88
void setEducation(char val)
Set individual's education level.
Definition: Individual.hpp:318
void setHouse(long val)
Set individual's house localization (i.e. a node id, see Network class).
Definition: Individual.hpp:424
void setSpsStatus(char val)
Set individual's socio-professional status.
Definition: Individual.hpp:334
char _education
Education level (No diploma, Primary school, High School, Master degree).
Definition: Individual.hpp:135
int _age_class
Age class of the individual.
Definition: Individual.hpp:133
long getHouse() const
Return the house localization (i.e. a node id, see Network class).
Definition: Individual.hpp:416
friend class boost::serialization::access
Definition: Individual.hpp:125
int getMunicipality() const
Return the ins code of individual's municipality.
Definition: Individual.hpp:294
void setHhId(repast::AgentId val)
Set the Repast AgentId of the individual's household.
Definition: Individual.hpp:408
Individual(repast::AgentId id, repast::AgentId hh_id, int municipality, char gender, int age_class, char education, char hh_relationship)
Constructor (initialize every attributes but house, sps status, age and activity chain).
Definition: Individual.cpp:54
std::vector< Activity > _act_chain
Activity chain of the individual.
Definition: Individual.hpp:140
void setHhRelationship(char val)
Set individual's household relationship status (head, mate, child, adult).
Definition: Individual.hpp:366
int id
id of the individual
Definition: Individual.hpp:82
char sps_status
socio-professional status of the individual
Definition: Individual.hpp:93
bool givingbirth()
Determine whether the individual is giving birth to a baby.
Definition: Individual.cpp:209
void setActChain(std::vector< Activity > val)
Set individual's activity chain.
Definition: Individual.hpp:382
int agent_type
individual agent_type
Definition: Individual.hpp:84
friend class boost::serialization::access
Definition: Individual.hpp:50
char getDrivingLicense() const
Return individual's driving license ownership.
Definition: Individual.hpp:342
repast::AgentId hh_id
Repast agent id of the individual.
Definition: Individual.hpp:86
void aging()
Incrementing the age of an Individual.
Definition: Individual.cpp:133
int _age
Actual age of the individual.
Definition: Individual.hpp:134
void setDrivingLicense(char val)
Set individual's driving license ownership.
Definition: Individual.hpp:350
void setAgeClass(int val)
Set individual's age class.
Definition: Individual.hpp:270
std::vector< Activity > getActChain() const
Return individual's activity chain.
Definition: Individual.hpp:374
void addActChain(Activity val)
Add an activity to individual's activity chain.
Definition: Individual.hpp:390
int getAgeClass() const
Return individual's age class.
Definition: Individual.hpp:262
void setAge(int val)
Set individual's age.
Definition: Individual.hpp:286
int municipality
ins code of the individual's municipality
Definition: Individual.hpp:87
void setGender(char val)
Set individual's gender.
Definition: Individual.hpp:254
long _house
Network's node's id of the individual's house.
Definition: Individual.hpp:139
The individual agent class.
Definition: Individual.hpp:122
virtual ~Individual()
Destructor.
Definition: Individual.cpp:130
repast::AgentId & getId()
Return the individual Repast agent id (required by Repast).
Definition: Individual.hpp:432
char _gender
Gender of the individual (Male, Female).
Definition: Individual.hpp:132