diff --git a/activitysim/abm/models/cdap.py b/activitysim/abm/models/cdap.py index 761c5c970..f41bea9ee 100644 --- a/activitysim/abm/models/cdap.py +++ b/activitysim/abm/models/cdap.py @@ -190,7 +190,7 @@ def cdap_simulate(persons_merged, persons, households, chunk_size, trace_hh_id): estimator.write_choices(choices) choices = estimator.get_survey_values(choices, "persons", "cdap_activity") if add_joint_tour_utility: - hh_joint.index.name = 'household_id' + hh_joint.index.name = "household_id" hh_joint = estimator.get_survey_values( hh_joint, "households", "has_joint_tour" ) diff --git a/activitysim/abm/models/location_choice.py b/activitysim/abm/models/location_choice.py index 7027c87dd..7e9a76d55 100644 --- a/activitysim/abm/models/location_choice.py +++ b/activitysim/abm/models/location_choice.py @@ -140,7 +140,7 @@ def _location_sample( sample_size = model_settings["SAMPLE_SIZE"] if estimator: - sample_size = model_settings.get('ESTIMATION_SAMPLE_SIZE', 0) + sample_size = model_settings.get("ESTIMATION_SAMPLE_SIZE", 0) locals_d = { "skims": skims, @@ -471,23 +471,32 @@ def run_location_sample( if estimator: # grabbing survey values survey_persons = estimation.manager.get_survey_table("persons") - if 'school_location' in trace_label: - survey_choices = survey_persons['school_zone_id'].reset_index() - elif ('workplace_location' in trace_label) and ('external' not in trace_label): - survey_choices = survey_persons['workplace_zone_id'].reset_index() + if "school_location" in trace_label: + survey_choices = survey_persons["school_zone_id"].reset_index() + elif ("workplace_location" in trace_label) and ("external" not in trace_label): + survey_choices = survey_persons["workplace_zone_id"].reset_index() else: return choices - survey_choices.columns = ['person_id', 'alt_dest'] - survey_choices = survey_choices[survey_choices['person_id'].isin(choices.index) & (survey_choices.alt_dest > 0)] + survey_choices.columns = ["person_id", "alt_dest"] + survey_choices = survey_choices[ + survey_choices["person_id"].isin(choices.index) + & (survey_choices.alt_dest > 0) + ] # merging survey destination into table if not available - joined_data = survey_choices.merge(choices, on=['person_id', 'alt_dest'], how='left', indicator=True) - missing_rows = joined_data[joined_data['_merge'] == 'left_only'] - missing_rows['pick_count'] = 1 + joined_data = survey_choices.merge( + choices, on=["person_id", "alt_dest"], how="left", indicator=True + ) + missing_rows = joined_data[joined_data["_merge"] == "left_only"] + missing_rows["pick_count"] = 1 if len(missing_rows) > 0: - new_choices = missing_rows[['person_id', 'alt_dest', 'prob', 'pick_count']].set_index('person_id') + new_choices = missing_rows[ + ["person_id", "alt_dest", "prob", "pick_count"] + ].set_index("person_id") choices = choices.append(new_choices, ignore_index=False).sort_index() # making probability the mean of all other sampled destinations by person - choices['prob'] = choices['prob'].fillna(choices.groupby('person_id')['prob'].transform('mean')) + choices["prob"] = choices["prob"].fillna( + choices.groupby("person_id")["prob"].transform("mean") + ) return choices diff --git a/activitysim/estimation/larch/__init__.py b/activitysim/estimation/larch/__init__.py index d5ff3d092..a175db6e7 100644 --- a/activitysim/estimation/larch/__init__.py +++ b/activitysim/estimation/larch/__init__.py @@ -11,6 +11,7 @@ from .stop_frequency import * from .external_worker_identification import * + def component_model(name, *args, **kwargs): if isinstance(name, str): m = globals().get(f"{name}_model") diff --git a/activitysim/estimation/larch/location_choice.py b/activitysim/estimation/larch/location_choice.py index 64aa47141..41e2f78e6 100644 --- a/activitysim/estimation/larch/location_choice.py +++ b/activitysim/estimation/larch/location_choice.py @@ -330,6 +330,7 @@ def workplace_location_model(**kwargs): **kwargs, ) + def external_workplace_location_model(**kwargs): unused = kwargs.pop("name", None) return location_choice_model( @@ -337,6 +338,7 @@ def external_workplace_location_model(**kwargs): **kwargs, ) + def school_location_model(**kwargs): unused = kwargs.pop("name", None) return location_choice_model( diff --git a/activitysim/estimation/larch/simple_simulate.py b/activitysim/estimation/larch/simple_simulate.py index 87ec5594c..843311da1 100644 --- a/activitysim/estimation/larch/simple_simulate.py +++ b/activitysim/estimation/larch/simple_simulate.py @@ -230,6 +230,7 @@ def free_parking_model( }, # True is free parking, False is paid parking, names match spec positions ) + def work_from_home_model( name="work_from_home", edb_directory="output/estimation_data_bundle/{name}/", @@ -311,6 +312,7 @@ def joint_tour_participation_model( }, ) + def external_non_mandatory_identification_model( name="external_non_mandatory_identification", edb_directory="output/estimation_data_bundle/{name}/", @@ -339,8 +341,8 @@ def transit_pass_subsidy_model( edb_directory=edb_directory, return_data=return_data, choices={ - 0: 1, # 0 means no subsidy, alternative 1 - 1: 2, # 1 means subsidy, alternative 2 + 0: 1, # 0 means no subsidy, alternative 1 + 1: 2, # 1 means subsidy, alternative 2 }, ) @@ -355,11 +357,12 @@ def transit_pass_ownership_model( edb_directory=edb_directory, return_data=return_data, choices={ - 0: 1, # 0 means no pass, alternative 1 - 1: 2, # 1 means pass, alternative 2 + 0: 1, # 0 means no pass, alternative 1 + 1: 2, # 1 means pass, alternative 2 }, ) + def transponder_ownership_model( name="transponder_ownership", edb_directory="output/estimation_data_bundle/{name}/", @@ -370,7 +373,7 @@ def transponder_ownership_model( edb_directory=edb_directory, return_data=return_data, choices={ - 0: 1, # 0 means no pass, alternative 1 - 1: 2, # 1 means pass, alternative 2 + 0: 1, # 0 means no pass, alternative 1 + 1: 2, # 1 means pass, alternative 2 }, - ) \ No newline at end of file + )