At-work Subtour Mode#

The at-work subtour mode choice model assigns a travel mode to each at-work subtour using the tour_mode_choice model.

The main interface to the at-work subtour mode choice model is the atwork_subtour_mode_choice function. This function is called in the Inject step atwork_subtour_mode_choice and is registered as an Inject step in the example Pipeline. writing_logsums for how to write logsums for estimation.

Structure#

  • Configuration File: tour_mode_choice.yaml

  • Core Table: tour

  • Result Field: tour_mode

  • Skims keys: workplace_taz, destination, start, end

Configuration#

settings activitysim.abm.models.atwork_subtour_mode_choice.TourModeComponentSettings#

Bases: TemplatedLogitComponentSettings

Fields:
  • COEFFICIENTS (pathlib.Path | None)

  • COEFFICIENT_TEMPLATE (str | None)

  • COMPUTE_TRIP_MODE_CHOICE_LOGSUMS (bool)

  • CONSTANTS (dict[str, typing.Any])

  • FORCE_ESCORTEE_CHAUFFEUR_MODE_MATCH (bool)

  • LOGIT_TYPE (Literal['MNL', 'NL'])

  • LOGSUM_CHOOSER_COLUMNS (list[str])

  • MODE_CHOICE_LOGSUM_COLUMN_NAME (str | None)

  • NESTS (activitysim.core.configuration.logit.LogitNestSpec | None)

  • SPEC (pathlib.Path)

  • annotate_tours (activitysim.core.configuration.base.PreprocessorSettings | None)

  • nontour_preprocessor (activitysim.core.configuration.base.PreprocessorSettings | list[activitysim.core.configuration.base.PreprocessorSettings] | None)

  • preprocessor (activitysim.core.configuration.base.PreprocessorSettings | list[activitysim.core.configuration.base.PreprocessorSettings] | None)

  • sharrow_skip (bool)

  • source_file_paths (list[pathlib.Path])

  • tvpb_mode_path_types (dict[str, typing.Any] | None)

  • use_TVPB_constants (bool)

Validators:
  • nests_are_for_nl » NESTS

field COEFFICIENTS: Path | None = None#

Coefficients filename.

This is a CSV file giving named parameters for use in the utility expression. If it is not provided, then it is assumed that all model coefficients are given explicitly in the SPEC as numerical values instead of named parameters. This is perfectly acceptable for use with ActivitySim for typical simulation applications, but may be problematic if used with “estimation mode”.

field COEFFICIENT_TEMPLATE: str | None = None#

Coefficients template filename.

For a segmented model component, this maps the named parameters to segment-specific names.

field COMPUTE_TRIP_MODE_CHOICE_LOGSUMS: bool = False#
field CONSTANTS: dict[str, Any] = {}#

Named constants usable in the utility expressions.

field FORCE_ESCORTEE_CHAUFFEUR_MODE_MATCH: bool = True#
field LOGIT_TYPE: Literal['MNL', 'NL'] = 'MNL'#

Logit model mathematical form.

  • “MNL”

    Multinomial logit model.

  • “NL”

    Nested multinomial logit model.

field LOGSUM_CHOOSER_COLUMNS: list[str] = []#
field MODE_CHOICE_LOGSUM_COLUMN_NAME: str | None = None#
field NESTS: LogitNestSpec | None = None#

Nesting structure for a nested logit model.

The nesting structure is specified heirarchically from the top, so the value of this field should be the “root” level nest of the nested logit tree, which should contain references to lower level nests and/or the actual alternatives.

For example, this YAML defines a simple nesting structure for four alternatives (DRIVE, WALK, WALK_TO_TRANSIT, DRIVE_TO_TRANSIT) with the two transit alternatives grouped together in a nest:

NESTS:
  name: root
  coefficient: coef_nest_root
  alternatives:
    - DRIVE
    - WALK
    - name: TRANSIT
      coefficient: coef_nest_transit
      alternatives:
      - WALK_TO_TRANSIT
      - DRIVE_TO_TRANSIT
Validated by:
  • nests_are_for_nl

field SPEC: Path [Required]#

Utility specification filename.

This is sometimes alternatively called the utility expressions calculator (UEC). It is a CSV file giving all the functions for the terms of a linear-in-parameters utility expression.

field annotate_tours: PreprocessorSettings | None = None#
field nontour_preprocessor: PreprocessorSettings | list[PreprocessorSettings] | None = None#
field preprocessor: PreprocessorSettings | list[PreprocessorSettings] | None = None#
field sharrow_skip: bool = False#

Skip sharrow when evaluating this component.

field source_file_paths: list[Path] = None#

A list of source files from which these settings were loaded.

This value should not be set by the user within the YAML settings files, instead it is populated as those files are loaded. It is primarily provided for debugging purposes, and does not actually affect the operation of any model.

field tvpb_mode_path_types: dict[str, Any] | None = None#
field use_TVPB_constants: bool = True#
validator nests_are_for_nl  »  NESTS#

Checks that nests are provided if (and only if) LOGIT_TYPE is NL.

Examples#

Implementation#

activitysim.abm.models.atwork_subtour_mode_choice.atwork_subtour_mode_choice(state: State, tours: DataFrame, persons_merged: DataFrame, network_los: Network_LOS, model_settings: Optional[TourModeComponentSettings] = None, model_settings_file_name: str = 'tour_mode_choice.yaml', trace_label: str = 'atwork_subtour_mode_choice') None#

At-work subtour mode choice simulate