fix(opus55): honor part priority and use host scoring and tolerances

Opus55 ignored NestJobPart.Priority, so the shared contract test (lower
number wins scarce stock) failed; lower-number priority now precedes its
placement score. SheetEconomics is replaced by the host's NestJobCost so
it optimizes exactly what the benchmark scores, and its footprint margin
comes from NestTolerances.SafeClearanceMargin plus four Clipper grid
units - the same 0.003 total as before, which keeps its contact points.

Synthetic benchmark (5 jobs, salvage 0.5): all valid, cost unchanged at
5452.79, time 611 -> 456 ms.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aj
2026-09-25 09:29:27 -04:00
co-authored by Codex Claude Opus 5.5
parent d0c6af783b
commit 0308a862b8
8 changed files with 77 additions and 335 deletions
+6 -2
View File
@@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using Clipper2Lib;
using OpenNest.Engine.Jobs;
namespace OpenNest.Engine.Opus55;
@@ -15,7 +16,7 @@ namespace OpenNest.Engine.Opus55;
internal sealed class NoFitCache
{
/// <summary>Clipper decimal precision; 1e-4 job units is far below any margin we keep.</summary>
public const int Precision = 4;
public const int Precision = NestTolerances.ClipperPrecision;
private readonly double halfClearance;
private readonly ConcurrentDictionary<(int, int), PathD> footprints = new();
@@ -43,7 +44,10 @@ internal sealed class NoFitCache
// footprint is a superset of "every point within the clearance of the outline".
var inflated = Clipper.InflatePaths(
new PathsD { o.Outline },
halfClearance + o.Tolerance,
// Four additional grid units cover this engine's repeated footprint/NFP
// Boolean operations. Keep its established contact points and packing quality.
halfClearance + NestTolerances.SafeClearanceMargin(o.Tolerance) / 2
+ 4 * System.Math.Pow(10, -Precision),
JoinType.Miter,
EndType.Polygon,
2.0,