Skip to content

Commit

Permalink
Merge 8b4f081 into f189143
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewTheTM committed Aug 22, 2022
2 parents f189143 + 8b4f081 commit 462c01c
Show file tree
Hide file tree
Showing 206 changed files with 87,810 additions and 18 deletions.
39 changes: 21 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,27 @@ jobs:
- env: TEST_SUITE=activitysim/core

- stage: Examples
name: "Prototype MTC"
env: TEST_SUITE=activitysim/examples/prototype_mtc/test
- name: "Prototype MTC (Extended)"
env: TEST_SUITE=activitysim/examples/prototype_mtc_extended/test
- name: "Multizone Example"
env: TEST_SUITE=activitysim/examples/placeholder_multiple_zone/test
- name: "Marin Example"
env: TEST_SUITE=activitysim/examples/prototype_marin/test
- name: "ARC Example"
env: TEST_SUITE=activitysim/examples/prototype_arc/test
- name: "SEMCOG Example"
env: TEST_SUITE=activitysim/examples/prototype_semcog/test
- name: "PSRC Example"
env: TEST_SUITE=activitysim/examples/placeholder_psrc/test
- name: "SANDAG Example"
env: TEST_SUITE=activitysim/examples/placeholder_sandag/test
- name: "SANDAG Cross-Border Example"
env: TEST_SUITE=activitysim/examples/prototype_sandag_xborder/test
name: "MWCOG Example"
env: TEST_SUITE=activitysim/examples/prototype_mwcog/test
#- name: "Prototype MTC"
# env: TEST_SUITE=activitysim/examples/prototype_mtc/test
#- name: "Prototype MTC (Extended)"
# env: TEST_SUITE=activitysim/examples/prototype_mtc_extended/test
#- name: "Multizone Example"
# env: TEST_SUITE=activitysim/examples/placeholder_multiple_zone/test
#- name: "Marin Example"
# env: TEST_SUITE=activitysim/examples/prototype_marin/test
#- name: "ARC Example"
# env: TEST_SUITE=activitysim/examples/prototype_arc/test
#- name: "SEMCOG Example"
# env: TEST_SUITE=activitysim/examples/prototype_semcog/test
#- name: "PSRC Example"
# env: TEST_SUITE=activitysim/examples/placeholder_psrc/test
#- name: "SANDAG Example"
# env: TEST_SUITE=activitysim/examples/placeholder_sandag/test
#- name: "SANDAG Cross-Border Example"
# env: TEST_SUITE=activitysim/examples/prototype_sandag_xborder/test


- stage: Estimation Mode
name: "Larch Test"
Expand Down
16 changes: 16 additions & 0 deletions activitysim/examples/example_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -894,3 +894,19 @@
- https://media.githubusercontent.com/media/activitysim/activitysim_resources/master/sandag_xborder/traffic_skims_xborder_PM.omx
data/traffic_skims_xborder_PM.omx
87544b59488c4ca654ae8d9756dfb3a8226b85faa21e631339d86fae5dc60feb

- name: prototype_mwcog
description: 53 zone test example for the MWCOG region
# activitysim create -e prototype_mwcog -d test_prototype_mwcog
# cd test_prototype_mwcog
# python simulation.py -c configs -o output -d data
# cd ..
include:
- prototype_mwcog/extensions
- prototype_mwcog/data
- prototype_mwcog/configs
- prototype_mwcog/configs_mp
- prototype_mwcog/output
- prototype_mwcog/README.MD
- prototype_mwcog/simulation.py

2 changes: 2 additions & 0 deletions activitysim/examples/prototype_mwcog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data_*/
output_*/
3 changes: 3 additions & 0 deletions activitysim/examples/prototype_mwcog/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### MWCOG Example

