Data Model for ActivitySim Inputs
Instructions: customize these example values for your own ActivitySim implementation
Bases: BaseModel
Household data from PopulationSim and input to ActivitySim.
Customize as needed for your application.
Source code in input.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 | class Household(BaseModel):
"""
Household data from PopulationSim and input to ActivitySim.
Customize as needed for your application.
"""
id: int
persons: List[Person]
income_in_usd2011: float
home_location: int
@property
def income_quartile(self) -> int:
"""
Create income quartiles from the income using the
`income_quartile_breakpoints_in_aud2019` Parameter
"""
quartile = 1
for break_point in p.income_quartile_breakpoints_in_usd2011:
if self.income_in_usd2011 < break_point:
return quartile
@property
def household_size(self) -> int:
"""
Number of persons in the household from the persons array length
"""
return len(self.persons)
|
Number of persons in the household from the persons array length
Create income quartiles from the income using the
income_quartile_breakpoints_in_aud2019
Parameter
Bases: BaseModel
Helper class to validate a list of households.
See the example notebooks for details on how this works.
Source code in input.py
153
154
155
156
157
158
159 | class HouseholdValidator(BaseModel):
"""
Helper class to validate a list of households.
See the example notebooks for details on how this works.
"""
list_of_households: List[Household]
|
Bases: BaseModel
Person data from PopulationSim and input to ActivitySim.
Customize as needed for your application.
Source code in input.py
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 | class Person(BaseModel):
"""
Person data from PopulationSim and input to ActivitySim.
Customize as needed for your application.
"""
id: int
age: int
sex: e.Gender
person_type: e.PersonType
occupation: e.Occupation
@property
def gender(self) -> e.Gender:
"""
Sex is used as a proxy for gender in the travel model
"""
return self.sex
|
Sex is used as a proxy for gender in the travel model
Bases: BaseModel
Helper class to validate a list of persons.
See the example notebooks for details on how this works.
Source code in input.py
144
145
146
147
148
149
150 | class PersonValidator(BaseModel):
"""
Helper class to validate a list of persons.
See the example notebooks for details on how this works.
"""
list_of_persons: List[Person]
|
Bases: BaseModel
Helper class to validate a list of zonal data.
See the example notebooks for details on how this works.
Source code in input.py
162
163
164
165
166
167
168 | class TazValidator(BaseModel):
"""
Helper class to validate a list of zonal data.
See the example notebooks for details on how this works.
"""
list_of_zones: List[TravelAnalysisZoneData]
|
Bases: BaseModel
TAZ or socio-economic data. Customize as needed for your application.
Source code in input.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 | class TravelAnalysisZoneData(BaseModel):
"""
TAZ or socio-economic data. Customize as needed for your application.
"""
id: int
centroid_latitude: Optional[float]
centroid_longitude: Optional[float]
households: float
household_population: float
employment_agriculture: float
employment_mining: float
employment_utilities: float
employment_construction: float
employment_manufacturing: float
employment_wholesale: float
employment_retail: float
employment_transport: float
employment_communication: float
employment_finance: float
employment_rental: float
employment_professional: float
employment_administrative: float
employment_education: float
employment_health: float
employment_social: float
employment_accommodation: float
employment_public_administration: float
employment_other: float
enrollment_secondary: float
enrollment_primary: float
enrollment_tertiary: float
parking_cost_per_hour_usd2019: float
area_type: e.AreaType
valid_values_for_internal_travel: Optional[List[int]] = range(
1, p.maximum_internal_zone_number
)
@property
def employment_total(self) -> float:
"""
This is an example of how to compute a new variable from the variables defined above.
In this case `employment_total` is the sum across employment categories.
Modify as needed and add other variables as desired.
"""
return (
self.employment_agriculture
+ self.employment_mining
+ self.employment_construction
+ self.employment_manufacturing
+ self.employment_wholesale
+ self.employment_retail
+ self.employment_transport
+ self.employment_communication
+ self.employment_finance
+ self.employment_rental
+ self.employment_professional
+ self.employment_administrative
+ self.employment_education
+ self.employment_health
+ self.employment_social
+ self.employment_accommodation
+ self.employment_public_administration
+ self.employment_other
)
@validator("parking_cost_per_hour_usd2019")
def parking_cost_is_too_high(cls, value):
"""
This is an example of of a custom validation method. In this case,
the method returns an error if `parking_cost_per_hour_usd2019` is higher than
the value set in the `parameters` file.
"""
if value > p.maximum_parking_cost_per_hour:
raise ValueError("Parking cost too high")
return value
|
This is an example of how to compute a new variable from the variables defined above.
In this case employment_total
is the sum across employment categories.
Modify as needed and add other variables as desired.
This is an example of of a custom validation method. In this case,
the method returns an error if parking_cost_per_hour_usd2019
is higher than
the value set in the parameters
file.
Source code in input.py
82
83
84
85
86
87
88
89
90
91 | @validator("parking_cost_per_hour_usd2019")
def parking_cost_is_too_high(cls, value):
"""
This is an example of of a custom validation method. In this case,
the method returns an error if `parking_cost_per_hour_usd2019` is higher than
the value set in the `parameters` file.
"""
if value > p.maximum_parking_cost_per_hour:
raise ValueError("Parking cost too high")
return value
|