Skip to content

Rename the meta-search hooks to hub and spoke - #282

Draft
zayenz wants to merge 14 commits into
feature/comparisonfrom
feature/rename-master-slave-terms
Draft

zayenz wants to merge 14 commits into
feature/comparisonfrom
feature/rename-master-slave-terms

Conversation

@zayenz

@zayenz zayenz commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Gecode 7 renames the meta-search hooks Space::master() and Space::slave() to Space::hub() and Space::spoke(). Both RBS and PBS call them at the same points as before and keep the same default behavior.

I kept the rename in its own PR ahead of #283 so reviewers can look at the name change separately from the protocol changes. #283 changes the hook signatures again and removes MetaInfo, at which point the deleted declarations and compile-fail tests added here go away because old overrides fail to compile on their own.

Most of the diff is the mechanical rename, with a few supporting changes around it:

  • Space declares the old master() and slave() hooks as deleted virtual functions. Without that, a Gecode 6 model that wrote bool slave(const MetaInfo&) without override would still compile and silently never be called, turning LNS into plain restarts. With deleted declarations, both old hooks fail at compile time. Two CTest compile-fail cases verify this (one per hook) and run in the Ninja CI job.
  • Inside PBS, the per-asset engine wrappers were briefly caught in the rename and are now called assets (Asset, n_assets, asset_stop), matching the public PBS vocabulary. Hub and spoke refer strictly to spaces.
  • job-shop now names its cloned spaces root and model, because neither plays a meta-search role.
  • The Doxygen comments on hub() and spoke() spell out when RBS and PBS call each hook and which space each runs on, and docs/gecode-7-migration.md summarizes what downstream code needs to update.
  • New MetaDispatch tests check which hook RBS and PBS invoke, how many times, and for which restart reason or asset.

Tested locally: Search passes 25,848 of 25,848 tests.

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.

  1. Rank solutions with Space::compare in best-solution search #242 Rank solutions with Space::compare
  2. Rename the meta-search hooks to hub and spoke #282 Rename the meta-search hooks to hub and spoke ← this PR
  3. Give meta search hub and spoke contexts and report why search ended #283 Hub and spoke contexts and end reasons
  4. Add extensible random generators with reproducible stream splitting #241 Splittable random generators
  5. Gecode 7: CMake-only C++23 build baseline #284 Gecode 7: build baseline
  6. Gecode 7: format the sources with LLVM 22 #285 Gecode 7: reformat
  7. Gecode 7: normalized API names, LT constants and Clang checks #286 Gecode 7: API names, LT constants, checks
  8. Gecode 7: post nothing for empty arrays #287 Gecode 7: empty arrays
  9. Gecode 7: pass large parameters by const reference #288 Gecode 7: const& parameters
  10. Gecode 7: state and assert the heap size contract #289 Gecode 7: heap contract
  11. Gecode 7: trivially copyable handles and defaulted special members #290 Gecode 7: modern classes
  12. Gecode 7: native float interval instead of Boost #291 Gecode 7: native float interval
  13. Gecode 7: bug fixes and Doxygen warnings #292 Gecode 7: bug fixes and Doxygen
  14. Gecode 7: scoped enums and descriptive constant names #293 Gecode 7: scoped enums
  15. Gecode 7: clang-tidy sweep #274 Gecode 7: clang-tidy sweep

