Skip to content

Joint Tour Chunking - Household Participants Need to Remain in Same Chunk #288

Description

@danielsclint

In the joint tour participation model, its possible for the chunker to split potential joint tour participants from the same household across two different chunks. This will create an endless loop and eventual assertion error in the joint tour participation model.

def chunked_choosers(choosers, rows_per_chunk):
assert choosers.shape[0] > 0
# generator to iterate over choosers in chunk_size chunks
num_choosers = len(choosers.index)
num_chunks = (num_choosers // rows_per_chunk) + (num_choosers % rows_per_chunk > 0)
i = offset = 0
while offset < num_choosers:
yield i+1, num_chunks, choosers.iloc[offset: offset+rows_per_chunk]
offset += rows_per_chunk
i += 1

If a household is split, so only one person is chosen in the chunk, the following code will never evaluate to true, because x.participants > 1 will always evaluate to False. Or... x.participants > x.adults will always evaluate to False.

satisfaction = (x.composition != 'mixed') & (x.participants > 1) | \
(x.composition == 'mixed') & (x.adults > 0) & (x.participants > x.adults)

Eventually, the mode will crash in the following set of code after the maximum number of iterations for finding participants occurs.

if iter > MAX_ITERATIONS:
logger.warning('%s max iterations exceeded (%s).', trace_label, MAX_ITERATIONS)
diagnostic_cols = ['tour_id', 'household_id', 'composition', 'adult']
unsatisfied_candidates = candidates[diagnostic_cols].join(probs)
tracing.write_csv(unsatisfied_candidates,
file_name='%s.UNSATISFIED' % trace_label, transpose=False)
print(unsatisfied_candidates.head(20))
assert False

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions