-
Notifications
You must be signed in to change notification settings - Fork 118
Description
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.
activitysim/activitysim/core/chunk.py
Lines 217 to 229 in 7b57c94
| 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.
activitysim/activitysim/abm/models/joint_tour_participation.py
Lines 86 to 87 in 7b57c94
| 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.
activitysim/activitysim/abm/models/joint_tour_participation.py
Lines 158 to 165 in 7b57c94
| 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 |