This is an example of the Metropolitan Washington Council of Governments ActivitySim model. This is a 53 zone portion of the model, centered on the National Mall.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coefficient_name,value,constrain
coef_one,1,T
59 changes: 59 additions & 0 deletions activitysim/examples/prototype_mwcog/configs/accessibility.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Description,Target,Expression
#,,
#,, auto peak
#,,
#,, assume peak occurs in AM for outbound and PM for inbound
peak round trip time,_auPkTime,"skim_od[('SOV_TIME', 'AM')] + skim_do[('SOV_TIME', 'PM')]"
decay function,_decay, exp(_auPkTime * dispersion_parameter_automobile)
auto peak retail,auPkRetail,df.RETEMP * _decay
auto peak total,auPkTotal,df.TOTEMP * _decay
#,,
#,, auto off-peak
#,,
#,, assume midday occurs entirely in the midday period
off-peak round trip time,_auOpTime,"skim_od[('SOV_TIME', 'MD')] + skim_do[('SOV_TIME', 'MD')]"
decay function,_decay, exp(_auOpTime * dispersion_parameter_automobile)
auto off-peak retail,auOpRetail,df.RETEMP * _decay
auto off-peak total,auOpTotal,df.TOTEMP * _decay
#,,
#,, transit peak
#,,
#,, assume peak outbound transit occurs in AM
o-d peak transit ivt,_inVehicleTime,"skim_od[('WK_TRN_WK_TOTIVT', 'AM')]"
o-d peak transit ovt,_outOfVehicleTime,"skim_od[('WK_TRN_WK_IWAIT', 'AM')] + skim_od[('WK_TRN_WK_XWAIT', 'AM')] + skim_od[('WK_TRN_WK_WACC_EGR', 'AM')] + skim_od[('WK_TRN_WK_WAUX', 'AM')]"
o-d peak transit time,_trPkTime_od,(_inVehicleTime + out_of_vehicle_time_weight * _outOfVehicleTime)
#,, assume peak inbound transit occurs in PM
d-o peak transit ivt,_inVehicleTime,"skim_od[('WK_TRN_WK_TOTIVT', 'PM')]"
d-o peak transit ovt,_outOfVehicleTime,"skim_od[('WK_TRN_WK_IWAIT', 'PM')] + skim_od[('WK_TRN_WK_XWAIT', 'PM')] + skim_od[('WK_TRN_WK_WACC_EGR', 'PM')] + skim_od[('WK_TRN_WK_WAUX', 'PM')]"
d-o peak transit time,_trPkTime_do,(_inVehicleTime + out_of_vehicle_time_weight * _outOfVehicleTime)
peak transit time,_trPkTime,_trPkTime_od + _trPkTime_do
round trip path is available,_rt_available,(_trPkTime_od > 0) & (_trPkTime_do > 0)
decay function,_decay,_rt_available * exp(_trPkTime * dispersion_parameter_transit)
transit peak retail,trPkRetail,df.RETEMP * _decay
transit peak total,trPkTotal,df.TOTEMP * _decay
#,,
#,, transit off-peak
#,,
#,, assume off-peak outbound transit occurs in the MD time period
o-d off-peak transit ivt,_inVehicleTime,"skim_od[('WK_TRN_WK_TOTIVT', 'MD')]"
o-d off-peak transit ovt,_outOfVehicleTime,"skim_od[('WK_TRN_WK_IWAIT', 'MD')] + skim_od[('WK_TRN_WK_XWAIT', 'MD')] + skim_od[('WK_TRN_WK_WACC_EGR', 'MD')] + skim_od[('WK_TRN_WK_WAUX', 'MD')]"
o-d off-peak transit time,_trOpTime_od,(_inVehicleTime + out_of_vehicle_time_weight * _outOfVehicleTime)
#,, assume off-peak inbound transit occurs in the MD time period
d-o off-peak transit ivt,_inVehicleTime,"skim_do[('WK_TRN_WK_TOTIVT', 'MD')]"
d-o off-peak transit ovt,_outOfVehicleTime,"skim_do[('WK_TRN_WK_IWAIT', 'MD')] + skim_do[('WK_TRN_WK_XWAIT', 'MD')] + skim_do[('WK_TRN_WK_WACC_EGR', 'MD')] + skim_do[('WK_TRN_WK_WAUX', 'MD')]"
d-o off-peak transit time,_trOpTime_do,(_inVehicleTime + out_of_vehicle_time_weight * _outOfVehicleTime)
peak transit time,_trOpTime,_trOpTime_od + _trOpTime_do
#,,FIXME - _rt_available calculation appears to be wrong in mtctm1 accessibility.job
#round trip path is available,_rt_available,(_trOpTime > 0)
round trip path is available,_rt_available,(_trOpTime_od > 0) & (_trOpTime_do > 0)
decay function,_decay,_rt_available * exp(_trOpTime * dispersion_parameter_transit)
transit off-peak retail,trOpRetail,df.RETEMP * _decay
transit off-peak total,trOpTotal,df.TOTEMP * _decay
#,,
#,, non motorized
#,,
non-motorized round trip distance,_nmDist,skim_od['DISTWALK'] + skim_do['DISTWALK']
round trip path is available,_rt_available,_nmDist <= maximum_walk_distance
decay function,_decay,_rt_available * exp(_nmDist * dispersion_parameter_walk)
retail accessibility,nmRetail,df.RETEMP * _decay
total accessibility,nmTotal,df.TOTEMP * _decay
13 changes: 13 additions & 0 deletions activitysim/examples/prototype_mwcog/configs/accessibility.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# columns from land_use table to add to df
land_use_columns: ['RETEMP', 'TOTEMP']

