Skip to content

Allow picking the best of several orders for GreedyColoringAlgorithm#265

Merged
gdalle merged 10 commits intomainfrom
gd/ordercomp
Oct 14, 2025
Merged

Allow picking the best of several orders for GreedyColoringAlgorithm#265
gdalle merged 10 commits intomainfrom
gd/ordercomp

Conversation

@gdalle
Copy link
Copy Markdown
Member

@gdalle gdalle commented Oct 10, 2025

In the context of DI, it's a bit annoying to compare several orders before picking the best one, since the best order is matrix-dependent.
This PR allows passing a tuple of orders to GreedyColoringAlgorithm, which are then compared for every matrix and the best one is picked. I use a tuple to preserve type-stability and to ensure efficiency in the base case N=1.

Todo:

@gdalle
Copy link
Copy Markdown
Member Author

gdalle commented Oct 10, 2025

@SouthEndMusic does this API do what you'd like it to do?

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7efc6bc) to head (a1b5b5e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #265   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         1939      1955   +16     
=========================================
+ Hits          1939      1955   +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amontoison
Copy link
Copy Markdown
Collaborator

I like the idea! We could reuse the buffers if we only change the ordering. But it can be done later.

@gdalle gdalle marked this pull request as ready for review October 13, 2025 09:46
@gdalle gdalle requested a review from amontoison October 13, 2025 13:11
@gdalle
Copy link
Copy Markdown
Member Author

gdalle commented Oct 13, 2025

@amontoison all the tests are now passing, I think this one is easy to ship

@amontoison
Copy link
Copy Markdown
Collaborator

Ok I will review do my best to review it tonight !

Copy link
Copy Markdown
Collaborator

@amontoison amontoison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just have a suggestion to not call remap_colors a second time for nothing.
It is not expensive but can be probably easily avoided.

@gdalle gdalle merged commit b3cf23d into main Oct 14, 2025
9 checks passed
@gdalle gdalle deleted the gd/ordercomp branch October 14, 2025 05:17
amontoison pushed a commit that referenced this pull request Oct 22, 2025
…265)

* Allow picking the best of several orders for GreedyColoringAlgorithm

* Fix type params

* Tuple

* Better tests

* Better test

* Fix foc

* Fix type inference inside closure

* Fix seed

* Test on 1.11

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants