Engines optimized guesses at the benchmark cost: Opus55 re-implemented salvage credit, Qwen used plate area per part area, Gpt6Astra ignored salvage. NestJobCost moves StockLadder's EstimateNetArea into a public home (net sheet area, unplaced-part penalty, whole-result Evaluate) and the benchmark and StockLadder now call it. Scores are unchanged: tests pin it against a frozen copy of the old computation and real benchmark runs. Bounds still include marks, as before, so scores do not move. Co-Authored-By: Codex <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.7 KiB
C#
43 lines
1.7 KiB
C#
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Engine.Jobs.Adapters;
|
|
|
|
namespace OpenNest.Engine.Tests.Jobs;
|
|
|
|
// Frozen pre-PR2 computation: keep independent of NestJobCost to detect scoring drift.
|
|
internal static class LegacyNestJobCost
|
|
{
|
|
public static double EstimateNetArea(NestJob job, NestJobPlateResult sheet)
|
|
{
|
|
var area = sheet.Stock.Size.Width * sheet.Stock.Size.Length;
|
|
var minimum = job.Options.MinimumSalvageDimension;
|
|
if (job.Options.SalvageRate == 0 || minimum <= 0 || sheet.Placements.Count == 0)
|
|
return area;
|
|
var work = DrawingJobMapper.CreatePlate(sheet.Stock).WorkArea();
|
|
var parts = job.Parts.ToDictionary(p => p.Id);
|
|
var boxes = sheet
|
|
.Placements.Select(p =>
|
|
{
|
|
var part = new Part(DrawingJobMapper.CreateDrawing(parts[p.PartId]));
|
|
part.Rotate(p.Rotation);
|
|
part.Location = new OpenNest.Geometry.Vector(p.X, p.Y);
|
|
part.UpdateBounds();
|
|
return part.BoundingBox;
|
|
})
|
|
.ToList();
|
|
var gap = sheet.Stock.PartSpacing;
|
|
var candidates = new[]
|
|
{
|
|
(work.Length, boxes.Min(b => b.Bottom) - work.Bottom - gap),
|
|
(work.Length, work.Top - boxes.Max(b => b.Top) - gap),
|
|
(boxes.Min(b => b.Left) - work.Left - gap, work.Width),
|
|
(work.Right - boxes.Max(b => b.Right) - gap, work.Width),
|
|
};
|
|
var salvage = candidates
|
|
.Where(c => c.Item1 >= minimum && c.Item2 >= minimum)
|
|
.Select(c => c.Item1 * c.Item2)
|
|
.DefaultIfEmpty(0)
|
|
.Max();
|
|
return area - job.Options.SalvageRate * salvage;
|
|
}
|
|
}
|