feat(irregular): band the last sheet of each best plan

The frontier packer is offered Lattice blocks only on an empty sheet, so
the like parts that end a job went down one copy at a time, and the
banded variant that lays them out as a person does runs minutes later.
Someone stopping Auto Nest on an early plan got that ragged sheet.

Each plan that becomes the best now has its last sheet packed again as
full-height Lattice bands, before and after its tail re-plan, on a work
meter and block catalog of its own. The banded plan is kept beside the
search, reported when it beats every plan reported and returned when the
search ends without beating it, so the search runs as before.

On N26-2J9 the nine-sheet plan's last sheet (139 parts on 48 x 144) ends
at 114.55 instead of 120.76, about 22 s after the plan is reported.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Fable 5.2 committed 2026-11-24 19:58:05 -05:00
1 parent 9e3f0d5558
commit 96e6a1e006
8 files changed
+313 -30

No files matched your search

@@ -0,0 +1,107 @@
using System.Linq;
using OpenNest.Engine.Jobs;
using OpenNest.Engine.NestingEngines.Irregular;
using OpenNest.Geometry;
using static OpenNest.Engine.Tests.NestingEngines.JobBuilder;
using static OpenNest.Engine.Tests.NestingEngines.Shapes;
namespace OpenNest.Engine.Tests.NestingEngines;
/// <summary>
/// Irregular bands the last sheet of each plan it makes its best: the like parts that end a job
/// as their Lattice patterns side by side. On a real job (six 43 x 6 strips, 27 small plates and
/// 106 interlocking triangles ending a nine-sheet plan on 48 x 144) the frontier packer set the
/// triangles down one at a time and the sheet ended at 120.8; banded it ends at 114.6. That sheet
/// takes about twenty seconds to band, so smaller ones are tested here.
/// </summary>
public class IrregularBandLastSheetTests
{
/// <summary>The search before the bands, without the variants that band whole jobs.</summary>
private static IrregularNestingEngine Engine(bool bandLastSheet) => new()
{
GroupLikeParts = false,
BandLikeParts = false,
BandLastSheet = bandLastSheet,
};
private static NestJob BarsThenTriangles() => Job(
new[]
{
Part("bar", Rectangle(43, 6), 3),
Part("plate", Rectangle(12.5, 4.2), 9),
Part("tri", Wedge(), 40),
},
new[] { Stock("sheet", 48, 96, spacing: 0.25, edge: new Spacing(0.25, 0.25)) });
/// <summary>A tapered tab: two interlock head to tail, which the frontier packer does not find
/// for every copy.</summary>
private static OpenNest.CNC.Program Wedge() => Polyline((0, 0), (7.6, 0), (7.6, 1), (0.8, 3.8), (0, 3.8));
[Fact]
public void TheLastSheetEndsShorterThanWithoutTheBands()
{
var job = BarsThenTriangles();
var plain = Engine(bandLastSheet: false).Solve(job);
var banded = Engine(bandLastSheet: true).Solve(job);
LayoutAssert.Valid(job, banded);
Assert.Equal(NestJobStatus.Complete, banded.Status);
Assert.Equal(plain.Plates.Count, banded.Plates.Count);
Assert.True(NestJobCost.CompactnessOffcut(job, banded) > NestJobCost.CompactnessOffcut(job, plain),
$"{NestJobCost.CompactnessOffcut(job, banded)} against {NestJobCost.CompactnessOffcut(job, plain)}");
}
[Fact]
public void TheBandedPlanIsReportedAndReturned()
{
var plans = PlanAssert.ReportedAndEndWithTheResult(() => Engine(bandLastSheet: true), BarsThenTriangles());
Assert.True(plans.Count > 1);
}
[Fact]
public void TheSameJobBandsTheSameWay()
{
var first = Engine(bandLastSheet: true).Solve(BarsThenTriangles());
var second = Engine(bandLastSheet: true).Solve(BarsThenTriangles());
Assert.Equal(PlanAssert.Layout(first), PlanAssert.Layout(second));
}
[Fact]
public void JobsOfSeveralPrioritiesAreNotBanded()
{
var job = Job(
new[]
{
Part("bar", Rectangle(43, 6), 3, priority: 1),
Part("plate", Rectangle(12.5, 4.2), 9),
Part("tri", Wedge(), 40),
},
new[] { Stock("sheet", 48, 96, spacing: 0.25, edge: new Spacing(0.25, 0.25)) });
var plain = Engine(bandLastSheet: false).Solve(job);
var banded = Engine(bandLastSheet: true).Solve(job);
Assert.Equal(PlanAssert.Layout(plain), PlanAssert.Layout(banded));
}
[Fact]
public void ALastSheetWithoutThreeOfAKindIsLeftAlone()
{
var job = Job(
new[]
{
Part("bar", Rectangle(40, 6), 2),
Part("plate", Rectangle(12, 4), 2),
Part("ell", LShape(12, 10, 4), 2),
},
new[] { Stock("sheet", 48, 96, spacing: 0.25, edge: new Spacing(0.25, 0.25)) });
var plain = Engine(bandLastSheet: false).Solve(job);
var banded = Engine(bandLastSheet: true).Solve(job);
Assert.Equal(PlanAssert.Layout(plain), PlanAssert.Layout(banded));
}
}
@@ -125,13 +125,16 @@ public class IrregularSearchUntilCancelledTests
var plain = new Recorder();
// Grouped, or with ten ells (whose blocks Fill nests as herringbone pairs), this job's
// normal search already finds a plan the seeds do not beat within the sheets allowed
// here; this test is of the seeded search, so it runs ungrouped with twelve.
var plainResult = new IrregularNestingEngine { GroupLikeParts = false }.Solve(MixedJob(false, Ells), plain);
// here; this test is of the seeded search, so it runs ungrouped with twelve. So does the
// normal search's best plan with its last sheet banded, so the bands are off as well.
var plainResult = new IrregularNestingEngine { GroupLikeParts = false, BandLastSheet = false }
.Solve(MixedJob(false, Ells), plain);
var normalSheets = 0;
new IrregularNestingEngine { GroupLikeParts = false, SheetPacked = () => normalSheets++ }.Solve(MixedJob(false, Ells));
new IrregularNestingEngine { GroupLikeParts = false, BandLastSheet = false, SheetPacked = () => normalSheets++ }
.Solve(MixedJob(false, Ells));
// A time-limited solve packs its quick plan before the normal search.
var quickSheets = 0;
var quick = new IrregularNestingEngine { GroupLikeParts = false, SheetPacked = () => quickSheets++ }
var quick = new IrregularNestingEngine { GroupLikeParts = false, BandLastSheet = false, SheetPacked = () => quickSheets++ }
.QuickPlanForTesting(MixedJob(false, Ells));
var extendedSheets = 0;
@@ -140,6 +143,7 @@ public class IrregularSearchUntilCancelledTests
var engine = new IrregularNestingEngine
{
GroupLikeParts = false,
BandLastSheet = false,
// The quick plan and the normal search pack exactly quickSheets + normalSheets sheets;
// later ones are extended.
TailReplanning = budget =>
@@ -26,6 +26,9 @@ namespace OpenNest.Engine.NestingEngines.Irregular;
/// A person nesting many copies of a few parts lays them out in tidy columns; a frontier packer
/// placing one part at a time instead leaves every group's last column ragged and scatters the
/// smallest parts into the gaps between groups.
///
/// Without <c>lowerBands</c> a type has only its full-height bands: about half the patterns to
/// build, for a caller that packs a sheet again and again.
/// </summary>
internal sealed class BandedFill(
IReadOnlyList<PartType> types,
@@ -35,7 +38,8 @@ internal sealed class BandedFill(
Func<FrontierPacker> packer,
Comparison<SheetFill> compare,
WorkCounter counter,
long budget)
long budget,
bool lowerBands = true)
{
/// <summary>Fewest copies a band may hold back to be narrower; a third of them when more.</summary>
private const int MaxHeldBack = 4;
@@ -539,7 +543,7 @@ internal sealed class BandedFill(
var options = FullBands(t, copies, token);
var shortest = ShortestSide(types[t]);
var last = options.FirstOrDefault();
for (var i = 0; i < LowerHeights && last != null; i++)
for (var i = 0; lowerBands && i < LowerHeights && last != null; i++)
{
var height = Tall(last) - StepShort;
// Nothing between the clear height and the full band's could sit past the clamps whole.
@@ -61,6 +61,9 @@ internal sealed class BlockCatalog : IDisposable
private readonly long budget;
private readonly Func<NestJobPart, Drawing>? drawingFor;
/// <summary>Least index of an orientation a proposal adds; see the constructor.</summary>
private readonly int firstIndex;
/// <summary>The catalog's own drawing per type, made only without <see cref="drawingFor"/>.</summary>
private readonly Dictionary<int, Drawing> drawings = new();
@@ -188,10 +191,13 @@ internal sealed class BlockCatalog : IDisposable
/// <param name="drawingFor">Shared private drawings whose best-fit entries the caller owns;
/// null makes the catalog own one per type and release it on dispose.</param>
/// <param name="firstIndex">Least index of an orientation a proposal adds. A solve's second
/// catalog of one spacing sets it past the first's, as no-fit polygons are kept per index.</param>
public BlockCatalog(double spacing, IReadOnlyList<PartType> types,
IReadOnlyDictionary<int, IReadOnlyList<PairPose>> pairs, WorkCounter counter, long budget,
Func<NestJobPart, Drawing>? drawingFor = null)
Func<NestJobPart, Drawing>? drawingFor = null, int firstIndex = 0)
{
this.firstIndex = firstIndex;
this.spacing = spacing;
bandSpacing = spacing + System.Math.Pow(10, -NoFitCache.Precision);
this.counter = counter;
@@ -317,7 +323,8 @@ internal sealed class BlockCatalog : IDisposable
return Array.Empty<Placed>();
var type = request.Type;
var poses = Propose(request, spacing, DrawingOf(type), token, out _);
return poses == null ? Array.Empty<Placed>() : Bind(type, poses, orientations[type.Index], token);
return poses == null ? Array.Empty<Placed>()
: Bind(type, poses, orientations[type.Index], token, firstIndex);
}
/// <summary>
@@ -355,7 +362,7 @@ internal sealed class BlockCatalog : IDisposable
return Array.Empty<Placed>();
var entry = BandFor(request, token, prefetch);
if (prefetch != null)
return entry.Members ?? Bind(type, entry.Poses!, orientations[type.Index].ToList(), token);
return entry.Members ?? Bind(type, entry.Poses!, orientations[type.Index].ToList(), token, firstIndex);
lock (bands)
{
// The first ordinary request pays for the pattern, whichever request built it.
@@ -368,7 +375,7 @@ internal sealed class BlockCatalog : IDisposable
return entry.Members;
}
// Ordinary requests of one type run on one thread at a time.
var bound = Bind(type, entry.Poses!, orientations[type.Index], token);
var bound = Bind(type, entry.Poses!, orientations[type.Index], token, firstIndex);
lock (bands)
entry.Members = bound;
return bound;
@@ -533,11 +540,11 @@ internal sealed class BlockCatalog : IDisposable
/// <summary>
/// The certified poses as members relative to the first, each at the orientation of its
/// rotation, which is added to <paramref name="orientations"/> when missing; empty when one
/// cannot be made.
/// rotation, which is added to <paramref name="orientations"/> when missing, at
/// <paramref name="firstIndex"/> or above; empty when one cannot be made.
/// </summary>
private static IReadOnlyList<Placed> Bind(PartType type, NestJobPlacement[] poses, List<Orientation> orientations,
CancellationToken token)
CancellationToken token, int firstIndex = 0)
{
try
{
@@ -545,7 +552,7 @@ internal sealed class BlockCatalog : IDisposable
foreach (var pose in poses)
{
token.ThrowIfCancellationRequested();
var orientation = OrientationAt(type, orientations, pose.Rotation);
var orientation = OrientationAt(type, orientations, pose.Rotation, firstIndex);
if (orientation == null)
return Array.Empty<Placed>();
result.Add(new Placed(orientation, pose.X - poses[0].X, pose.Y - poses[0].Y));
@@ -560,12 +567,14 @@ internal sealed class BlockCatalog : IDisposable
/// <summary>The orientation at the rotation, made and added to <paramref name="orientations"/>
/// when missing; null when it cannot be made.</summary>
private static Orientation? OrientationAt(PartType type, List<Orientation> orientations, double rotation)
private static Orientation? OrientationAt(PartType type, List<Orientation> orientations, double rotation,
int firstIndex)
{
var orientation = orientations.FirstOrDefault(o => o.Rotation == rotation);
if (orientation != null)
return orientation;
orientation = PartCatalog.CreateOrientation(type, orientations.Max(o => o.Index) + 1, rotation);
orientation = PartCatalog.CreateOrientation(type,
System.Math.Max(firstIndex, orientations.Max(o => o.Index) + 1), rotation);
if (orientation != null)
orientations.Add(orientation);
return orientation;
@@ -171,6 +171,74 @@ public sealed partial class IrregularNestingEngine
yield return snake;
}
/// <summary>First orientation index of the catalogs of <see cref="BandLastSheet"/>: above
/// the other catalogs' and below the solved ones.</summary>
private const int TailOrientations = 500_000;
/// <summary>The work meter of <see cref="BandLastSheet"/>, which its catalogs keep.</summary>
private readonly WorkCounter tailWork = new();
/// <summary>The Lattice catalogs of <see cref="BandLastSheet"/>, per spacing.</summary>
private readonly Dictionary<double, BlockCatalog> tailBlocks = new();
/// <summary>The last sheets <see cref="BandLastSheet"/> has banded, by stock and demand;
/// null where the sheet did not band whole.</summary>
private readonly Dictionary<string, SheetFill?> tailBands = new(StringComparer.Ordinal);
/// <summary>
/// The plan with its last sheet packed again as bands (<see cref="BandedFill.Fill"/>, full
/// height only): each like-part group as its Lattice pattern, side by side, as a person
/// fills the end of a job. The frontier packer is offered Lattice blocks only on an empty
/// sheet, so the groups that end a job behind other parts go down one copy at a time and
/// end ragged. Returns the plan given unless the banded sheet holds every part and the
/// plan then beats it.
///
/// It runs on a work meter and Lattice catalogs of its own, so every other pass runs as
/// without it.
/// </summary>
public Plan BandLastSheet(Plan plan)
{
if (plan.Unplaced != 0 || plan.Sheets.Count == 0)
return plan;
var last = plan.Sheets[^1];
var stock = last.Stock;
var demand = new int[types.Count];
foreach (var part in last.Parts)
demand[part.Orientation.TypeIndex]++;
if (stock.Outline != null || !demand.Any(d => d >= GroupedFill.MinGroup))
return plan;
var key = stock.Id + ":" + string.Join(",", demand);
if (!tailBands.TryGetValue(key, out var fill))
{
FrontierPacker Gaps() => new(types, CacheFor(stock), PairsFor(stock), stock, PackAxis.X, 1.0, tailWork,
clamps: ClampsFor(stock));
fill = new BandedFill(types, TailBlocksFor(stock), stock, ClampsFor(stock), Gaps, CompareSheets,
tailWork, tailWork.Value + workBudget, lowerBands: false).Fill(demand, token);
if (fill != null && fill.Parts.Count != last.Parts.Count)
fill = null;
tailBands[key] = fill;
}
if (fill == null)
return plan;
var candidate = plan with
{
Sheets = plan.Sheets.Take(plan.Sheets.Count - 1).Append(fill).ToList(),
Cost = NestJobCost.RequireFinite(plan.Cost - NetCost(job.Options, last) + NetCost(job.Options, fill)),
};
return candidate.IsBetterThan(plan) ? candidate : plan;
}
/// <summary>Lattice patterns for this stock's spacing, for <see cref="BandLastSheet"/> alone.</summary>
private BlockCatalog TailBlocksFor(NestPlateStock stock)
{
var spacing = Clearance(stock);
if (!tailBlocks.TryGetValue(spacing, out var found))
tailBlocks[spacing] = found = new BlockCatalog(spacing, types, PairsFor(stock), tailWork, workBudget,
engine.DrawingFor, TailOrientations);
return found;
}
/// <summary>
/// Packs the last sheet of a complete plan again inside ever shorter strips
/// (<see cref="OrderedSqueeze"/>), along each of <see cref="SqueezeAxes"/>; a shorter
@@ -52,7 +52,7 @@ public sealed partial class IrregularNestingEngine
public void Dispose()
{
foreach (var catalog in blocks.Values)
foreach (var catalog in blocks.Values.Concat(tailBlocks.Values))
catalog.Dispose();
}
@@ -95,6 +95,9 @@ public sealed partial class IrregularNestingEngine : INestingEngine
.Any(level => level.Select(t => ranks[t.Index]).Distinct().Count() > 1));
}
/// <summary>Whether the last sheet is packed again as bands; off only in tests of the search before it.</summary>
internal bool BandLastSheet { get; init; } = true;
/// <summary>Whether the sheet-reduction pass runs; off only in tests of the search before it.</summary>
internal bool ReduceSheets { get; init; } = true;
@@ -229,7 +232,7 @@ public sealed partial class IrregularNestingEngine : INestingEngine
if (untilCancelled)
search.SeededVariants(groups);
return BuildResult(job, types, search.Best, progress, token);
return BuildResult(job, types, search.Result, progress, token);
}
/// <summary>
@@ -248,9 +251,20 @@ public sealed partial class IrregularNestingEngine : INestingEngine
{
private Plan? best;
/// <summary>
/// The best plan reported so far: <see cref="Best"/>, or one of the search's best plans
/// with its last sheet banded (<see cref="BandLastSheet"/>). The search never reads it, so
/// it runs as without the banding.
/// </summary>
private Plan? shown;
/// <summary>The best plan so far; the strategy variants find the first.</summary>
public Plan Best => best ?? throw new InvalidOperationException("The strategy variants have not run.");
/// <summary>The plan to return, which is the last one reported as the best: the search's
/// best, or a banded plan it has not beaten.</summary>
public Plan Result => shown ?? Best;
private long WorkBudget => engine.WorkBudget;
/// <summary>Reports the first variant decoded without Lattice blocks; it never becomes the best.</summary>
@@ -278,7 +292,7 @@ public sealed partial class IrregularNestingEngine : INestingEngine
if (leader == null || plan.IsBetterThan(leader))
{
leader = plan;
Report(leader);
ReportBest(leader);
}
else
ReportAlternative(plan);
@@ -287,7 +301,9 @@ public sealed partial class IrregularNestingEngine : INestingEngine
}
best = leader!;
BandLastSheet();
Replace(solver.ImproveTail(leader!, WorkBudget * 2));
BandLastSheet();
}
/// <summary>Decodes the grouped variants, none starting once the work budget is spent.</summary>
@@ -313,7 +329,7 @@ public sealed partial class IrregularNestingEngine : INestingEngine
|| solver.Work.Value >= BandedWorkLimit * WorkBudget)
return;
token.ThrowIfCancellationRequested();
Offer(solver.Plan(demand, Strategy.Banded));
Offer(solver.Plan(demand, Strategy.Banded), banded: true);
}
/// <summary>
@@ -346,7 +362,30 @@ public sealed partial class IrregularNestingEngine : INestingEngine
return true;
}
public void ReduceSheets() => Replace(solver.ReduceSheets(Best));
/// <summary>
/// Packs the best plan's last sheet again as bands, each time a plan becomes the best: the
/// like parts that end a job, which the frontier packer set down one at a time behind the
/// others, each as its Lattice pattern. The banded plan is reported when it beats every
/// plan reported and returned when it beats the search's result; it never becomes
/// <see cref="Best"/>. Bands ignore priority, so only for jobs of one priority.
/// </summary>
private void BandLastSheet()
{
if (!engine.BandLastSheet || job.Parts.Select(p => p.Priority).Distinct().Count() != 1)
return;
token.ThrowIfCancellationRequested();
var banded = solver.BandLastSheet(Best);
if (!ReferenceEquals(banded, Best))
ReportBest(banded);
}
public void ReduceSheets()
{
var before = Best;
Replace(solver.ReduceSheets(before));
if (!ReferenceEquals(Best, before))
BandLastSheet();
}
public void SqueezeLastSheet() => Replace(solver.Squeeze(Best));
@@ -375,22 +414,30 @@ public sealed partial class IrregularNestingEngine : INestingEngine
/// Takes a variant's plan: it becomes the best by beating it, and is otherwise reported as
/// another layout, like the complete plans its decode passed over.
/// </summary>
private void Offer(Plan plan)
/// <param name="banded">The plan's sheets are banded already.</param>
private void Offer(Plan plan, bool banded = false)
{
ReportAlternatives();
if (plan.IsBetterThan(Best))
Adopt(plan);
Adopt(plan, banded);
else
ReportAlternative(plan);
}
/// <summary>Makes a plan that beat the best the new best, and re-plans its tail on a fresh budget.</summary>
private void Adopt(Plan plan)
/// <summary>Makes a plan that beat the best the new best and re-plans its tail on a fresh
/// budget, banding the last sheet before and after: a tail re-plan can take a minute, and
/// the plan shown meanwhile is the one a person stopping the search gets. A plan whose
/// sheets are <paramref name="banded"/> already is banded only when its tail changes.</summary>
private void Adopt(Plan plan, bool banded = false)
{
// Report before the tail re-plan, which the limit may cut short.
Report(plan);
ReportBest(plan);
best = plan;
if (!banded)
BandLastSheet();
Replace(solver.ImproveTail(plan, solver.Work.Value + WorkBudget * 2));
if (!banded || !ReferenceEquals(best, plan))
BandLastSheet();
}
/// <summary>Takes a pass's result, which is the plan it was given unless it found a better one.</summary>
@@ -399,10 +446,22 @@ public sealed partial class IrregularNestingEngine : INestingEngine
if (ReferenceEquals(result, best))
return;
best = result;
Report(result);
ReportBest(result);
}
/// <summary>Reports a new best whole-job plan.</summary>
/// <summary>
/// Reports a plan the search made its best, or its banded form, unless a plan already
/// reported is as good: a banded plan can stay ahead of the search's next best.
/// </summary>
private void ReportBest(Plan plan)
{
if (shown != null && !plan.IsBetterThan(shown))
return;
shown = plan;
Report(plan);
}
/// <summary>Reports a whole-job plan as the best so far.</summary>
private void Report(Plan plan)
{
if (progress != null)
+34 -2
View File
@@ -14,7 +14,7 @@ in `OpenNest.Engine/NestingEngines/<Name>/`, its tests in `OpenNest.Engine.Tests
| Default | Any job; used when no engine is named | Runs Irregular, Rectangles and Circles, checks each layout with the layout check and keeps the best: valid first, then fewest unplaced parts, then lowest salvage-credited cost, then the largest compactness offcut; remaining ties keep the engine listed first here |
| Rectangles | Plain and near-rectangular plates | Each part packed as the box of its material at its minimum-area rotation, using a maximal-rectangles free list; the sheet that finishes the job is also squeezed into a shorter or narrower bin; stock chosen sheet by sheet by salvage-credited look-ahead cost, and the whole job also run large parts first with the small parts filling their sheets' gaps |
| Circles | Round parts: blanks, washers, flanges, gears by their tip circle | Each part packed as its minimum enclosing circle at centers tangent to two of walls, placed discs and clamp keep-outs, with hexagonal and square lattice seeds; bids only when every part is round; stock chosen as Rectangles does, plus whole-job runs preferring each stock and a tail re-plan |
| Irregular | Irregular profiles | No-fit-polygon frontier packing with gap filling and best-fit pairs, six whole-job strategy variants (each also keeping a stock that finished the job when the per-sheet estimate passed it over for a plan that ended up dearer) and a tail re-plan, then large-first variants that pack each sheet's large parts before any small one, then grouped variants that pack like parts together, then a banded variant that packs each sheet in full-height strips, each group as its Lattice band or each strip from the largest parts down, then a sheet-reduction pass that packs edge parts first and turns a key part by its contacts, then a squeeze that packs the last sheet again, largest part first, in ever shorter strips; under a time limit it first reports a quick plan without Lattice blocks, and after its search keeps trying seeded variants until the limit |
| Irregular | Irregular profiles | No-fit-polygon frontier packing with gap filling and best-fit pairs, six whole-job strategy variants (each also keeping a stock that finished the job when the per-sheet estimate passed it over for a plan that ended up dearer) and a tail re-plan, then large-first variants that pack each sheet's large parts before any small one, then grouped variants that pack like parts together, then a banded variant that packs each sheet in full-height strips, each group as its Lattice band or each strip from the largest parts down, with the last sheet of every plan it makes its best packed again as such bands, then a sheet-reduction pass that packs edge parts first and turns a key part by its contacts, then a squeeze that packs the last sheet again, largest part first, in ever shorter strips; under a time limit it first reports a quick plan without Lattice blocks, and after its search keeps trying seeded variants until the limit |
| FlatBar | Flat bar: parts about as wide as the bar | Each stock read as a bar and cut in one row: the CutList cut-list packer and a best-fill search on part lengths less their self-nesting gain, then a slide-left pass that nests shaped ends and refills freed length; stock chosen bar by bar by whole-plan cost |
| Lattice, Strip, Vertical Remnant, Horizontal Remnant | Many copies of a few parts | The fixed placement strategies behind interactive fill; Lattice is the multi-phase lattice fill (linear, pairs, rectangle best-fit, remainder; the pairs phase fills the strip its grid leaves with rows of pairs when they hold more than single parts, and also tiles herringbone pairs: the part turned so a hull edge lies along a sheet axis, nested into its own row, with every other row reversed), and the remnant strategies run it ranked to keep the largest drop. In whole jobs, all four place a plate with any fixed or bounded part rotation by the rotation-aware ordered placer instead |
@@ -112,7 +112,9 @@ returned layout. Reporting never changes the search: layouts are identical with
progress sink.
- Irregular reports when a strategy variant, a grouped variant or a tail re-plan beats its best plan so far;
under a time limit it reports a quick plan before them (see [time limits](#time-limits)).
under a time limit it reports a quick plan before them (see [time limits](#time-limits)). It also
reports such a plan with its last sheet banded (see [last-sheet bands](#last-sheet-bands)) when
that beats every plan reported, and then skips the search's next best plans until one beats it.
- Rectangles makes one sheet-by-sheet run, so it reports the finished job as its one plan.
- 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,
@@ -445,6 +447,36 @@ and leaves a strip below it for the smaller leg's last two copies, ending the la
starts while the work spent stays under three work budgets and replaces the result only by
beating it, with its own tail re-plan.
### Last-sheet bands
The frontier packer is offered Lattice blocks only on an empty sheet and after its first
placement, a type gets at most eight block preparations a solve, none once the work budget is
spent, and the large-first and grouped variants prepare none. So the like parts that end a job,
behind whatever else is on the last sheet, go down one copy at a time and end ragged, and the
banded variant, which would lay them out as a person does, runs minutes later and replaces the
plan only by beating all of it. Someone stopping the search on an early plan got that ragged
sheet.
So each time a plan becomes the best, and again after its tail re-plan, Irregular packs its last
sheet again as bands (`BandedFill.Fill`): each type of three or more copies on it as its Lattice
pattern in the narrowest full-height strip, the bands side by side in the best of the three
orders, narrower bands tried in turn, the rest filling the gaps. Only full-height bands are
searched (no lower bands, no strips), which takes about half the Lattice fills of the banded
variant's sheet; a last sheet banded once is not banded again, and a plan the banded variant
made only when its tail re-plan changes it. It needs a complete plan, a rectangular last sheet
and a job of one priority.
The banded sheet stays beside the search. The search keeps its own best plan and runs as without
the pass, on the same work meter and Lattice catalogs: the pass has its own (its orientations
are numbered apart, as no-fit polygons are kept per orientation). A plan with the banded sheet
is reported when it beats every plan reported, and returned when the search ends without a plan
that beats it, so a result is never worse for it.
On the large-first job below, the nine-sheet plan reported 80 s into the solve ended its last
sheet (six 43 x 6 strips, 27 small plates and 106 triangles on 48 x 144) at 120.8, the triangles
scattered over the last 45 inches; banded 22 s later it ends at 114.6. The tail re-plan that
follows moves those small plates and triangles to a 48 x 96 ending at 95.8, which bands to 76.4.
### Large-first variants
The decode picks each sheet's stock by its look-ahead cost, which favors the densest sheet, and a