Repository navigation
Conversation
zayenz
commented
Oct 4, 2026
Member
Author
There was a problem hiding this comment.
- The one-argument
CarSequencing::compare()hid the inherited Gist display overload. Addedusing Script::compareto restore the two-argument call. - Parallel PBS broadcast a solution before handling a stored worker failure. That could call into a failed asset and replace the original exception. The failure guard now runs before solution processing.
zayenz
force-pushed
the
feature/comparison
branch
from
October 8, 2026 15:15
fdd5080 to
08b56e6
Compare
zayenz
force-pushed
the
feature/comparison
branch
from
November 3, 2026 12:04
65e455e to
5aece80
Compare
zayenz
force-pushed
the
feature/comparison
branch
2 times, most recently
from
November 3, 2026 16:17
9c72d67 to
2fdfdc9
Compare
zayenz
force-pushed
the
feature/comparison
branch
2 times, most recently
from
November 15, 2026 08:02
d7c26e2 to
b767864
Compare
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
Zdev-Change-Id: Z4e4e39fd1665c0addf3e5726ab9bfb5ef3c6d49a7ca7b636d665bb672dccf5c5
Zdev-Change-Id: Z779d79cd0461e169a13d69dddf214ef27fe9499b996e28b9f44c29b66ff7cb97
Parallel BAB now discards solutions that compare as equivalent, so BAB tests can no longer enumerate all solutions of a model without an objective. The restart and worker-control pause tests now give BAB a lexicographic objective and check for improving solutions ending with the best one. The restart test model tightens its bound on the last solution when it has an objective. The comparison tests counted spaces and posted constraints in static counters shared by tests that the harness runs concurrently. Give each test its own atomic counter instead.
A* and CABS chose between solutions by their guidance bound, unlike the other best-solution engines and the portfolios they can run in. They now replace the incumbent only when Space::compare reports SC_BETTER, both for their own solutions and for external incumbents, and report incomparable and missing comparisons like BAB. Parallel workers pass solutions that tie with the incumbent bound on to comparison. The bound still orders and prunes open nodes.
Space::compare now says what compare returns, how it must agree with constrain, and what the default does, at about the length of the constrain documentation. Model-specific ranking stays with the MiniModel and FlatZinc classes. The BAB and PBS notes and the changelog entry drop the repeated and speculative parts.
Implementing Space::compare for an integer objective took four lines of value comparisons, against a single rel call in constrain. compare_int compares two values for a Sense, an optimization direction now shared by the kernel, MiniModel, FlatZinc, and the experimental heuristic guidance, which had its own MINIMIZE/MAXIMIZE enum.
FlatZincSpace::compare threw DynamicCastFailed for a satisfaction model, the same error as for incompatible objectives. A model without an objective does not support comparison, so throw SpaceNoComparison like the default Space::compare.
The example overrides constrain to keep later solutions apart from earlier ones, but had no compare, so parallel BAB threw SpaceNoComparison. Report a solution as better than another exactly when constrain would admit it. This is not an order and only keeps the example running until it is reworked.
Parallel BAB reports a stored worker failure before constrain() compares the new bound, and before a restart engine moves on from nogoods(). A bound weaker than the incumbent still drops the queued solutions it excludes. PBS reports a stored failure before broadcasting a solution to the remaining assets, which could otherwise replace the original exception. The tests drive the parallel BAB engine directly, so NoNGL is exported for shared-library builds.
A one-argument compare() hides Script's compare(const Space&, std::ostream&), which Gist calls, so car-sequencing and cartesian-heart bring it back into scope.
SpaceComparison becomes an enum class with Better, Equivalent, Worse and Incomparable, and Sense uses Minimize and Maximize, matching the Gecode 7 naming of scoped enums. Comparing solutions whose objectives differ in direction, float step or size now throws SpaceIncompatibleObjectives instead of DynamicCastFailed or ArgumentSizeMismatch. DynamicCastFailed remains for spaces of the wrong type. compare_float() and compare_lex() join compare_int(). The MiniModel float and lexicographic spaces and FlatZinc use them. Also declare each variable separately and clarify the FlatZinc float comparison documentation.
zayenz
force-pushed
the
feature/comparison
branch
from
November 19, 2026 18:10
b767864 to
e89a7a2
Compare
The changelog now says that an exception in a parallel portfolio asset, or from compare() in parallel BAB, is rethrown by next() instead of terminating the program. FlatZinc builds without float variables cannot reach the float branch of compare().
zayenz
force-pushed
the
feature/comparison
branch
from
November 19, 2026 18:21
e89a7a2 to
9359b1a
Compare
This was referenced Nov 20, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Best-solution engines regularly have to pick between two solutions without posting a constraint. Parallel BAB receives solutions from different workers, a portfolio receives them from different assets, and any engine can be handed an external incumbent through
constrain(). Until now, A* and CABS made that choice using their guidance bound, while the other engines had no read-only way to compare two solutions at all.This PR introduces
Space::compare(), a read-only comparison that classifies one solution against another asBetter,Equivalent,Worse, orIncomparable, and switches every best-solution engine to use it.Contract for models
Any space used for optimization now implements both
constrain()andcompare().constrain()keeps its existing role of posting the restriction that future solutions must improve on the incumbent;compare()decides which of two already-found solutions to keep, and must agree withconstrain(). The defaultSpace::compare()throwsSpaceNoComparison.To keep overrides short,
SpaceComparisonandGecode::Sense(Minimize,Maximize) are added as enum classes, along withcompare_int(),compare_float(), andcompare_lex(). With those helpers, a typicalcompare()override is one line, much likeconstrain(). Comparing objectives that differ in direction, float step, or size throwsSpaceIncompatibleObjectives(spaces of the wrong dynamic type still throwDynamicCastFailed).The MiniModel optimization spaces, FlatZinc,
car-sequencing, andcartesian-heartall implementcompare(). Float spaces compare the bound that their cuts actually use and ignore the step size, and a FlatZinc satisfaction model throwsSpaceNoComparisonrather thanDynamicCastFailed. The experimentalHeuristicGuidancenow usesGecode::Senseinstead of defining its own enum.One example needs a caveat:
cartesian-hearthas no real objective and usesconstrain()only to keep later solutions apart from earlier ones. Itscompare()temporarily reports a solution asBetterwheneverconstrain()would admit it. That is not a true order, and is only there to keep the example running until the example itself is reworked.How the engines use
compare()compare()when an external incumbent arrives throughconstrain().Better. BecauseEquivalentsolutions are discarded, parallel BAB no longer enumerates all solutions of a model without an objective. The RBS and worker-control tests relied on that behavior and now use a lexicographic objective to check strict improvement.Better, while their guidance bound continues to order and prune open nodes.Incomparablesolutions by throwingSearch::Incomparable.compare()throws inside a parallel engine, the exception reaches the caller throughnext()rather than terminating the process, after which the engine must be deleted. Any stored worker failure is reported before further comparisons run, so a later exception cannot mask the first one.Tests and verification
New tests cover the engines, portfolios, external incumbents, failure transport, FlatZinc, and the comparison helpers. Because the parallel BAB tests drive the engine directly,
NoNGLis now exported for shared-library builds. Test counters that previously lived instaticvariables and raced under the concurrent test harness are now per-test atomics. The final commit removes the.zdev/planning records.Tested on macOS:
check, Search, and FlatZinc pass in both the default and experimental builds, and thedoctarget builds.Stack
Merge in this order. #242 targets
main, and each later PR builds on the one before it so its diff shows only its own commits. The first four PRs are standalone search and random-number changes; #284 through #274 are the Gecode 7 changes split out of what used to be a single branch.