Files
OpenNest/OpenNest.Tests/Engine/GroupedNestingTests.cs
T
ajandClaude Opus 5.5 91089820ee feat(engine): group like parts in Irregular's grouped variants
After its six variants and tail re-plan, Irregular decodes the job again
with each type of three or more copies packed as one group, in a searched
order, holding back up to four copies per group that would start a ragged
row and filling them into the gaps afterward. When everything fits, the
best candidates are re-packed in a strip ending just short of the front.

The pass runs after the ungrouped search, which is unchanged, and replaces
its result only by beating it. The help tutorial's parts now end at 34.9"
instead of 38.1" on 60 x 120.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:41:33 -05:00

29 lines
1.1 KiB
C#

using OpenNest.Benchmark;
using OpenNest.Engine.Jobs.Adapters;
using OpenNest.Engine.NestingEngines.Irregular;
using OpenNest.Tests.CuttingPlanning;
namespace OpenNest.Tests.Engine;
/// <summary>
/// The help tutorial's parts (30 gussets, 20 ells, 10 plates, 12 flanges on a 60 x 120 sheet) nest
/// with like parts grouped. Before grouping, Irregular ended the layout at 38.06"; a hand-grouped
/// layout of the same parts ends at 34.1".
/// </summary>
public class GroupedNestingTests
{
[Fact]
public void TutorialPartsNestInAShorterStripWhenGrouped()
{
var path = Path.Combine(PlanningCharacterizationTests.RepositoryRoot(), "test-data", "help-tutorial", "first-nest.nest");
var job = Assert.Single(JobLoader.Load(path)).BuildNestJob(1);
var result = new IrregularNestingEngine().Solve(job);
var plate = Assert.Single(NestResultMaterializer.Materialize(job, result).Nest.Plates);
Assert.Equal(72, plate.Parts.Count);
var right = plate.Parts.Max(p => p.BoundingBox.Right);
Assert.True(right < 35.5, $"Layout ends at {right:F3}");
}
}