mode_choice package

Submodules

mode_choice.mode_choice module

class mode_choice.mode_choice.Mode_Choice(config)[source]

Bases: object

Mode choice class that computes mode probabilities and calculated trips by mode.

This object takes in the skims, parameters, SE data, and trip tables by purpose and time period and outputs the trip tables by mode

Parameters:config – the scenario object defined in the config.py

Summaries of the modal trip tables are provided by the functions in the mc_util.py module

Warning

hardcoded skim names and vehicle/tod segments must match the modes defined in model_defs.py

Todo

set skim names and market segments dynamically based on model_defs.py

calculate_trips_by_mode()[source]

Applies trip tables to mode shares to generate modal trip tables

call_mode_probability_tables(pv='0_PK', mode='DA')[source]
call_var_by_mode(pv='0_PK', var='OVTT', mode='DA')[source]
load_input()[source]

Reads the skims, trip tables, and zonal data into memory for processing

read_param(purpose)[source]

Reads associated parameters file with mode choice coefficients

run_for_purpose(purpose)[source]

Runs mode choice model for selected purpose and populates the table_container object of ModeChoice with the modal tables

Parameters:purpose – Purpose string (e.g. ‘HBW’) to run
run_model()[source]

Runs mode choice model and populates the table_container object of ModeChoice with the modal tables

class mode_choice.mode_choice.Shared_Mobility(sm_params)[source]

Bases: object

Shared Mobility Values

mode_choice.scenario_editor module

mode_choice.scenario_editor.active_transportation_modify_skim(mc_obj, bike_project_file)[source]

improve bike and walk skims according to new projects

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • bike_project_file – file with zones and factors to adjust bike time and distance
mode_choice.scenario_editor.bike_advantage_modify_skim(mc_obj, bike_skim_factor)[source]

cross the board factoring of bike time and distance

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • bike_skim_factor – factor to apply to bike time and distance
mode_choice.scenario_editor.boston_pev(mc_obj, pev_factor)[source]

reduce PEV variable by factor for zones within Boston

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • pev_factor – adjustments to PEV for all Boston zones
mode_choice.scenario_editor.clean_vehicle_costs(mc_obj, clean_savings)[source]

Decrease the cost per mile for clean vehicles

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • clean_savings – adjustment value (cents per mile) added to op cost
mode_choice.scenario_editor.compact_land_use(mc_obj, zone_factor_file)[source]

shifts growth in trips according to zones and factors defined in file

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • zone_factor_file – file containing zones and growth factor
mode_choice.scenario_editor.congestion_charge(mc_obj, cordon_area, charge)[source]

apply a congestion charge for all trips to the cordon area

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • cordon_area – cordon area neighborhoods
  • charge – charge to be applied for trips to the cordon area
mode_choice.scenario_editor.land_use_growth_shift(mc_obj, growth_shift_factor, zone_factor_file)[source]

shifts growth in trips to zones identified in zone factor file

Growth is shifted to zones identified in the input file from Boston zones not included in the file

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • growth_shift_factor – amount of growth to shift
  • zone_factor_file – file containing zones to shift growth to
mode_choice.scenario_editor.parking_cost_change(mc_obj, parking_charge)[source]

increase parking costs for trips ending in Boston

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • parking_charge – value to add to parking charge for all zones in Boston
mode_choice.scenario_editor.reduce_boston_veh_ownership(mc_obj, boston_veh_decrease)[source]

shift HH from 1+ to zero vehicles for Boston only

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • boston_veh_decrease – factor to shift boston trips from with/vehicle to zero vehicle
mode_choice.scenario_editor.reduce_hbw_peak_trips(mc_obj, tdm_rate)[source]

reduce HBW trips

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • tdm_rate – adjustment to hbw peak trips
mode_choice.scenario_editor.reduce_outside_boston_veh_ownership(mc_obj, veh_decrease)[source]

shift HH from 1+ to zero vehicles for areas outside Boston

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • boston_veh_decrease – factor to shift trips from with/vehicle to zero vehicle
mode_choice.scenario_editor.shared_mobility(mc_obj, param_file, coeffs)[source]

