Skip to content

Commit

Permalink
Merge pull request #13 from ActivitySim/trip_dest_preprocessor
Browse files Browse the repository at this point in the history
Trip Destination Alts Preprocessor
  • Loading branch information
jpn-- authored May 14, 2024
2 parents 85c1ecb + 64320e5 commit 97b8bf7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion configs/resident/trip_destination.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local_dist_nd,,_nd_DIST@nd_skims['DIST'],1,1,1,1,1,1,1,1,1,1
distance_deviation,distance deviation,_dist_dev@(_od_DIST +_dp_DIST - _op_DIST),1,1,1,1,1,1,1,1,1,1
dist_deviation_logged,logged deviation distance,"_dist_dev_logged@np.where((_dist_dev > 0), np.log(_dist_dev),0)",1,1,1,1,1,1,1,1,1,1
#,,,,,,,,,,,,
util_sizeterm,size term,"@np.log1p(size_terms.get(df.dest_taz, df.purpose)) # sharrow: np.log1p(size_terms['sizearray'])",coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one
util_sizeterm,size term,"@np.log1p(size_terms.get(df.alt_dest, df.purpose)) # sharrow: np.log1p(size_terms['sizearray'])",coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one
util_Sampleofalternativescorrectionfactor,Sample of alternatives correction factor,"@np.minimum(np.log(df.pick_count/df.prob), 60)",coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one,coef_one
util_Modechoicelogsum,Mode choice logsum,od_logsum + dp_logsum,coef_mode_choice_logsum_mandatory,coef_mode_choice_logsum_mandatory,coef_mode_choice_logsum_mandatory,coef_mode_choice_logsum_maint,coef_mode_choice_logsum_maint,coef_mode_choice_logsum_maint,coef_mode_choice_logsum_discr,coef_mode_choice_logsum_discr,coef_mode_choice_logsum_discr,coef_mode_choice_logsum_discr
#,,,,,,,,,,,,
Expand Down
18 changes: 15 additions & 3 deletions configs/resident/trip_destination.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ DEST_CHOICE_SAMPLE_TABLE_NAME: trip_destination_sample

# model-specific logsum-related settings
TRIP_ORIGIN: origin
ALT_DEST_COL_NAME: dest_taz
ALT_DEST_COL_NAME: alt_dest
PRIMARY_ORIGIN: tour_leg_origin
PRIMARY_DEST: tour_leg_dest # must be created in preprocessor

# tour_mode is already in trips table, so we don't need it from tours
# (it is assigned in trip_destination_annotate_trips_preprocessor )
REDUNDANT_TOURS_MERGED_CHOOSER_COLUMNS:
- tour_mode



preprocessor:
SPEC: trip_destination_annotate_trips_preprocessor
DF: trips
Expand All @@ -37,6 +35,20 @@ preprocessor:
- households
- land_use

# preprocessor for sample, operates on TAZs
alts_preprocessor_sample:
SPEC: trip_destination_annotate_alts_preprocessor_sample
DF: alternatives
TABLES:
- land_use

# preprocessor for simulate, operates on MAZs in two zone models
# alts_preprocessor_sample:
# SPEC: trip_destination_annotate_alts_preprocessor_simulate
# DF: alternatives
# TABLES:
# - land_use


# drop failed trips and cleanup failed trip leg_mates for consistency
# (i.e. adjust trip_count, trip_num, first for missing failed trips)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Description,Target,Expression
micromobility access time at destination taz,d_microAccTime,"land_use.groupby('TAZ')['MicroAccessTime'].agg('max').reindex(df.index)"
8 changes: 3 additions & 5 deletions configs/resident/trip_destination_sample.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ Description,Expression,work,univ,school,escort,shopping,eatout,othmaint,social,o
,_op_DIST@op_skims['DIST'],1,1,1,1,1,1,1,1,1,1
,_od_bikeL@odt_skims['BIKE_LOGSUM'],1,1,1,1,1,1,1,1,1,1
,_dp_bikeL@dpt_skims['BIKE_LOGSUM'],1,1,1,1,1,1,1,1,1,1
# next line gets max MAZ micromobility access time in destination TAZ
,"_d_microAccTime@land_use.sort_values(by='MicroAccessTime',ascending=False).drop_duplicates('TAZ',keep='first').set_index('TAZ')['MicroAccessTime'].reindex(df.dest_taz)",1,1,1,1,1,1,1,1,1,1
#,,,,,,,,,,,
size term,"@np.log1p(size_terms.get(df.dest_taz, df.purpose)) # sharrow: np.log1p(size_terms['sizearray'])",1,1,1,1,1,1,1,1,1,1
no attractions,"@size_terms.get(df.dest_taz, df.purpose) == 0 # sharrow: size_terms['sizearray'] == 0",-999,-999,-999,-999,-999,-999,-999,-999,-999,-999
size term,"@np.log1p(size_terms.get(df.alt_dest, df.purpose)) # sharrow: np.log1p(size_terms['sizearray'])",1,1,1,1,1,1,1,1,1,1
no attractions,"@size_terms.get(df.alt_dest, df.purpose) == 0 # sharrow: size_terms['sizearray'] == 0",-999,-999,-999,-999,-999,-999,-999,-999,-999,-999
#,,,,,,,,,,,
,"@df.walkTour * (np.where(_od_DIST > df.max_walk_distance,1,0) + np.where(_dp_DIST > df.max_walk_distance,1,0))",-10,-10,-10,-10,-10,-10,-10,-10,-10,-10
,@df.walkTour * (_od_DIST + _dp_DIST),-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,-0.5,-0.5
Expand All @@ -19,4 +17,4 @@ no attractions,"@size_terms.get(df.dest_taz, df.purpose) == 0 # sharrow: size_te
,@df.bikeTour * (_dp_bikeL < -300),-999,-999,-999,-999,-999,-999,-999,-999,-999,-999
#,,,,,,,,,,,
,@(df.nonmotorTour==0) * (_od_DIST + _dp_DIST - _op_DIST),-0.05,-0.05,-0.05,-0.05,-0.05,-0.05,-0.05,-0.05,-0.05,-0.05
,"@(df.microTour * (np.where(_d_microAccTime > microAccessThreshold,1,0) + np.where(df.o_MicroAccessTime > microAccessThreshold,1,0)))",-10,-10,-10,-10,-10,-10,-10,-10,-10,-10
,"@(df.microTour * (np.where(df.d_microAccTime > microAccessThreshold,1,0) + np.where(df.o_MicroAccessTime > microAccessThreshold,1,0)))",-10,-10,-10,-10,-10,-10,-10,-10,-10,-10

0 comments on commit 97b8bf7

Please sign in to comment.