Skip to content

Provisional: non-mutating solution comparison for Gecode 7 (breaking changes) - #242

Draft
zayenz wants to merge 9 commits into
mainfrom
feature/comparison
Draft

Provisional: non-mutating solution comparison for Gecode 7 (breaking changes)#242
zayenz wants to merge 9 commits into
mainfrom
feature/comparison

Conversation

@zayenz

@zayenz zayenz commented Sep 10, 2026

Copy link
Copy Markdown
Member

Provisional draft — future breaking-change release only

This PR is a provisional design and implementation for Gecode 7, or another future release that explicitly permits breaking changes. It is not ready for merge and must not be included in Gecode 6.x or any compatibility-preserving release. The comparison contract, search policy for incomparability, and migration requirements remain subject to review and testing.

Adding Space::compare() changes the C++ ABI of Space. Optimization models with custom objectives must implement comparison as well as constrain(). Release version and ABI-number changes are intentionally left to release preparation.

Changes

  • Add a read-only, receiver-relative Space::compare() operation with better, equivalent, worse, and incomparable results. Models decide when two spaces contain enough objective information to compare; the spaces need not otherwise be fully assigned.
  • Implement comparison for the integer and floating-point optimization convenience classes and FlatZinc. Integer objectives compare assigned values. Floating-point objectives rank their documented interval endpoints independently of the improvement step, while requiring compatible directions and steps.
  • Use comparison for incumbent arbitration in sequential and parallel BAB, RBS, and portfolio search. constrain() remains responsible for pruning working spaces and is no longer used to rank independently produced solutions.
  • Preserve pending-result correctness for external incumbent updates and return comparison failures from parallel workers to the controlling caller after workers are quiescent.
  • Add focused coverage for equivalent and worse candidates, external bounds, float improvements smaller than the cut step, mixed PBS/RBS/BAB portfolios, comparison errors, reset/reuse, and satisfaction portfolios.

Policy requiring review

The current exact best-solution engines reject an incomparable incoming solution. This makes policy failures explicit while the interface and use cases are evaluated.

A possible future best-effort policy is that an incomparable incoming solution becomes the current best. The comparison interface already supports that policy, so testing it would not require another API change. Such a policy would not by itself guarantee completeness, Pareto maximality, or preservation of previously incomparable solutions. Pareto archives and diverse-solution search remain outside this PR.

Verification

Local verification on arm64 macOS with Apple Clang 21:

  • Threaded gecode-test build and the complete Search::PBS:: matrix.
  • Focused sequential and parallel BAB/RBS/PBS comparison, external-incumbent, nested-failure, reset/reuse, and float-objective checks.
  • Relevant FlatZinc comparison and search checks.
  • Existing parallel BAB stop/resume and recomputation coverage under bounded execution.
  • Fresh GECODE_ENABLE_THREAD=OFF build with applicable comparison and PBS checks.

The full combinatorial Search:: matrix was sampled under a time bound; all executed cases passed. Other platforms and configurations have not been verified locally. Passing these checks does not change the provisional draft status.

Mikael Zayenz Lagerkvist added 9 commits September 10, 2026 08:22
Zdev-Change-Id: Zd450758a16d392690607cf153a5160083ad5c3a5cd6812f461a16610075fc80a
…iness

Zdev-Change-Id: Z5c772894bb48c0852974820982b13020d663b002850618c6bcba63a53e9e4571
Zdev-Change-Id: Zd3bd5210f7a14908a3b4cf47a040ce93d4488f82ec178872c8b90824895e3f87
Zdev-Change-Id: Z1c007f6a8f418dab7835ce3c161f32811819842b08897f39166326aacd7afcb5
Zdev-Change-Id: Z87d7de4220478ed2e6d58d55f4648cde323acfbbb28ecb589c39215a802aeb03
Zdev-Change-Id: Z738bbca9dd306371480ab382cbd9492a52cd416d460e53b9512a5f83e57476d7
Zdev-Change-Id: Zc9f2540cb25a8b2bc131505b4314c6ea435ced462e808cb28c0b3f57b66f8f34
Arbitrate candidates and external incumbents with non-mutating comparison, invalidate superseded queued results, and deliver comparison failures safely through next().

Preserve restart support by clearing failure state during reset, with focused parallel BAB regressions.

Zdev-Change-Id: Z7926867238a6c0cfb64f226c42bf1df0d6994fedf653be929d33ef60ec652f92
Use non-mutating comparison for PBS incumbent arbitration and safely return collector or nested-asset failures after portfolio workers quiesce.

Add mixed portfolio regressions and document model-defined comparability, float ranking, migration, and the possible future best-effort incomparability policy.

Zdev-Change-Id: Ze012cd6e1d4ae7aebf1483d8aabd40f2204a99b09907e93c1a7e61d6dfc7b911
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.

1 participant