setup shared mobility scenarios

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • param_file – parameter file with shared mobility alternatives
  • coeffs – shared mobility fare, waiting time, and subsidy terms
mode_choice.scenario_editor.transit_improvement_projects(mc_obj, project_impact_file, transit_project_factor)[source]

reduce transit OVTT and IVTT according to transit project impacts

Adjust transit times based on transit projects

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • project_impact_file – file with transit projects
  • transit_project_factor – factor to apply to zones with transit projects
mode_choice.scenario_editor.transit_ivt_modify_skim(mc_obj, transit_ivt_factor)[source]

apply transit travel time factor to skims

Factor transit invehicle time across all modes and time periods

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • transit_ivt_factor – factor to be applied to transit ivt
mode_choice.scenario_editor.transit_mode_fare_factor(mc_obj, lb_fact, rt_fact, cr_fact, boat_fact, walk_fact)[source]

adjust transit fares by sub-mode

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • lb_fact – drive to local bus fare factor
  • rt_fact – drive to rapid transit fare factor
  • cr_fact – drive to commuter rail fare factor
  • boat_fact – drive to ferry fare factor
  • walk_fact – walk to any transit mode fare factor
mode_choice.scenario_editor.trip_pricing(mc_obj, trip_price)[source]

set per-trip pricing

create a new parameter file with the modified constant values to reflect additional trip pricing for auto modes

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • trip_price – trip price value
mode_choice.scenario_editor.vmt_fee(mc_obj, per_mile_fee)[source]

adjust vehicle cost per mile to represent VMT fee

Parameters:
  • mc_obj – the mode choice object containing parameters and inputs
  • per_mile_fee – value to add to vehicle operating cost

mode_choice.mc_util module

mode_choice.mc_util.act_pmt_by_neighborhood(mc_obj, out_fn=None, by=None)[source]

Summarizes PMT production and attraction by the 26 Boston neighborhoods for active modes.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary; if None specified, only aggregate production and attraction will be provided.
mode_choice.mc_util.display_mode_share(mc_obj)[source]

This displays a mode share summary by market segment (with / without vehicle, peak / off-peak) on the IPython notebook.

Parameters:mc_obj – mode choice module object as defined in the IPython notebook
mode_choice.mc_util.mode_share_by_neighborhood(mc_obj, out_fn=None, by=None)[source]

Summarizes mode share as the average of trips to/from the 26 Boston neighborhoods, in three categories - drive, non-motorized and transit.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary
mode_choice.mc_util.pmt_by_neighborhood(mc_obj, out_fn=None, by=None)[source]

Summarizes PMT production and attraction by the 26 Boston neighborhoods.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary; if None specified, only aggregate production and attraction will be provided.
mode_choice.mc_util.productions_by_region(mc_obj, region='all', cordon_area=[])[source]
mode_choice.mc_util.sm_trips_by_neighborhood(mc_obj, out_fn=None, by=None, sm_mode='SM_RA')[source]

Summarizes PMT production and attraction by the 26 Boston neighborhoods for Shared Mobility Modes.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary; if None specified, only aggregate production and attraction will be provided.
  • sm_mode – Smart Mobility Mode name
mode_choice.mc_util.sm_vmt_by_neighborhood(mc_obj, out_fn=None, by=None, sm_mode='SM_RA')[source]

Summarizes VMT production and attraction by the 26 Boston neighborhoods for Shared Mobility Modes.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary; if None specified, only aggregate production and attraction will be provided.
mode_choice.mc_util.transit_ridership(mc_obj, by='all')[source]

Summarizes transit ridership by peak period in cities and towns with MBTA subway service.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • mbta_fn – TAZ file that contains MBTA coverage definition
  • out_path – output path.
mode_choice.mc_util.trips_by_mode(mc_obj, mode='all')[source]
mode_choice.mc_util.trips_by_neighborhood(mc_obj, out_fn=None, by=None)[source]

Summarizes PMT production and attraction by the 26 Boston neighborhoods.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary; if None specified, only aggregate production and attraction will be provided.
mode_choice.mc_util.vmt_by_neighborhood(mc_obj, out_fn=None, by=None)[source]