Gecode 7 replaces the master() and slave() Space hooks with hub() and
spoke() for both restart-based and portfolio-based search. Internal PBS
runnables become spokes, their back-pointer the portfolio, and the wrapped
engine the engine.
The MetaDispatch tests check which hook RBS and PBS call, how often, and for
which restart reason or asset, with each hook overridden alone and together.
They also check that RBS honours the hub() restart decision and the
spoke() completeness result, that no-goods reach the hub, that stopped
engines delete every clone, and that BAB incumbents reach the hub and
spoke spaces through RBS, PBS, and PBS over RBS. The Sol model gains a
spoke() override.
Configuring with tests compiles a space overriding hub() and spoke(),
and then requires spaces overriding master() or slave() to fail, one hook
at a time. The pass fixture is also built into the test library. The new
hub-spoke example shows both overrides and the Gecode 6 names they
replace.
The Gecode 7 migration notes give the hook rename, its unchanged timing and
defaults, and the risk of a renamed hook declared without override. The
terminology contract records the role definitions, both engine lifecycles,
and the names considered and rejected. The README links the migration notes,
and the changelog records the breaking change.
Space now declares master() and slave() as deleted virtual functions. A
non-deleted function cannot override a deleted one, so a Gecode 6
override fails to compile even without override, where it used to
compile and never be called.

The configure-time try_compile checks become two CTest cases that build
EXCLUDE_FROM_ALL object libraries: one overrides hub() and spoke() and
must build, the other overrides slave() without override and master()
with it, and must fail. The failing case requires the passing one, so a
broken setup cannot make it pass. The pass fixture leaves the test
library.
The notes now start with what a port needs: rename the overrides, keep
their signatures, and rely on the compiler to find old ones. Short
semantics follow, including that a spoke is a disposable clone rather
than a long-lived peer, and pointers to the crossword, photo, and qcp
examples. The terminology contract shrinks to the wheel picture in the
notes.

The hub-spoke example goes: its overrides only called the defaults, and
with several assets it printed unassigned solutions.
The probing phase clones its root space for each DFS probe, and the
dichotomic phase clones the model for each bounded search before giving
it to RBS. Neither space plays a meta-search role, so the rename to hub
misdescribed them.
Hub and spoke name Spaces, but the rename also called the per-asset
engine wrappers in sequential and parallel PBS spokes. They now use the
existing public PBS word: Asset, assets, n_assets, and asset_stop, and
make_rbs_engine takes its leaf engine as engine. Space variables keep
the names hub and spoke.

The sequential Asset::init declaration and definition use the same
parameter names, and the stat members describe what they hold.
The hub() and spoke() documentation now matches the engines. RBS also
calls spoke() when search starts and ignores that result. The default
RBS hub() constrains with the last solution, if any, posts the no-goods,
and returns true. The hub's result counts only after a solution, and
returning false then skips spoke(). The default PBS hub() removes all
branchers, so spoke() must post each asset's branching. The RBS and PBS
class comments point to these functions.
PBS spoke-only models now post their branching in spoke(), as the
default hub() requires, and every PBS dispatch case checks that its
solution is assigned. A new case keeps that branching out and expects an
unassigned solution, showing that the default hub() removes the model's
branchers. Another case makes the first RBS spoke reach the cutoff and
checks the exact hub() and spoke() calls of a limit restart. A parallel
case records that PBS runs only as many assets as it has threads.

The rename had added a no-op spoke() override to an existing test space;
it is gone. The new enums use PascalCase constants, and the SEB
portfolio test names its thread counts and options for the portfolio
and the assets.
The single fail fixture overrode slave() without override and master()
with it. The master() override fails even if Space no longer deletes the
old hooks, since override then names no virtual function, so the test
could never catch a lost deletion.

Split it into hub-spoke-api-fail-master and hub-spoke-api-fail-slave.
Each is the pass fixture with one hook replaced by an old override
without override. The tests now require the deleted-function diagnostic
of Clang or GCC instead of any failure; MSVC words it differently, so
there they only require the build to fail. Both still require the pass
test.
The Ninja job's Check step selected only build-gecode-test and test, so the
compile tests for the meta-search hooks never ran in CI.
If the hub fails after hub(), RBS ends. The last PBS asset searches the hub
itself, so its spoke is the hub or a clone of it, not always a clone.
Drop the origin of the names and the comparison with other solvers, and
say which space each hook runs on.

This branch has not been deployed

No deployments
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