Skip to content

Commit

Permalink
Merge pull request #178 from SANDAG/remove_xborder_constants
Browse files Browse the repository at this point in the history
Remove configs\crossborder\constants.yaml
  • Loading branch information
bhargavasana authored Aug 16, 2024
2 parents ef0d920 + d727e51 commit 16f38f8
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 136 deletions.
8 changes: 7 additions & 1 deletion src/asim/configs/common/constants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,10 @@ MedIncomeEVRebateCutoff: 4
LowIncomeBEVRebate: 0
LowIncomePEVRebate: 0
MedIncomeBEVRebate: 0
MedIncomePEVRebate: 0
MedIncomePEVRebate: 0

# MGRAs for Ports of Entry
SanYsidro_maz_id: 9279
OtayMesa_maz_id: 9387
Tecate_maz_id: 22324
OtayMesaEast_maz_id: 7123
102 changes: 0 additions & 102 deletions src/asim/configs/crossborder/constants.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions src/asim/configs/crossborder/trip_mode_choice.csv
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ util_cr_long_distance_prm,CR long distance bonus,"@(odt_skims['WALK_PRM_CMRIVTT'
#,,,,,,,,,,,,
util_TAXI_IVT,Taxi - In-vehicle time,c_ivt * s2_time_skims,,,,,,,,1,,
util_TAXI_wait,Taxi - Wait time,c_ivt * 1.5 * taxi_wait_time,,,,,,,,1,,
util_TAXI_cost,Taxi - Fare,@c_cost * ((taxi_base_fare + (df.s2_dist_skims * taxi_cost_per_mile) + (df.s2_time_skims * taxi_cost_per_minute)) * 100 + df.s2_cost_skims),,,,,,,,1,,
util_TAXI_cost,Taxi - Fare,@c_cost * ((Taxi_baseFare + (df.s2_dist_skims * Taxi_costPerMile) + (df.s2_time_skims * Taxi_costPerMinute)) * 100 + df.s2_cost_skims),,,,,,,,1,,
util_TNC_SINGLE_IVT,TNC Single - In-vehicle time,c_ivt * s2_time_skims,,,,,,,,,1,
util_TNC_SINGLE_wait,TNC Single - Wait time,c_ivt * 1.5 * tnc_single_wait_time,,,,,,,,,1,
util_TNC_SINGLE_cost,TNC Single - Cost,@c_cost * ((tnc_single_base_fare + (df.s2_dist_skims * tnc_single_cost_per_mile) + (df.s2_time_skims * tnc_single_cost_per_minute).clip(lower=tnc_single_cost_minimum)) * 100 + df.s2_cost_skims),,,,,,,,,1,
util_TNC_SINGLE_cost,TNC Single - Cost,@c_cost * ((TNC_single_baseFare + (df.s2_dist_skims * TNC_single_costPerMile) + (df.s2_time_skims * TNC_single_costPerMinute).clip(lower=TNC_single_costMinimum)) * 100 + df.s2_cost_skims),,,,,,,,,1,
util_TNC Shared_switch,TNC Shared - switch turn-off (depends on data availability),@((~df.nev_available) & (~df.microtransit_available) & (scenarioYear==2022)),,,,,,,,,,-999
util_TNC_SHARED_IVT,TNC Shared - In-vehicle time,"@df.c_ivt * np.where(df.nev_available, df.nev_time, np.where(df.microtransit_available, df.microtransit_time, df.s3_time_skims)) * tnc_shared_ivt_factor",,,,,,,,,,1
util_TNC_SHARED_wait,TNC Shared - Wait time,"@df.c_ivt * 1.5 * np.where(df.nev_available, nevWaitTime, np.where(df.microtransit_available, microtransitWaitTime, df.tnc_shared_wait_time))",,,,,,,,,,1
util_TNC_SHARED_cost,TNC Shared - Cost,"@c_cost * np.where(df.nev_available, nevCost, np.where(df.microtransit_available, microtransitCost, ((tnc_shared_base_fare + (df.s3_dist_skims * tnc_shared_cost_per_mile) + (df.s3_time_skims * tnc_shared_cost_per_minute).clip(lower=tnc_shared_cost_minimum)))) * 100 + df.s3_cost_skims)",,,,,,,,,,1
util_TNC_SHARED_cost,TNC Shared - Cost,"@c_cost * np.where(df.nev_available, nevCost, np.where(df.microtransit_available, microtransitCost, ((TNC_shared_baseFare + (df.s3_dist_skims * TNC_shared_costPerMile) + (df.s3_time_skims * TNC_shared_costPerMinute).clip(lower=TNC_shared_costMinimum)))) * 100 + df.s3_cost_skims)",,,,,,,,,,1
#,,,,,,,,,,,,
util_S2_ASC_tour_DA,s2 ASC - Tour Mode DA,@df.tour_mode_is_da * s2_ASC_tour_da,,1,,,,,,,,
util_S3_ASC_tour_DA,s3 ASC - Tour Mode DA,@df.tour_mode_is_da * s3_ASC_tour_da,,,1,,,,,,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Description,Target,Expression
,costOperatingDrive,"_costOperatingDrive + df.trip_mode.isin(['SHARED3']) * df.cost_per_mile * df.s3_dist_skims / _tour_participants"
#,,
,_cost_fare_drive,0
,_cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode == 'TAXI',1,0) * ((taxi_base_fare + (df.s2_dist_skims * taxi_cost_per_mile) + (df.s2_time_skims * taxi_cost_per_minute)) * 100 + df.s2_cost_skims) / _tour_participants"
,_cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode=='TNC_SINGLE',1,0)*((tnc_single_base_fare + (df.s2_dist_skims * tnc_single_cost_per_mile) + (df.s2_time_skims * tnc_single_cost_per_minute).clip(lower=tnc_single_cost_minimum)) * 100 + df.s2_cost_skims) / _tour_participants"
,cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode=='TNC_SHARED',1,0)*np.where(df.nev_available, 0, np.where(df.microtransit_available, 0, ((tnc_shared_base_fare + (df.s3_dist_skims * tnc_shared_cost_per_mile) + (df.s3_time_skims * tnc_shared_cost_per_minute).clip(lower=tnc_shared_cost_minimum)))) * 100 + df.s3_cost_skims) / _tour_participants"
,_cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode == 'TAXI',1,0) * ((Taxi_baseFare + (df.s2_dist_skims * Taxi_costPerMile) + (df.s2_time_skims * Taxi_costPerMinute)) * 100 + df.s2_cost_skims) / _tour_participants"
,_cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode=='TNC_SINGLE',1,0)*((TNC_single_baseFare + (df.s2_dist_skims * TNC_single_costPerMile) + (df.s2_time_skims * TNC_single_costPerMinute).clip(lower=TNC_single_costMinimum)) * 100 + df.s2_cost_skims) / _tour_participants"
,cost_fare_drive,"_cost_fare_drive + np.where(df.trip_mode=='TNC_SHARED',1,0)*np.where(df.nev_available, 0, np.where(df.microtransit_available, 0, ((TNC_shared_baseFare + (df.s3_dist_skims * TNC_shared_costPerMile) + (df.s3_time_skims * TNC_shared_costPerMinute).clip(lower=TNC_shared_costMinimum)))) * 100 + df.s3_cost_skims) / _tour_participants"
#,,
,_time_nev_in_vehicle,0
,_time_nev_in_vehicle,"_time_nev_in_vehicle + (df.trip_mode=='TNC_SHARED') * df.nev_available * df.nev_time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ light rail ASC,asc_lrt_prm,"np.where(asc_cr_prm==0, np.where(odt_skims['WALK_PRM
bus rapid transit ASC,asc_brt_prm,"np.where(asc_lrt_prm==0, np.where(odt_skims['WALK_PRM_BRTIVTT'] > 0, brt_asc * c_ivt, 0), asc_lrt_prm)"
express bus ASC,asc_eb_prm,"np.where(asc_brt_prm==0, np.where(odt_skims['WALK_PRM_LTDEXPIVTT'] + odt_skims['WALK_PRM_EXPIVTT'] > 0, exp_asc * c_ivt, 0), asc_brt_prm)"
#,,
,cost_per_mile,cost_per_mile_fuel + cost_per_mile_maint
,cost_per_mile,costPerMile
intermediate outbound stops on tour,out_stops,df['stop_frequency'].str[0].astype(int)
intermediate inbound stops on tour,in_stops,df['stop_frequency'].str[5].astype(int)
total intermediate stops,tot_stops,out_stops + in_stops
Expand Down Expand Up @@ -50,8 +50,8 @@ effective parking cost,park_cost_prim_dest,"pd.concat((park_cost_day, park_cost_
,park_cost_trip_dest_contrib,((1 - last_trip) * (1 - trip_dest_is_tour_dest)) * (park_cost_trip_dest / 2) + (trip_dest_is_tour_dest * (park_cost_tour_dest_contrib / (tot_trips + 2)))
,parking_cost,park_cost_tour_dest_contrib + park_cost_trip_orig_contrib + park_cost_trip_dest_contrib
,vot_da,c_ivt / c_cost * 0.6
,vot_s2,vot_da * cost_share_s2
,vot_s3,vot_da * cost_share_s3
,vot_s2,vot_da / cost_share_s2
,vot_s3,vot_da / cost_share_s3
,_vot_bin_da,"np.where(vot_da < vot_threshold_low, 1, np.where(vot_da < vot_threshold_med, 2, 3))"
,_vot_bin_s2,"np.where(vot_s2 < vot_threshold_low, 1, np.where(vot_s2 < vot_threshold_med, 2, 3))"
,_vot_bin_s3,"np.where(vot_s3 < vot_threshold_low, 1, np.where(vot_s3 < vot_threshold_med, 2, 3))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Description,Target,Expression
,c_xfers,c_ivt * 24
,c_walk_time,c_ivt * 1.8
,c_xfers_pnr,c_ivt * 15
,cost_per_mile,cost_per_mile_fuel + cost_per_mile_maint
,cost_per_mile,costPerMile
,vot_da,c_ivt / trip_c_cost * 0.6
,vot_s2,vot_da * cost_share_s2
,vot_s3,vot_da * cost_share_s3
,vot_s2,vot_da / cost_share_s2
,vot_s3,vot_da / cost_share_s3
,vot_bin_da,"np.where(trips.trip_mode.isin(['DRIVEALONE']),np.where(vot_da < vot_threshold_low, 1,np.where(vot_da < vot_threshold_med, 2, 3)),0)"
,vot_bin_s2,"np.where(trips.trip_mode.isin(['SHARED2','TAXI','TNC_SINGLE']),np.where(vot_s2 < vot_threshold_low,1,np.where(vot_s2 < vot_threshold_med, 2, 3)),0)"
,vot_bin_s3,"np.where(trips.trip_mode.isin(['SHARED3','TNC_SHARED']),np.where(vot_s3 < vot_threshold_low,1,np.where(vot_s3 < vot_threshold_med, 2, 3)),0)"
Expand Down
17 changes: 0 additions & 17 deletions src/asim/scripts/scenarioManagement/scenManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@
util.write_yaml(_join(configs_dir, 'common_airport', 'constants.yaml'), doc)

#update crossborder parameters
doc = util.open_yaml(_join(configs_dir, 'crossborder', 'constants.yaml'))
doc['scenarioYear'] = int(scenYear)
doc['taxi_base_fare'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'taxi.baseFare'].values[0])
doc['cost_per_mile_fuel'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'aoc.fuel'].values[0])
doc['cost_per_mile_maint'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'aoc.maintenance'].values[0])
doc['taxi_cost_per_mile'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'taxi.costPerMile'].values[0])
doc['taxi_cost_per_minute'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'taxi.costPerMinute'].values[0])
doc['tnc_single_base_fare'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.single.baseFare'].values[0])
doc['tnc_single_cost_per_mile'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.single.costPerMile'].values[0])
doc['tnc_single_cost_per_minute'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.single.costPerMinute'].values[0])
doc['tnc_single_cost_minimum'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.single.costMinimum'].values[0])
doc['tnc_shared_base_fare'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.shared.baseFare'].values[0])
doc['tnc_shared_cost_per_mile'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.shared.costPerMile'].values[0])
doc['tnc_shared_cost_per_minute'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.shared.costPerMinute'].values[0])
doc['tnc_shared_cost_minimum'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'TNC.shared.costMinimum'].values[0])
doc['ivt_brt_multiplier'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'rapid.factor.ivt'].values[0])
util.write_yaml(_join(configs_dir, 'crossborder', 'constants.yaml'), doc)
doc = util.open_yaml(_join(configs_dir, 'crossborder', 'preprocessing.yaml'))
doc['tours']['num_tours'] = int(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'crossBorder.tours'].values[0])
doc['tours']['pass_shares']['sentri'] = float(paramByYear.loc[paramByYear.year==scenYearWithSuffix, 'crossBorder.sentriShare'].values[0])
Expand Down
9 changes: 6 additions & 3 deletions src/asim/scripts/xborder/cross_border_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def assign_hh_p_to_tours(tours, persons):
action='store_true', help='Run activitysim.')
parser.add_argument(
'-c', '--configs',
action = 'append',
help = 'Config Directory')
parser.add_argument(
'-d', '--data',
Expand All @@ -717,15 +718,17 @@ def assign_hh_p_to_tours(tours, persons):
run_preprocessor = args.preprocess
run_asim = args.asim
update_wait_times = args.wait_times
config_dir = args.configs
config_dir = args.configs[0]
common_config_dir = args.configs[1]
data_dir = args.data
output_dir = args.output

# load settings
with open(os.path.join(config_dir,'preprocessing.yaml')) as f:
settings = yaml.load(f, Loader=yaml.FullLoader)

with open(os.path.join(config_dir,'constants.yaml')) as f:
#with open(os.path.join(config_dir,'constants.yaml')) as f:
with open(os.path.join(common_config_dir, 'constants.yaml')) as f:
constants_settings = yaml.load(f, Loader=yaml.FullLoader)
settings['scenario_year'] = constants_settings['scenarioYear']

Expand Down Expand Up @@ -955,7 +958,7 @@ def assign_hh_p_to_tours(tours, persons):

print('RUNNING ACTIVITYSIM!')
process = subprocess.Popen(
['python', '-u', 'src/asim/simulation.py', '-c', config_dir ,'-o', output_dir, '-d', data_dir, '-d', 'output/skims'],
['python', '-u', 'src/asim/simulation.py', '-c', config_dir , '-c', common_config_dir,'-o', output_dir, '-d', data_dir, '-d', 'output/skims'],
stdout=sys.stdout, stderr=subprocess.PIPE)
_, stderr = process.communicate()
if process.returncode != 0:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/runSandagAbm_ActivitySimXborder.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ MD crossborder
CD ..

:: Run Models
%PYTHON3% src/asim/scripts/xborder/cross_border_model.py -a -c src/asim/configs/crossborder -d input -o output/crossborder || exit /b 2
%PYTHON3% src/asim/scripts/xborder/cross_border_model.py -a -c src/asim/configs/crossborder -c src/asim/configs/common -d input -o output/crossborder || exit /b 2

::::::::::::::::::::::
CD /d %ANACONDA2_DIR%\Scripts
Expand Down

0 comments on commit 16f38f8

Please sign in to comment.