Summarizes VMT production and attraction by the 26 Boston neighborhoods.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_fn – output csv filename; if None specified, in the output path defined in config.py
  • by – grouping used for the summary; if None specified, only aggregate production and attraction will be provided.
mode_choice.mc_util.write_boston_mode_share_to_excel(mc_obj)[source]

Writes mode share summary by purpose and market segment to an Excel workbook. Applies only to trips to/from Boston

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_excel_fn – output Excel filename, by default in the output path defined in config.py
mode_choice.mc_util.write_boston_neighbortown_mode_share_to_excel(mc_obj)[source]

Writes mode share summary by purpose and market segment to an Excel workbook. Applies only to trips to/from Boston

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • out_excel_fn – output Excel filename, by default in the output path defined in config.py
mode_choice.mc_util.write_mode_share_to_excel(mc_obj, purpose)[source]

Writes mode share summary by purpose and market segment to an Excel workbook.

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • purpose – can be a single purpose or ‘all’, in which case the Excel workbook has six sheets, one for each purpose.
  • out_excel_fn – output Excel filename, by default in the output path defined in config.py
mode_choice.mc_util.write_summary_by_subregion(mc_obj, by='all')[source]

Summarizes VMT, PMT or mode share by subregions of Massachusetts surrounding Boston (neighboring towns of Boston / within I-93/95 / within I-495).

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • taz_fn – TAZ file that contains subregion definition
  • out_path – output path.
mode_choice.mc_util.write_summary_by_subregion_sm(mc_obj, by='all')[source]

Summarizes Smart Mobility VMT and trips by subregions of Massachusetts surrounding Boston (neighboring towns of Boston / within I-93/95 / within I-495).

Parameters:
  • mc_obj – mode choice module object as defined in the IPython notebook
  • taz_fn – TAZ file that contains subregion definition
  • out_path – output path.

mode_choice.trk_util module

mode_choice.trk_util.compute_summary_by_subregion(mc_obj, metric='VMT', subregion='neighboring')[source]

Computing function used by write_summary_by_subregion(), does not produce outputs

mode_choice.trk_util.trip_by_neighborhood(mc_obj, out_fn=None)[source]

Summarizes Truck trips production and attraction by the 26 Boston neighborhoods. :param mc_obj: mode choice module object as defined in the IPython notebook :param out_fn: output csv filename; if None specified, in the output path defined in config.py :param by: grouping used for the summary; if None specified, only aggregate production and attraction will be provided.

mode_choice.trk_util.vmt_by_neighborhood(mc_obj, out_fn=None)[source]

Summarizes Truck VMT production and attraction by the 26 Boston neighborhoods. :param mc_obj: mode choice module object as defined in the IPython notebook :param out_fn: output csv filename; if None specified, in the output path defined in config.py :param by: grouping used for the summary; if None specified, only aggregate production and attraction will be provided.

mode_choice.trk_util.write_summary_by_subregion(mc_obj)[source]

Summarizes Truck VMT and trips by subregions of Massachusetts surrounding Boston (neighboring towns of Boston / within I-93/95 / within I-495). :param mc_obj: mode choice module object as defined in the IPython notebook :param taz_fn: TAZ file that contains subregion definition :param out_path: output path.

mode_choice.input_prep module

mode_choice.input_prep.inter_extrap_triptable(config, year=2030)[source]

interpolate or extrapolate trip tables

Parameters:
  • config – the scenario object defined in the config.py - path to output trip table
  • year – year of interpolated or extrapolated trip table
mode_choice.input_prep.inter_extrap_trucktriptable(config, year=2030)[source]

interpolate or extrapolate truck trip tables

Parameters:
  • config – the scenario object defined in the config.py - path to output trip table
  • year – year of interpolated or extrapolated trip table
mode_choice.input_prep.land_use_growth_shift(config, factor=0.5)[source]

apply land use growth shifts to tazs defined in Densified_TAZs.csv

Parameters:
  • config – the scenario object defined in the config.py - path to output trip table and zone files
  • factor – share of growth to be reallocated

Module contents