Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracing fix for HH ID that exists in both synthetic and proto populations #901

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading