Skip to content

Fix tuple BnB metric ordering propagation#39

Merged
evanlinjin merged 2 commits intobitcoindevkit:masterfrom
EliteCoder18:master
Feb 14, 2026
Merged

Fix tuple BnB metric ordering propagation#39
evanlinjin merged 2 commits intobitcoindevkit:masterfrom
EliteCoder18:master

Conversation

@EliteCoder18
Copy link
Contributor

Tuple BnB metrics currently propagates requires_ordering_by_descending_value_pwu() using all().

If one metric requires descending order and another does not, order is skipped, thus violating the requirement of the order-dependent metrics.

What this PR does:

  1. Adds a test (bnb_tuple_metric_respects_ordering_requirement) demonstrating the issue.

  2. The fix involves changing the ordering propagation to use any() instead of all().

The test is added in a separate commit to clearly demonstrate the failing behavior before the fix.

Copy link
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Before ACK/Merge, I propose the following changes:

1. Simplify tests

No need to actually run .bnb_solutions. We just need to make sure ((metric_a, 1.0), (metric_b, 1.0)).requires_ordering_by_descending_value_pwu() returns the correct value.

  • score and bound implementations of OrderSensitive and NoOrderMetric can just return Some(Ord32(0.0)).
  • Have the following test cases:
    • Both metrics require ordering
    • One metric requires ordering
    • No metric requires ordering

2. Don't have a separate clippy/lint commit

Just merge the commits.

@EliteCoder18
Copy link
Contributor Author

Thanks for the suggestions. I've made the tests easier by only covering the three ordering situations and getting rid of the lint commit.

Please let me know if anything else needs to be changed

Copy link
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

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

Don't forget to do cargo fmt and cargo clippy otherwise CI will fail.

Copy link
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

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

ACK 66e82d4

@evanlinjin evanlinjin merged commit a077ec9 into bitcoindevkit:master Feb 14, 2026
5 checks passed
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