Speed up list_frontdoor_adjustment with a bool-array find oracle - #181
Speed up list_frontdoor_adjustment with a bool-array find oracle#181SimonAB wants to merge 1 commit into
Conversation
Keep ConstraintIterator (O(n(n+m)) delay) but use a Wienöbst/mwien-style bool-array Algorithm-2 find for listing, which was ~2× faster than the gensearch find under heavy enumeration in local benchmarks. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR optimizes list_frontdoor_adjustment enumeration performance by swapping the listing feasibility oracle from the existing gensearch-based find_frontdoor_adjustment to a bool-array (Algorithm 2) implementation, while keeping the same ConstraintIterator enumeration approach and public find_* APIs unchanged.
Changes:
- Replace deep copies with shallow
copyinConstraintIteratoriteration to reduce overhead. - Introduce a bool-array frontdoor “find oracle” and use it for
list_frontdoor_adjustment. - Bump package version to
0.19.5.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/gensearch.jl |
Adds a bool-array frontdoor oracle and wires it into list_frontdoor_adjustment; reduces iterator copying overhead. |
Project.toml |
Version bump to 0.19.5. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| function list_frontdoor_adjustment(g, X, Y, I = Set{eltype(g)}(), R = setdiff(Set(vertices(g)), X, Y)) | ||
| X, Y, I, R = toset.((X, Y, I, R)) | ||
| return ConstraintIterator(g, X, Y, I, R, find_frontdoor_adjustment) | ||
| return ConstraintIterator(g, X, Y, I, R, _find_frontdoor_adjustment_bool) | ||
| end |
|
Thank you for the PR, I think I have to be careful here. Let's move in smaller steps, otherwise, as LLMs are involved I'll not be able to keep up reviewing. Sorry for not signaling this better yesterday. |
Summary
ConstraintIteratorforlist_frontdoor_adjustment(same O(n(n+m))-delay enumeration as before; Wienöbst et al. 2024, Corollary 1).find_frontdoor_adjustment.find_frontdoor_adjustment/find_min_frontdoor_adjustmentare unchanged.Motivation
@mwien correctly noted on #180 that the package already implements the delay enumerator. Local microbenchmarks (parity-checked) found that swapping only the find oracle for listing gives about a 2× wall-clock improvement under heavy enumeration, with only a modest allocation drop.
Test plan
test/gensearch.jlfrontdoor list fixtures (g1/g2)Made with Cursor