feat(engine): report best whole-job plans from Rectangles, Circles and Default

Desktop Auto Nest's "Best plan so far" strip now fills in for every built-in
whole-job engine except FlatBar, not only Irregular.

- Rectangles makes one sheet-by-sheet run, so it reports the finished job as
  its one plan, then replays its plate commits (token checked as before).
- Circles reports when a stock-preference run or a tail re-plan beats its
  best result so far.
- Default scores each candidate plan as it ranks results (valid, fewest
  unplaced, lowest cost, candidate order) and reports it only when it beats
  every plan already shown, so a later candidate never shows a worse plan.
  The chosen result is always the last plan reported.
- Shared ReportPlan/SameLayout helpers on CandidateProgress; Irregular uses
  them too. Reporting never changes the search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-10-18 23:56:38 -04:00
1 parent cd2bea054b
commit 00acaeaaf1
11 files changed
+275 -13

No files matched your search

@@ -18,7 +18,8 @@ namespace OpenNest.Engine.NestingEngines.Rectangles;
///
/// Sheet by sheet (<see cref="SheetByStock"/>), each available stock is packed under several
/// free-space scoring rules and two pick modes (best-fitting box anywhere, or largest type first),
/// and the candidate with the lowest estimated whole-job cost wins.
/// and the candidate with the lowest estimated whole-job cost wins. The finished job is reported as
/// its one whole-job plan (<see cref="NestJobStage.PlanImproved"/>) before its plate commits.
/// Deterministic: no clocks or randomness; the only stop besides completion is the host token.
/// </summary>
public sealed class RectanglesNestingEngine : INestingEngine
@@ -52,7 +53,12 @@ public sealed class RectanglesNestingEngine : INestingEngine
remaining[t.Index] = 0;
var demand = types.Select(t => new SheetDemand(t.Index, t.Id, t.Priority, t.MaterialArea)).ToArray();
return SheetByStock.Run(job, demand, remaining, Pack, progress, token, BatchSelected);
// One run makes one whole-job plan: report it, then its commits, as the other engines do.
var forward = progress == null ? null : new CandidateProgress(progress);
var result = SheetByStock.Run(job, demand, remaining, Pack, forward, token, BatchSelected);
CandidateProgress.ReportPlan(result, progress);
CandidateProgress.ReportCommits(result, progress, token);
return result;
IEnumerable<SheetLayout> Pack(NestPlateStock stock, IReadOnlyList<int> left)
{