diff --git a/activitysim/abm/models/disaggregate_accessibility.py b/activitysim/abm/models/disaggregate_accessibility.py index 40265b798..fd79a188d 100644 --- a/activitysim/abm/models/disaggregate_accessibility.py +++ b/activitysim/abm/models/disaggregate_accessibility.py @@ -922,10 +922,6 @@ def compute_disaggregate_accessibility( for ch in list(state.get_rn_generator().channels.keys()): state.get_rn_generator().drop_channel(ch) - # Drop any prematurely added traceables - for trace in [x for x in state.tracing.traceable_tables if "proto_" not in x]: - state.tracing.deregister_traceable_table(trace) - # # need to clear any premature tables that were added during the previous run for name in list(state.existing_table_status): if name not in tables_prior: @@ -954,4 +950,8 @@ def compute_disaggregate_accessibility( ) state.add_table(tablename, df) + # drop all proto-related tables and make way for synthetic population + for trace in state.tracing.traceable_tables: + state.tracing.deregister_traceable_table(trace) + return diff --git a/activitysim/core/workflow/tracing.py b/activitysim/core/workflow/tracing.py index 384e10f59..580c6fad9 100644 --- a/activitysim/core/workflow/tracing.py +++ b/activitysim/core/workflow/tracing.py @@ -506,18 +506,19 @@ def interaction_trace_rows(self, interaction_df, choosers, sample_size=None): traceable_table_ids = self.traceable_table_ids - # Determine whether actual tables or proto_ tables for disaggregate accessibilities - persons_table_name = set(traceable_table_ids).intersection( - ["persons", "proto_persons"] - ) - households_table_name = set(traceable_table_ids).intersection( - ["households", "proto_households"] + # trace proto tables if they exist, otherwise trace actual tables + # proto tables are used for disaggregate accessibilities and + # are removed from the traceable_table_ids after the accessibilities are created + households_table_name = ( + "proto_households" + if "proto_households" in traceable_table_ids.keys() + else "households" ) - assert len(persons_table_name) == 1 and len(persons_table_name) == 1 - persons_table_name, households_table_name = ( - persons_table_name.pop(), - households_table_name.pop(), + persons_table_name = ( + "proto_persons" + if "proto_persons" in traceable_table_ids.keys() + else "persons" ) if (