Skip to content

Commit

Permalink
Add full recursive binary search to second pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsnow committed Dec 4, 2024
1 parent f28ad97 commit 3591995
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions data/src/utils/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,23 +613,25 @@ def many_to_many(self, second_pass: bool = True) -> pd.DataFrame:
self.config.logger.info("Routing missing set number %s", idx)
o_ids = missing_set["origin_id"].unique()
d_ids = missing_set["destination_id"].unique()
results_sp.extend(
self._binary_search(
o_start_idx=0,
d_start_idx=0,
o_end_idx=len(o_ids),
d_end_idx=len(d_ids),
print_log=True,
cur_depth=0,
origins=self.inputs.origins[
self.inputs.origins["id"].isin(o_ids)
],
destinations=self.inputs.destinations[
self.inputs.destinations["id"].isin(d_ids)
],
actor=self.actor_fallback,
)
)
for o in range(0, len(o_ids), max_spl_o):
for d in range(0, len(d_ids), m_spl_d):
results_sp.extend(
self._binary_search(
o_start_idx=o,
d_start_idx=d,
o_end_idx=min(o + max_spl_o, len(o_ids)),
d_end_idx=min(d + m_spl_d, len(d_ids)),
print_log=True,
cur_depth=0,
origins=self.inputs.origins[
self.inputs.origins["id"].isin(o_ids)
],
destinations=self.inputs.destinations[
self.inputs.destinations["id"].isin(d_ids)
],
actor=self.actor_fallback,
)
)

# Merge the results from the second pass with the first pass
results_sp_df = (
Expand Down

0 comments on commit 3591995

Please sign in to comment.