Repository navigation
Conversation
Reuse reachable nodes while adding flux edges in sorted order. Reduce endpoint sorting and repeated sparse matrix copies. Co-Authored-By: Aiden <aiden@weco.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #351 +/- ##
==========================================
- Coverage 94.03% 93.93% -0.11%
==========================================
Files 141 141
Lines 11199 11237 +38
==========================================
+ Hits 10531 10555 +24
- Misses 668 682 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
clonker
left a comment
There was a problem hiding this comment.
Thanks for the PR. I checked it against main on random flux networks and the results are identical, so it seems change is correct. The speedup is limited to small networks though:
- about 4–5x at 100 states,
- roughly break-even at 10^4 states, and
- 15–40% slower on larger ones (200×200 grid, random networks with 2·10^5–5·10^5 edges).
Since it also keeps the old bisection as a second code path, I'd rather keep the simpler implementation unless you have an idea how to get a nice implementation that still looks like an algorithm without regressions and actual speedup.
Otherwise I'd close this one.
TL;DR
ReactiveFlux.pathwaysfor dominant-path decomposition.python3 -m pytest tests/markov/tools/flux/test_reactive_flux.py tests/markov/test_reactive_flux.py -q --tb=short— 57 passed.What & Why
The bottleneck search rebuilt sparse graphs and repeated reachability searches for different edge cutoffs.
Now it adds edges in the existing sorted order and keeps the nodes already reached.
Duplicate or nonpositive edges keep the existing search; unchanged edge ordering preserves tied-path choices.
Capacity reads reuse DOK storage, and one helper handles singleton endpoint checks.
Numeric endpoint checks use comparisons instead of sorting arrays.
Validation
Times below are per call, measured on one isolated CPU core with one numerical-library thread.
The grid uses 100 states, nearest-neighbor transitions, and a 50% flux target.
The smaller case comes from the existing reactive-flux tests.
Grid rows separate five tied-weight samples from four varied-weight samples already measured.
Before and after columns show median times; percentage changes use the median new/old ratio for each situation.
The combined workload also checks sparse formats, multiple endpoints, tied edges, zero flux, and iteration limits.
Its three runs give these statistics:
The control does not reach the optimized search; its measured difference is within the 5% noise band.
Samples contain 50 calls for the five-state case, 20,000 for zero flux, and 2,000 for invalid endpoints.
The table divides these times by the call count.
To reproduce the tied-grid situation after installing each revision, use Python's standard benchmark command:
The measurements above include fresh grid inputs with tied and varied edge weights, so this command reproduces one situation.
Why this is safe and easy to maintain
The change stays within five existing helpers in one module and shares endpoint membership checks.
Paths, capacities, warnings, exceptions, and input matrices remain unchanged in the checked cases.
Existing reactive-flux tests cover path ordering, capacities, major flux, and dense and sparse inputs.
Repository checklist
AUTHORS.AI assistance
This PR was prepared with AI assistance from Aiden. Candidates were tracked with Weco Observe.
Weco share link: https://dashboard.weco.ai/share/Y_bF9N3rsRnEcG_y3ARNiEBEYjk5YCpk