Skip to content

Add experimental A* and CABS search - #256

Open
zayenz wants to merge 120 commits into
mainfrom
feature/open-search
Open

zayenz wants to merge 120 commits into
mainfrom
feature/open-search

Conversation

@zayenz

@zayenz zayenz commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Add experimental A* and complete anytime beam search (CABS) for ordinary Gecode Space subclasses.

Guidance (an optimistic objective bound, an optional rank, and optional CABS dominance) is passed through Search::Options::guidance, so AStar<T>(s,o) and CABS<T>(s,o) have the same shape as BAB<T> and run directly with Script::run. The driver forwards Options::guidance(). CABS limits are Search::Options::max_width and frontier_limit. Like BAB, next() returns improving solutions as they are found, so A*'s first solution need not be optimal; exhausting the search proves the last one optimal.

Both engines support parallel search (Options::threads), dynamic worker control, and PBS portfolios with BAB. Open nodes, layers and beams use Gecode's Support containers; the shared pieces (node order, incumbent, A* queue, CABS beam) are in gecode/search/heuristic.hh, and parallel A* and CABS are small subclasses of Par::Frontier.

Other changes:

  • Sequential PBS no longer ignores a stop after a finished slice, and an asset that stops by itself (CABS at a limit) is removed instead of stalling the portfolio.
  • fifteen-puzzle gains -search astar|cabs; tsptw is a new driver-based example with two inline instances and a CABS dominance check.
  • Makefile.dep is updated for open lists and heuristic search (this replaces Update generated dependencies for open lists and heuristic search #261).

Enable with GECODE_ENABLE_EXPERIMENTAL=ON or --enable-experimental; the preview is disabled by default and its APIs may change.

Testing:

  • macOS arm64, CMake Release: -tag standard 6776/6777 passed. The failure, FlatZinc::on_restart::last_val_float, fails identically on current main.
  • macOS, ASan+UBSan Debug: -tag check 536/536 with one test thread, no sanitizer reports; heuristic and portfolio tests 20 iterations clean; examples clean with 1 and 4 threads. With -threads 0 a FlatZinc test overflows a test-runner thread's stack under ASan (unrelated code).
  • Experimental OFF: -tag check 533/533. Autoconf with --enable-experimental: build and make check 538/538.
  • Linux (GCC 15, RelWithDebInfo): -tag check 539/539. Valgrind on the heuristic, worker-control and portfolio tests: 14/14 passed; the only report is the known 78-byte leak from static test registration in test/int/extensional.cpp.

🤖 Generated with Claude Code

@zayenz zayenz changed the title Add experimental heuristic search for Gecode 6.5 [Experimental work in progress] Add experimental heuristic search for Gecode 6.5 Oct 13, 2026
@zayenz
zayenz force-pushed the feature/open-search branch 5 times, most recently from 10fad23 to 4b24088 Compare October 14, 2026 12:11
@zayenz
zayenz force-pushed the feature/open-search branch from 4b24088 to 489e4c2 Compare October 15, 2026 12:49
@zayenz
zayenz force-pushed the feature/open-search branch 5 times, most recently from b599534 to bfe3f2f Compare October 15, 2026 15:10
@zayenz zayenz changed the title [Experimental work in progress] Add experimental heuristic search for Gecode 6.5 Add experimental A* and CABS search for Gecode 6.5 Oct 18, 2026
@zayenz
zayenz marked this pull request as ready for review October 20, 2026 06:50
@zayenz
zayenz force-pushed the feature/open-search branch 2 times, most recently from 5c37b18 to 2e3068c Compare October 20, 2026 20:33
@zayenz
zayenz force-pushed the feature/open-cp branch 2 times, most recently from 0e679a7 to 5fb98a6 Compare October 21, 2026 08:11
@zayenz
zayenz force-pushed the feature/open-search branch 4 times, most recently from a03e61d to ace7c7f Compare October 21, 2026 12:02
@zayenz
zayenz force-pushed the feature/open-search branch 2 times, most recently from 7c04635 to 8d491da Compare October 21, 2026 19:25
zayenz added 23 commits October 26, 2026 18:56
Allow models to group dominance comparisons with an optional cached key. Keep the predicate authoritative under collisions and enable the key in the TSPTW transition example.

Retain parallel worker leases through admission and cleanup so exceptions cannot expose unfinished work.
Reuse incumbent copies and process failed or bound-pruned alternatives locally to reduce coordinator traffic. Check ordinary stops after at most 32 such alternatives and worker-count requests after each alternative.

Preserve stop polling while rejecting queued nodes, with focused stop and resume coverage for both pruning paths.
Track candidate positions as the heap moves, so keyed dominance replacement no longer scans the beam. Share heap maintenance between sequential and parallel CABS while leaving ranking and dominance decisions in the engines.

Validated with the existing search checks in Release and ASan/UBSan builds, temporary heap mutation probes, independent review, and paired benchmarks.
Submit up to eight successful siblings per frontier lock while preserving original-choice continuation and active leases through disposal. Keep single-child admission for A* and quota-limited CABS.

Validated with Release and ASan/UBSan search checks, temporary stop/pause/exception probes, independent review, paired measurements, and separate contention profiles.
Keep dominance selection, representative replacement, width eviction and discarded-bound tracking in the beam component. Leave guidance evaluation, frontier quotas and synchronization with the engines.

Give parallel runners ownership of their expansion state and bounded batch work, with shared reporting, selection and retirement coordinated by the frontier. Preserve incumbent-cache reuse and the model-cleanup barrier before returning from search.

Move resumable choice expansion into common search support for both sequential and parallel engines.
@zayenz
zayenz force-pushed the feature/open-search branch from bbf762e to 11e7c25 Compare October 26, 2026 18:40
Base automatically changed from feature/open-cp to main October 27, 2026 11:46
zayenz and others added 5 commits October 27, 2026 21:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AStar and CABS take their guidance from Search::Options::guidance and
the CABS limits from max_width and frontier_limit, so they have the
same constructor as BAB and run through Script::run; the driver passes
Options::guidance on. Dominance moves into HeuristicGuidance. This
removes CABSOptions, AStarOrder and its overloads, the second factory,
the engine configuration structs, and the per-engine exceptions.

Brancher::prepare is removed. Its only user was the TSPTW transition
brancher; branchers create new list positions in commit instead, as
the open-list brancher does.

Open nodes, layers and beams use Support::DynamicStack, DynamicArray
and DynamicQueue with explicitly owned spaces. Node order, incumbent,
A* queue and CABS beam are shared in search/heuristic.hh; the beam
keeps entries in fixed slots chained by dominance key. Par::Frontier
handles workers, locking and the incumbent; parallel A* and CABS are
small subclasses. Workers are woken when a disabled worker retires the
last lease, and reset clears a stored worker error.

TSPTW becomes a small driver-based model with two inline instances and
a dominance check for CABS; its readers, data and validation scripts
are removed. The heuristic tests check optimality on random trees.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CABS asset that reaches its width or node limit stops without the
portfolio stop object. Sequential PBS took this for a user stop and
kept returning without running the other assets. PortfolioStop now
records user stops; an asset that stops by itself is removed, and the
portfolio reports that it stopped once all assets are done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add rules for the new sources and examples, add the open-list and
heuristic search headers to existing rules, and drop deleted headers.
Other dependencies are left unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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