Estimation Mode - ActivitySim/activitysim GitHub Wiki

See Phase 5 Task 9 for an overview of the task.

Estimation tools

See Estimation Tools Review for a review of the characteristics, pros, cons and selection of the best estimation tool to prototype estimation mode integration.

Integration

A script will transform the activitysim estimation data export to estimation formats, run the estimation tool, and update the activitysim model coefficients.

The basic workflow:

  • Run a 2k household sample up through a model such as tour_mode_choice to create a synthetic version of a household travel survey in activitysim format up to that point. In reality the user uses their actual household survey and not a synthetic one.
  • The output files then becomes the input to running activitysim in estimation mode.
  • We then run just tour_mode_choice again, but this time with estimation mode set to true to write out all the required data for re-estimating the model. We're calling this the estimation data bundle (EDB), which is somewhat like the trace data, but for every household:
    • chooser table
    • expression values table
    • coefficients table
    • choices table
    • raw_utilities table (to determine if alternatives are available)
    • Plus model specification inputs such as the yaml, spec, etc
  • A pandas script then:
    • Reads the chooser table, expression values, raw_utilities, tour_mode_choice.yaml, tour_mode_choice.csv, and tour_mode_choice_coeffs.csv
    • Transforms the data into the formats required by the estimation tool
    • Runs estimation
    • Writes the output coefficients back to activitysim format

Some additional considerations

  • We need to better separate coefficients from data so the coefficients can be re-estimated in the estimation tool and then easily passed back to asim for model simulation. I think this means every logit model needs an explicit coefficients.csv input file now.
  • We will also read in the observed_choice (alternative) in order to use it instead of the chosen alternative for subsequent model step re-estimation. This includes for post-processor annotators as well.
  • When we do destination choice, if destination sampling is done, then the observed alternative may not be in the estimation data bundle. To get started, we'll just run it without sampling for now so we get all the alternatives, and think about how best to do this.
  • Estimation mode runs singled processed and doesn't use shadow pricing.
  • Inspired by DaySim estimation mode design, which means new terms / alternative model structures (say changing the nesting structure) are done first in asim and then required data is written out to the estimation tool.

Getting started

  • We will prototype tour mode choice
  • We will use CSV formats
  • Create the 2k HH asim format HH survey through tour_mode_choice
  • Clean-up coefficients separation #303 and write out the estimation data bundle #304
  • Write pandas script to transform data, run estimation tool, transform coefficient file, etc.
  • We'll create a first version and then iterate as needed
  • For now we're focused on just the integration with the estimation tool; we'll work on the "using the observed choice and running downstream models" need in the second half of this task

Estimation Recipes by Submode

The following table lists estimation functionality by submodel. An estimation recipe defines the type of model for writing the estimation data bundle (EDB) and the example larch notebook illustrates round-trip estimation integration. An entry in the estimation recipe or example larch notebook column means the functionality has been implemented to date.

Estimatable Submodel Estimation Recipe (including reading survey files, overriding choices, and writing EDBs) Estimation with Larch Example Notebook
initialize_landuse
compute_accessibility
initialize_households
x school_location interaction_sample_simulate notebook
x workplace_location interaction_sample_simulate notebook
x auto_ownership_simulate simple_simulate notebook
x free_parking simple_simulate
x cdap_simulate cdap_simulate
x mandatory_tour_frequency simple_simulate
x mandatory_tour_scheduling interaction_sample_simulate
x joint_tour_frequency simple_simulate
x joint_tour_composition simple_simulate
x joint_tour_participation simple_simulate
x joint_tour_destination interaction_sample_simulate
x joint_tour_scheduling interaction_sample_simulate
x non_mandatory_tour_frequency interaction_simulate
x non_mandatory_tour_destination interaction_sample_simulate
x non_mandatory_tour_scheduling interaction_sample_simulate
x tour_mode_choice_simulate simple_simulate notebook
x atwork_subtour_frequency simple_simulate
x atwork_subtour_destination interaction_sample_simulate
x atwork_subtour_scheduling interaction_sample_simulate
x atwork_subtour_mode_choice simple_simulate
x stop_frequency
trip_purpose
x trip_destination
trip_purpose_and_destination
x trip_scheduling
x trip_mode_choice
write_data_dictionary
track_skim_usage
write_trip_matrices
write_tables