CONSTANTS:
# dispersion parameters
dispersion_parameter_automobile: -0.05
dispersion_parameter_transit: -0.05
dispersion_parameter_walk: -1.00
# maximum walk distance in miles
maximum_walk_distance: 3.0
# perceived minute of in-vehicle time for every minute of out-of-vehicle time
out_of_vehicle_time_weight: 2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Description,Target,Expression
#,, annotate households table after import
,_PERSON_COUNT,"lambda query, persons, households: persons.query(query).groupby('household_id').size().reindex(households.index).fillna(0).astype(np.int8)"
#,,FIXME households.income can be negative - so we clip?
income,income,households.hhincadj.fillna(0)
income_in_thousands,income_in_thousands,(income / 1000).clip(lower=0)
income_segment,income_segment,"pd.cut(income_in_thousands, bins=[-np.inf, 50, 100, 150, np.inf], labels=[1, 2, 3, 4]).astype(int)"
#,,
,_MIN_VOT,setting('min_value_of_time')
,_MAX_VOT,setting('max_value_of_time')
,_MU,setting('distributed_vot_mu')
,_SIGMA,setting('distributed_vot_sigma')
median_value_of_time,median_value_of_time,"income_segment.map({k: v for k, v in setting('household_median_value_of_time').items()})"
hh_value_of_time,hh_value_of_time,"rng.lognormal_for_df(df, mu=np.log(median_value_of_time * _MU), sigma=_SIGMA).clip(_MIN_VOT, _MAX_VOT)"
#,,
#num_workers was renamed in import,,
,num_workers,"_PERSON_COUNT('(ESR==1)|(ESR==2)|(ESR==4)|(ESR==5)', persons, households)"
number of non_workers,num_non_workers,households.hhsize - num_workers
#,,
#,,we assume that everyone 16 and older is a potential driver
number of drivers,num_drivers,"_PERSON_COUNT('16 <= age', persons, households)"
num_adults,num_adults,"_PERSON_COUNT('18 <= age', persons, households)"
num_children,num_children,"_PERSON_COUNT('18 > age', persons, households)"
num_young_children,num_young_children,"_PERSON_COUNT('age <= 5', persons, households)"
num_children_5_to_15,num_children_5_to_15,"_PERSON_COUNT('5 <= age <= 15', persons, households)"
num_children_6_to_12,num_children_6_to_12,"_PERSON_COUNT('6 <= age <= 12', persons, households)"
num_children_16_to_17,num_children_16_to_17,"_PERSON_COUNT('16 <= age <= 17', persons, households)"
num_college_age,num_college_age,"_PERSON_COUNT('18 <= age <= 24', persons, households)"
num_young_adults,num_young_adults,"_PERSON_COUNT('25 <= age <= 34', persons, households)"
non_family,non_family,households.HHT.isin(HHT_NONFAMILY)
family,family,households.HHT.isin(HHT_FAMILY)
home_is_urban,home_is_urban,"reindex(land_use.AREATYPE, households.home_zone_id) < setting('urban_threshold')"
home_is_rural,home_is_rural,"reindex(land_use.AREATYPE, households.home_zone_id) > setting('rural_threshold')"
#,, default for work and school location logsums before auto_ownership model is run
,auto_ownership,households.auto_ownership
TAZ column to match settings file,TAZ,households.home_zone_id
number of pre-driving age children in the household,num_predrive_child,"_PERSON_COUNT('ptype == 7', persons, households)"
number of non-working adult in the household,num_nonworker_adults,"_PERSON_COUNT('ptype == 4', persons, households)"
number of full time workers,num_fullTime_workers,"_PERSON_COUNT('is_fulltime_worker', persons, households)"
number of part time workers,num_partTime_workers,"_PERSON_COUNT('is_parttime_worker', persons, households)"
number of retired adults in the household,_num_retired_adults,"_PERSON_COUNT('ptype == 5', persons, households)"
Retired Adults Only Households,retired_adults_only_hh,(households.hhsize > 0) & (households.hhsize == _num_retired_adults)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Description,Target,Expression
#,, annotate households table after cdap model has run
num_under16_not_at_school,num_under16_not_at_school,persons.under16_not_at_school.astype(int).groupby(persons.household_id).sum().reindex(households.index).fillna(0).astype(np.int8)
num_travel_active,num_travel_active,persons.travel_active.astype(int).groupby(persons.household_id).sum().reindex(households.index).fillna(0).astype(np.int8)
num_travel_active_adults,num_travel_active_adults,(persons.adult & persons.travel_active).astype(int).groupby(persons.household_id).sum().reindex(households.index).fillna(0).astype(np.int8)
num_travel_active_preschoolers,num_travel_active_preschoolers,((persons.ptype == PTYPE_PRESCHOOL) & persons.travel_active).astype(int).groupby(persons.household_id).sum().reindex(households.index).fillna(0).astype(np.int8)
num_travel_active_children,num_travel_active_children,num_travel_active - num_travel_active_adults
num_travel_active_non_preschoolers,num_travel_active_non_preschoolers,num_travel_active - num_travel_active_preschoolers
participates_in_jtf_model,participates_in_jtf_model,(num_travel_active > 1) & (num_travel_active_non_preschoolers > 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Description,Target,Expression
#,, annotate households table after workplace_location model has run
#,, hh_work_auto_savings_ratio is sum of persons work_auto_savings_ratio
,hh_work_auto_savings_ratio,persons.work_auto_savings_ratio.groupby(persons.household_id).sum().reindex(households.index).fillna(0.0)
#,,handle persons with no locatcion
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Description,Target,Expression
#,, annotate landuse table after import
household_density,household_density,land_use.HH / (land_use.LANDAREA * 640)
employment_density,employment_density,land_use.TOTEMP / (land_use.LANDAREA * 640)
,employment_density,employment_density.fillna(0)
density_index,density_index,(household_density *employment_density) / (household_density + employment_density).clip(lower=1)
topology (assume flat),TOPOLOGY,1
zero out land use for zero area,Park_Acres,"np.where(land_use.LANDAREA==0,0,land_use.Park_Acres)"
zero out land use for zero area,GC_Acres,"np.where(land_use.LANDAREA==0,0,land_use.GC_Acres)"
68 changes: 68 additions & 0 deletions activitysim/examples/prototype_mwcog/configs/annotate_persons.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Description,Target,Expression
#,, annotate persons table after import
age_0_to_5,age_0_to_5,"persons.age.between(0,5)"
age_6_to_12,age_6_to_12,"persons.age.between(6,12)"
age_16_to_19,age_16_to_19,"persons.age.between(16, 19)"
age_16_p,age_16_p,persons.age >= 16
adult,adult,persons.age >= 18
young,young,persons.age <= 25
old,old,persons.age >= 65
male,male,persons.SEX == 1
female,female,persons.SEX == 2
,esr,persons.ESR.fillna(0)
,wkhp,persons.WKHP.fillna(0)
,wkw,persons.WKW.fillna(0)
,schg,persons.SCHG.fillna(0)
,mil,persons.MIL.fillna(0)
employment status type,pemploy,np.zeros(len(persons))
,pemploy,"np.where(persons.age < 16, PEMPLOY_CHILD, PEMPLOY_PART)"
,pemploy,"np.where((persons['age'] >= 16) & ((esr == 3) | (esr == 6)), PEMPLOY_NOT, pemploy)"
,pemploy,"np.where((persons.age>=16)&((esr != 3)&(esr != 6))&(wkhp >= 35) & (wkw >= 1) & (wkw <= 4), PEMPLOY_FULL, pemploy)"
student category,pstudent,np.zeros(len(persons))
,pstudent,"np.where((pemploy == 1) & (persons.age >= 16), PSTUDENT_NOT, pstudent)"
,pstudent,"np.where((pemploy == 1) & (persons.age < 16), PSTUDENT_GRADE_OR_HIGH, pstudent)"
,pstudent,"np.where((schg < 1) & (persons.age >= 16), PSTUDENT_NOT, pstudent)"
,pstudent,"np.where((schg < 1) & (persons.age < 16), PSTUDENT_GRADE_OR_HIGH, pstudent)"
,pstudent,"np.where((schg >= 15) & (persons.age >= 16) & (pemploy != 1), PSTUDENT_UNIVERSITY, pstudent)"
,pstudent,"np.where((schg >= 15) & (persons.age < 16) & (pemploy != 1), PSTUDENT_GRADE_OR_HIGH, pstudent)"
,pstudent,"np.where((persons.age <= 19) & (pemploy != 1) & (schg >=1) & (schg<=14), PSTUDENT_GRADE_OR_HIGH, pstudent)"
,pstudent,"np.where((persons.age > 19) & (pemploy != 1) & (schg >=1) & (schg<=14), PSTUDENT_UNIVERSITY, pstudent)"
,pstudent,"np.where(pstudent == 0, 3, pstudent)"
person type,ptype,np.zeros(len(persons))
,ptype,"np.where((pemploy == 1), PTYPE_FULL, PTYPE_NONWORK)"
,ptype,"np.where((pstudent == 3) & (pemploy == 2), PTYPE_PART, ptype)"
,ptype,"np.where((pstudent == 3) & (persons['age'] >= 65) & ((pemploy == 3) | (pemploy == 4)), PTYPE_RETIRED, ptype)"
,ptype,"np.where((pstudent == 3) & (persons['age'] < 6) & ((pemploy == 3) | (pemploy == 4)), PTYPE_PRESCHOOL, ptype)"
,ptype,"np.where((pstudent == 3) & (persons['age'] >= 6) & (persons['age'] <= 64) & ((pemploy == 3) | (pemploy == 4)), PTYPE_NONWORK, ptype)"
,ptype,"np.where((pstudent == 2) & ((pemploy == 2) | (pemploy == 3) | (pemploy == 4)), PTYPE_UNIVERSITY, ptype)"
,ptype,"np.where((pstudent == 1) & (persons['age'] < 6) & ((pemploy == 2) | (pemploy == 3) | (pemploy == 4)), PTYPE_PRESCHOOL, ptype)"
,ptype,"np.where((pstudent == 1) & (persons['age'] >= 16) & ((pemploy == 2) | (pemploy == 3) | (pemploy == 4)), PTYPE_DRIVING, ptype)"
,ptype,"np.where((pstudent == 1) & (persons['age'] >= 6) & (persons['age'] < 16) & ((pemploy == 2) | (pemploy == 3) | (pemploy == 4)), PTYPE_SCHOOL, ptype)"
presence of non_worker other than self in household,has_non_worker,"other_than(persons.household_id, ptype == PTYPE_NONWORK)"
presence of retiree other than self in household,has_retiree,"other_than(persons.household_id, ptype == PTYPE_RETIRED)"
presence of preschooler other than self in household,has_preschool_kid,"other_than(persons.household_id, ptype == PTYPE_PRESCHOOL)"
presence of driving_kid other than self in household,has_driving_kid,"other_than(persons.household_id, ptype == PTYPE_DRIVING)"
presence of school_kid other than self in household,has_school_kid,"other_than(persons.household_id, ptype == PTYPE_SCHOOL)"
presence of full_time worker other than self in household (independent of person type),has_full_time,"other_than(persons.household_id, pemploy==PEMPLOY_FULL)"
presence of part_time worker other than self in household (independent of person type),has_part_time,"other_than(persons.household_id, pemploy==PEMPLOY_PART)"
presence of university student other than self in household,has_university,"other_than(persons.household_id, ptype == PTYPE_UNIVERSITY)"
student_is_employed,student_is_employed,"np.where(((ptype == PTYPE_UNIVERSITY) | (ptype == PTYPE_DRIVING)) & ((pemploy == PEMPLOY_FULL) | (pemploy == PEMPLOY_PART)), True, False)"
nonstudent_to_school,nonstudent_to_school,"np.where(((ptype == PTYPE_FULL) | (ptype == PTYPE_PART) | (ptype == PTYPE_NONWORK) | (ptype == PTYPE_RETIRED)) & ((pstudent == PSTUDENT_GRADE_OR_HIGH) | (pstudent == PSTUDENT_UNIVERSITY)), True, False)"
is_student,is_student,"np.where((pstudent == PSTUDENT_GRADE_OR_HIGH) | (pstudent == PSTUDENT_UNIVERSITY), True, False)"
preschool age can go to preschool,is_student,"np.where((pstudent == PSTUDENT_GRADE_OR_HIGH) | (pstudent == PSTUDENT_UNIVERSITY) & (persons.age > GRADE_SCHOOL_MIN_AGE), True, is_student)"
is_gradeschool,is_gradeschool,(pstudent == PSTUDENT_GRADE_OR_HIGH) & (persons.age <= GRADE_SCHOOL_MAX_AGE)
is_highschool,is_highschool,(pstudent == PSTUDENT_GRADE_OR_HIGH) & (persons.age > GRADE_SCHOOL_MAX_AGE)
is_university,is_university,pstudent == PSTUDENT_UNIVERSITY
school_segment gradeschool,school_segment,"np.where(is_gradeschool, SCHOOL_SEGMENT_GRADE, SCHOOL_SEGMENT_NONE)"
school_segment highschool,school_segment,"np.where(is_highschool, SCHOOL_SEGMENT_HIGH, school_segment)"
school_segment university,school_segment,"np.where(is_university, SCHOOL_SEGMENT_UNIV, school_segment).astype(np.int8)"
#,,
is_worker,is_worker,"np.where((pemploy == PEMPLOY_FULL) |( pemploy == PEMPLOY_PART), True, False)"
#,,
home_zone_id,home_zone_id,"reindex(households.home_zone_id, persons.household_id)"
person number,PNUM,persons.per_num
income,income,"reindex(households.hhincadj, persons.household_id)"
income_in_thousands,income_in_thousands,(income / 1000).clip(lower=0)
income_segment,income_segment,"pd.cut(income_in_thousands, bins=[-np.inf, 50, 100, 150, np.inf], labels=[1, 2, 3, 4]).astype(int)"
is_fulltime_worker,is_fulltime_worker,"((age_16_p) & (wkhp >=35) & (wkw>=1) & (wkw<=4) & (~esr.isin([3,6])))"
is_parttime_worker,is_parttime_worker,"((age_16_p) & (~esr.isin([3,6])) & (is_fulltime_worker == False))"

0 comments on commit 462c01c

Please sign in to comment.