Repository navigation
Fix how restart-based and portfolio search end and stop - #280
Merged
Merged
Conversation
When the slave search hit its cutoff, RBS restarted by calling the master configuration function. If the master then failed, for example because the posted no-goods proved that no better solution exists, RBS returned no solution but left the stopped slave engine in place, so stopped() kept returning true. FlatZinc then printed an unknown result instead of the proof, and the statistics counted the last slave search twice. Dispose of the failed master and reset the slave engine, as after a master that fails following a solution. RBS reports a stop only while it still has a master, and next() and constrain() do nothing once the master has failed.
The constructors of DFS, BAB, and LDS count a root space that fails at status() as a failure, but reset() checked the status before resetting the statistics, so the failure and the root's propagations were lost. RBS resets its engine for every restart, so when the slave space of large neighbourhood search failed right away, neither a FailStop or NodeStop nor the failure slice of a portfolio advanced: RBS with LNS under FailStop(5000) ran 960k episodes with no failure counted. Reset the statistics first and count a failed root, in the sequential and parallel engines. A null space, which RBS passes after its master has failed, is not counted. RBS also relied on the slave engine to check the stop object of the meta engine. A parallel engine without work never checks it, so with a slave failing at the root, restarts continued forever whatever the stop object said. RBS now checks that stop object itself before each restart after an incomplete slave search.
Sequential DFS and BAB checked the stop object before checking whether the search tree was exhausted. When the last failure of the tree exceeded a failure limit, the engine reported a stop although nothing was left to explore. With an empty path there are no no-goods, so RBS restarted from the same master and repeated the same slave search forever. RBS with no-goods on an unsatisfiable pigeonhole model did not terminate for most constant cutoffs between 5 and 17: the search got stuck once the remaining subtree had exactly one failure more than the cutoff. Return as exhausted before checking the stop object, as LDS already does. The parallel engines check the stop object only when they have work, so they were not affected.
A portfolio created from engine builders, PBS(s, sebs, o), wrapped the stop object of each builder in its portfolio stop and never looked at o.stop. A portfolio with a 200 ms TimeStop ran for about 3 seconds and then reported that it had not been stopped. The portfolio stop of each asset now checks the stop object of the portfolio as well as that of the builder, with the statistics of the asset, as the homogeneous portfolio already does for its stop object. New overloads of Seq::pbsstop and Par::pbsstop pass both stop objects; the existing ones are kept.
A homogeneous portfolio of restart-based engines, PBS<T,RBS>, passed the same options to every asset, so every RBS engine took ownership of the cutoff in o.cutoff. The cutoff was deleted once per asset: a portfolio of two RBS assets crashed when it was deleted, and parallel assets also advanced the same cutoff concurrently. A cutoff cannot be copied without adding a virtual function, so each asset that takes ownership of the cutoff now gets a PbsCutoff, which draws the next value from the shared cutoff under a mutex. The shared cutoff is deleted with the last asset cutoff, and only if the portfolio was built: if building throws, the caller keeps the cutoff, as with RBS. Nested portfolios of restart-based engines are handled the same way; other engines do not take the cutoff and are left unchanged. RBS also deleted the cutoff before creating the engine for a failed root, so a failing allocation there would leave the caller with a deleted cutoff. Delete it once that engine exists.
When LDS reaches its discrepancy limit with parts of the tree left unexplored, next() returns nullptr and stopped() returns false, exactly as after exhausting the tree. A caller cannot tell an incomplete search from a proof. Reporting the limit through stopped() would change how RBS and PBS treat an LDS asset: RBS would restart it as if a cutoff had been reached, and PBS would stop the whole portfolio. The 6.x engine interface has no other way to report it outside experimental builds, so document the behaviour for LDS, lds(), and the discrepancy limit.
zayenz
force-pushed
the
fix/meta-search-engine-ends
branch
from
November 15, 2026 08:40
23e17b8 to
8eff1d5
Compare
This was referenced Nov 15, 2026
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.
These are bug fixes in how search engines end and stop, intended for 6.6.0. Each fix is a separate commit with a regression test that fails without it. No public API is removed or changed. The only additions are two exported
pbsstopoverloads.Fixes
stopped(). Each restart then added no new no-goods and repeated the same search. An exhausted search now finishes before the stop object is checked.stopped(). FlatZinc then printed an unknown result instead of the proof.Each fix has a changelog entry.
Not included
The
photo -restart constant -restart-scale 5 -nogoods true -seed 4segfault does not reproduce on currentmain; cc578a0 fixed it. 150 runs under AddressSanitizer and UndefinedBehaviorSanitizer were clean, also with the #277 guard bypassed.Testing
Release build on macOS:
-test Search-tag checkFault-injection (
gecode-fault-test) and AddressSanitizer plus UndefinedBehaviorSanitizer runs (-test Search,-tag check) on Linux with GCC are in progress. I'll add the results here.