Skip to content

Commit

Permalink
trace proto tables if available, otherwise synthetic population
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensle committed Oct 4, 2024
1 parent ecb00b5 commit c633d39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions activitysim/abm/models/disaggregate_accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
21 changes: 11 additions & 10 deletions activitysim/core/workflow/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit c633d39

Please sign in to comment.