diff --git a/AGENTS.md b/AGENTS.md
index 034713fb..b7b1afd4 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -59,7 +59,7 @@ Releases: follow [the release procedure](docs/releasing.md) and `scripts/Publish
- Cutoffs persist as definitions on `Plate.CutOffs`; apply through `RegenerateCutOffs`, never preview parts. Preserve sequence positions. Batch planning must finish before mutation and roll back on failure. Cut order comes from Plan Cutting or the user (no automatic part sequencers); use `PlateSequencing.OrderCutOffsFirst`/`PlaceCutOffs` for cutoff dependencies, with nominal spans/reference identity rather than trimmed geometry/names.
- A cutoff starts only at the origin-side edge: stock can be oversize, so the far edge is unknown. Only a head-locked overcut (`CutOff.HeadLockOvercut`, `HeadHeightLock` markers) may start its far-edge segment there; posts refuse it without lock codes.
- Fixed emissions (locked programs, drawing-pinned contours) are accepted as given: their violations warn on an UNVERIFIED proposal and never steer the search, while every planner-chosen motion stays strict. Plates without them must keep the `PlanningCharacterizationTests` digests.
-- A `HeadRaise` marker (a rapid made head-up over cut parts) is the safest-route fallback's last resort, added only after the strict search fails; the strict search never marks a rapid. The one designed raise is the rapid out of a cutout's slug after its lead-out, marked at emission (see the cutting planner doc); no lead-out or an overcut keeps the head down. Every post must raise before a marked rapid or refuse the nest.
+- A `HeadRaise` marker (a rapid made head-up over cut parts) is the safest-route fallback's last resort, added only after the strict search fails; the strict search never marks a rapid. Designed raises are the rapid out of a cutout's slug after its lead-out, marked at emission (see the cutting planner doc; no lead-out or an overcut keeps the head down), and the heat jumps an opt-in `HeatWeight` plans between blocks of parts (counted in `HeatRaises`; weight 0 must stay byte-identical). Every post must raise before a marked rapid or refuse the nest.
- An empty diagnostic is not a clear result unless `IsComplete`. Posting must run checks before writing CNC output; warnings require explicit per-attempt consent, never a persisted bypass. Keep inputs stable through analysis/cancellation.
- Preserve symbolic G-code variable definitions/references in file round trips. Keep training bitmaps by default; inference checks predictor availability before scalar-only extraction.
diff --git a/OpenNest.Core/CNC/CuttingPlanning/OwnedCuttingParameters.cs b/OpenNest.Core/CNC/CuttingPlanning/OwnedCuttingParameters.cs
index 3a69f8e8..e2b7e572 100644
--- a/OpenNest.Core/CNC/CuttingPlanning/OwnedCuttingParameters.cs
+++ b/OpenNest.Core/CNC/CuttingPlanning/OwnedCuttingParameters.cs
@@ -38,7 +38,8 @@ internal static class OwnedCuttingParameters
TabSizeMinWidth = Dimension(source.TabSizeMinWidth),
TabSizeMaxWidth = Dimension(source.TabSizeMaxWidth),
SliceTippingSlugs = source.SliceTippingSlugs,
- LabelMode = source.LabelMode
+ LabelMode = source.LabelMode,
+ HeatWeight = Dimension(source.HeatWeight)
};
}
diff --git a/OpenNest.Core/CNC/CuttingPlanning/OwnedExecution.cs b/OpenNest.Core/CNC/CuttingPlanning/OwnedExecution.cs
index d181bfc6..b20807f0 100644
--- a/OpenNest.Core/CNC/CuttingPlanning/OwnedExecution.cs
+++ b/OpenNest.Core/CNC/CuttingPlanning/OwnedExecution.cs
@@ -72,4 +72,7 @@ public sealed class ExecutionMotion
public double Length => Curve?.Length ?? 0;
internal PostVerificationGeometry.Curve Curve { get; }
internal ExecutionMotion WithStart(Vector? start) => new(start, End, Rapid, Layer, Curve, HeadRaised, Code, CallCode);
+
+ /// This rapid made with the head raised, as if marked ().
+ internal ExecutionMotion WithHeadRaised() => new(Start, End, Rapid, Layer, Curve, headRaised: true, Code, CallCode);
}
diff --git a/OpenNest.Core/CNC/CuttingPlanning/ReleasedContourState.cs b/OpenNest.Core/CNC/CuttingPlanning/ReleasedContourState.cs
index 89fa1950..a11e298a 100644
--- a/OpenNest.Core/CNC/CuttingPlanning/ReleasedContourState.cs
+++ b/OpenNest.Core/CNC/CuttingPlanning/ReleasedContourState.cs
@@ -39,6 +39,18 @@ public sealed class ReleasedContourState
///
internal Func AvoidTabbedPart { get; init; }
+ ///
+ /// Parts (by caller part number) a heat-aware order reaches with the head raised: the rapid that
+ /// arrives at such a part from another part is judged as if marked to raise the head, so its
+ /// crossings are the raise's reason, not a fault. Planning only; the plan's programs are marked
+ /// before replay, which reads the marks. Null raises none.
+ ///
+ internal Func RaisesArrival { get; init; }
+
+ // The part the last check or continuation was for, so a continuation's opening rapid is known
+ // to arrive from another part or not. Zero before any.
+ private int lastPart;
+
///
/// The part whose tabbed outside 's rapid crosses, when that outside is
/// an obstacle only because tabbed parts are avoided (); null otherwise.
@@ -84,6 +96,8 @@ public sealed class ReleasedContourState
var copy = new ReleasedContourState(reportMissingLeadIns, tabMayNotHold, commonLineMember)
{
AvoidTabbedPart = AvoidTabbedPart,
+ RaisesArrival = RaisesArrival,
+ lastPart = lastPart,
partContours = partContours,
partClosed = partClosed,
shared = shared,
@@ -107,10 +121,10 @@ public sealed class ReleasedContourState
ArgumentNullException.ThrowIfNull(execution);
if (arrival is { } point)
PostVerificationGeometry.Validate(point);
- var moves = execution.Motions.ToArray();
- moves[0] = moves[0].WithStart(arrival);
+ var moves = Arriving(execution, arrival, partNumber);
var findings = new List();
AnalyzeMoves(moves, cutoff, new(findings, fixedFindings: new(), raised: new()), 1, partNumber, token);
+ lastPart = partNumber;
return findings.AsReadOnly();
}
@@ -133,14 +147,14 @@ public sealed class ReleasedContourState
ArgumentNullException.ThrowIfNull(execution);
if (arrival is { } point)
PostVerificationGeometry.Validate(point);
- var moves = execution.Motions.ToArray();
- moves[0] = moves[0].WithStart(arrival);
+ var moves = Arriving(execution, arrival, partNumber);
var findings = new List();
var fixedFindings = new List();
var raisedFindings = new List();
var warnings = new List();
AnalyzeMoves(moves, cutoff, new(findings, fixedFindings, raisedFindings, settingsLeadOuts ? warnings : null),
1, partNumber, token, isFixed);
+ lastPart = partNumber;
return (findings.AsReadOnly(), fixedFindings.AsReadOnly(), raisedFindings.AsReadOnly(), warnings.AsReadOnly());
}
@@ -160,13 +174,24 @@ public sealed class ReleasedContourState
PostVerificationGeometry.Validate(arrival);
if (!partClosed || execution.Motions.Count == 0 || !execution.Motions[0].Rapid)
return null;
- var moves = execution.Motions.ToArray();
- moves[0] = moves[0].WithStart(arrival);
+ var moves = Arriving(execution, arrival, partNumber);
var findings = new List();
AnalyzeMoves(moves, false, new(findings), 1, partNumber, token, contoursBefore: partContours);
+ lastPart = partNumber;
return partClosed ? findings.AsReadOnly() : null;
}
+ // The motions with the first starting at the arrival, raised when it arrives from another part
+ // at one reached with the head raised (RaisesArrival).
+ private ExecutionMotion[] Arriving(OwnedExecution execution, Vector? arrival, int partNumber)
+ {
+ var moves = execution.Motions.ToArray();
+ moves[0] = moves[0].WithStart(arrival);
+ if (moves[0] is { Rapid: true, HeadRaised: false } && partNumber != lastPart && RaisesArrival?.Invoke(partNumber) == true)
+ moves[0] = moves[0].WithHeadRaised();
+ return moves;
+ }
+
// findings.Warnings: where a configured lead-out that may cut its tabbed outside free is reported
// (see Check); without it, as for programs judged as they are, it stays an incomplete check.
internal void AnalyzeMoves(IReadOnlyList moves, bool cutoff, ContourFindings findings,
diff --git a/OpenNest.Core/CNC/CuttingPlanning/StateFingerprint.cs b/OpenNest.Core/CNC/CuttingPlanning/StateFingerprint.cs
index 6ac02f34..ab032279 100644
--- a/OpenNest.Core/CNC/CuttingPlanning/StateFingerprint.cs
+++ b/OpenNest.Core/CNC/CuttingPlanning/StateFingerprint.cs
@@ -101,6 +101,12 @@ internal static class StateFingerprint
text.Append("partLabels;");
else if (p.LabelMode == PartLabelMode.PartNumber)
text.Append("partLabelNumber;");
+ // Only when set, so fingerprints taken before the setting existed still match.
+ if (p.HeatWeight != 0)
+ {
+ text.Append("heatWeight;");
+ Number(p.HeatWeight);
+ }
text.Append('}');
}
diff --git a/OpenNest.Core/CNC/CuttingStrategy/CuttingParameters.cs b/OpenNest.Core/CNC/CuttingStrategy/CuttingParameters.cs
index 52f3b26b..7ef3fbc8 100644
--- a/OpenNest.Core/CNC/CuttingStrategy/CuttingParameters.cs
+++ b/OpenNest.Core/CNC/CuttingStrategy/CuttingParameters.cs
@@ -117,5 +117,12 @@ namespace OpenNest.CNC.CuttingStrategy
/// default; a drawing with no label box gets no number, and common-line members get nothing.
///
public PartLabelMode LabelMode { get; set; }
+
+ ///
+ /// Seconds of travel Plan Cutting's part order may spend to cut a part one degree Celsius
+ /// cooler, by an estimate of the heat the parts cut before it left (see
+ /// docs/plate-heat-map.md#sequencing). Zero, the default, orders by travel alone.
+ ///
+ public double HeatWeight { get; set; }
}
}
diff --git a/OpenNest.Data/MachineCuttingDefaults.cs b/OpenNest.Data/MachineCuttingDefaults.cs
index a4430e38..0353cc88 100644
--- a/OpenNest.Data/MachineCuttingDefaults.cs
+++ b/OpenNest.Data/MachineCuttingDefaults.cs
@@ -140,6 +140,7 @@ public static class MachineCuttingDefaults
TabSizeMaxWidth = parameters.TabSizeMaxWidth * scale,
SliceTippingSlugs = parameters.SliceTippingSlugs,
LabelMode = parameters.LabelMode,
+ HeatWeight = parameters.HeatWeight,
PierceClearance = parameters.PierceClearance * scale,
PierceDiameter = parameters.PierceDiameter * scale,
Unknown = previous?.Unknown,
@@ -158,6 +159,7 @@ public static class MachineCuttingDefaults
parameters.TabSizeMaxWidth = cutting.TabSizeMaxWidth * scale;
parameters.SliceTippingSlugs = cutting.SliceTippingSlugs;
parameters.LabelMode = cutting.ResolvedLabelMode;
+ parameters.HeatWeight = double.IsFinite(cutting.HeatWeight) && cutting.HeatWeight > 0 ? cutting.HeatWeight : 0;
parameters.PierceClearance = cutting.PierceClearance * scale;
parameters.PierceDiameter = cutting.PierceDiameter * scale;
}
diff --git a/OpenNest.Data/ThicknessCuttingConfig.cs b/OpenNest.Data/ThicknessCuttingConfig.cs
index 22f0c8a6..c77558c6 100644
--- a/OpenNest.Data/ThicknessCuttingConfig.cs
+++ b/OpenNest.Data/ThicknessCuttingConfig.cs
@@ -53,6 +53,13 @@ public class ThicknessCuttingConfig
: EtchPartLabels ? PartLabelMode.PartNumberAndBendGroups
: PartLabelMode.Off;
+ ///
+ /// Travel seconds Plan Cutting may spend to cut a part one degree cooler (docs/plate-heat-map.md);
+ /// 0 orders by travel alone. Written only when set.
+ ///
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
+ public double HeatWeight { get; set; }
+
public double PierceClearance { get; set; } = 0.0625;
/// The pierce zone's diameter; 0 turns it off.
diff --git a/OpenNest.Engine/CuttingPlanning/CutOffInsertion.cs b/OpenNest.Engine/CuttingPlanning/CutOffInsertion.cs
index 404be7e5..49676c7e 100644
--- a/OpenNest.Engine/CuttingPlanning/CutOffInsertion.cs
+++ b/OpenNest.Engine/CuttingPlanning/CutOffInsertion.cs
@@ -50,7 +50,7 @@ internal static class CutOffInsertion
// The contours finished before each gap, and where the tool is when it reaches the gap.
var states = new ReleasedContourState[count + 1];
var arrivals = new Vector[count + 1];
- states[0] = snapshot.NewReleasedState();
+ states[0] = snapshot.NewReleasedState(planning: true);
arrivals[0] = snapshot.StartPoint;
for (var gap = 0; gap < count; gap++)
{
diff --git a/OpenNest.Engine/CuttingPlanning/CuttingHeatOrder.cs b/OpenNest.Engine/CuttingPlanning/CuttingHeatOrder.cs
new file mode 100644
index 00000000..be610a8a
--- /dev/null
+++ b/OpenNest.Engine/CuttingPlanning/CuttingHeatOrder.cs
@@ -0,0 +1,364 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using OpenNest.CNC.Thermal;
+using OpenNest.Geometry;
+
+namespace OpenNest.Engine.CuttingPlanning;
+
+///
+/// What a heat-aware part order needs: the weight (travel seconds worth one degree Celsius), the
+/// sheet's material and thickness, and the feeds and pierce time the cut is timed with.
+///
+internal sealed record CuttingHeat(double Weight, ThermalParameters Thermal, CutParameters Times)
+{
+ /// Null unless a positive weight, a thickness and usable feeds make heat matter.
+ internal static CuttingHeat For(double weight, ThermalParameters thermal, CutParameters times) =>
+ double.IsFinite(weight) && weight > 0 && thermal is { Thickness: > 0 } && double.IsFinite(thermal.Thickness)
+ && times is { Feedrate: > 0, RapidTravelRate: > 0 } && double.IsFinite(times.Feedrate)
+ && double.IsFinite(times.RapidTravelRate)
+ ? new(weight, thermal, times) : null;
+}
+
+///
+/// One part as the heat-aware order sees it: where the tool reaches and leaves it, its cut extent
+/// (where its heat goes and what a rapid passes over once it is cut), its cut length and pierces,
+/// and whether it may be reached with the head raised: only a part whose program the planner
+/// writes, since the rapid into a program kept as given cannot be marked.
+///
+internal readonly record struct CuttingHeatItem(Vector Arrival, Vector Exit, Box Extent, double CutLength, int Pierces,
+ bool CanRaise = true);
+
+///
+/// Spreads Plan Cutting's heat by cutting the plate in blocks. The parts are grouped into blocks
+/// (two halves cut from opposite ends of the sheet toward each other, or a grid of squares), each
+/// toured on its own like the plain order, and the cut moves between blocks: each next part is the
+/// next of the current block or of another, whichever costs least in travel seconds plus
+/// times the heat estimated where it is cut
+/// (). A move to another block whose straight line passes over the
+/// extent of a part already cut is a jump: it also costs , and the search
+/// reaches that part with the head raised instead of keeping it head-down. Within a block the tour
+/// is the plain tour's and stays strict. Of the plain tour and each block layout, the order with
+/// the least of that cost, summed over the order, is kept; ties keep the plain tour. A proposal like
+/// the plain tour: the search still checks every motion along it. See docs/plate-heat-map.md#sequencing.
+///
+internal static class CuttingHeatOrder
+{
+ /// What a jump's head raise and lowering is taken to cost, in seconds.
+ internal const double RaiseSeconds = 2;
+
+ // What reaching a part head-down across cut parts costs: more than any other move.
+ private const double BlockedSeconds = 1e9;
+
+ // Fewer parts than this per front leave nothing to alternate.
+ private const int MinimumFrontParts = 2;
+
+ // Grid layouts tried: this many squares along the parts' long side.
+ private static readonly int[] GridDivisions = [2, 3, 4, 6];
+
+ /// The plain tour of .
+ /// Every part's data, by ordinal.
+ /// Tours some parts from a start, toward an endpoint when one is given,
+ /// as the plain order would.
+ /// The cheapest order, and the parts it jumps to across parts already cut (none for
+ /// the plain tour).
+ internal static (int[] Order, int[] Jumps) Plan(int[] plain, IReadOnlyList parts, Vector start,
+ IReadOnlyList items, IReadOnlyList> prerequisites, CuttingHeat heat,
+ Func, Vector, Vector?, int[]> blockTour, CancellationToken token)
+ {
+ if (heat == null || parts.Count < 2 * MinimumFrontParts)
+ return (plain, []);
+ var best = (Order: plain, Jumps: Array.Empty());
+ var bestCost = Cost(plain, [], start, items, heat);
+ foreach (var blocks in Layouts(parts, start, items, blockTour))
+ {
+ token.ThrowIfCancellationRequested();
+ if (Interleave(blocks, parts, start, items, prerequisites, heat, token) is not { } candidate)
+ continue;
+ var cost = Cost(candidate.Order, candidate.Jumps, start, items, heat);
+ if (cost < bestCost - 1e-9)
+ (best, bestCost) = (candidate, cost);
+ }
+ return best;
+ }
+
+ ///
+ /// The order's travel seconds, plus per jump, plus the weight times
+ /// the heat estimated where each part is cut: the sum the next part is chosen by.
+ ///
+ internal static double Cost(IReadOnlyList order, IReadOnlyCollection jumps, Vector start,
+ IReadOnlyList items, CuttingHeat heat)
+ {
+ var estimate = new HeatEstimate(heat);
+ var position = start;
+ var total = jumps.Count * RaiseSeconds;
+ foreach (var part in order)
+ {
+ var item = items[part];
+ var travel = estimate.TravelSeconds(position.DistanceTo(item.Arrival));
+ total += travel + heat.Weight * estimate.TemperatureAt(item.Extent.Center, estimate.Time + travel);
+ estimate.Cut(item, travel);
+ position = item.Exit;
+ }
+ return total;
+ }
+
+ // The block layouts tried: two fronts across the long axis and across the short one, then grids.
+ private static IEnumerable Layouts(IReadOnlyList parts, Vector start,
+ IReadOnlyList items, Func, Vector, Vector?, int[]> blockTour)
+ {
+ var bounds = parts.Select(p => items[p].Extent).ToList().GetBoundingBox();
+ var alongX = bounds.Length >= bounds.Width; // Length runs along X.
+ foreach (var axis in new[] { alongX, !alongX })
+ yield return Fronts(parts, start, items, bounds, axis, blockTour);
+ var longSide = System.Math.Max(bounds.Length, bounds.Width);
+ if (!(longSide > 0))
+ yield break;
+ foreach (var division in GridDivisions)
+ {
+ var side = longSide / division;
+ var columns = System.Math.Max(1, (int)System.Math.Round(bounds.Length / side));
+ var rows = System.Math.Max(1, (int)System.Math.Round(bounds.Width / side));
+ var cellWidth = bounds.Length / columns;
+ var cellHeight = bounds.Width / rows;
+ var cells = parts.GroupBy(part =>
+ {
+ var center = items[part].Extent.Center;
+ var column = cellWidth > 0 ? System.Math.Clamp((int)((center.X - bounds.Left) / cellWidth), 0, columns - 1) : 0;
+ var row = cellHeight > 0 ? System.Math.Clamp((int)((center.Y - bounds.Bottom) / cellHeight), 0, rows - 1) : 0;
+ return row * columns + column;
+ }).OrderBy(cell => cell.Key).ToArray();
+ if (cells.Length < 2)
+ continue;
+ yield return cells.Select(cell =>
+ {
+ var column = cell.Key % columns;
+ var row = cell.Key / columns;
+ // Each block is toured from its corner nearest the start, where the cut comes from.
+ var corner = new Vector(
+ System.Math.Clamp(start.X, bounds.Left + column * cellWidth, bounds.Left + (column + 1) * cellWidth),
+ System.Math.Clamp(start.Y, bounds.Bottom + row * cellHeight, bounds.Bottom + (row + 1) * cellHeight));
+ return blockTour(cell.ToArray(), corner, null);
+ }).ToArray();
+ }
+ }
+
+ // The two halves of the parts, split along the axis where their cut length is shared equally,
+ // each toured from its own end of the parts toward the split.
+ private static int[][] Fronts(IReadOnlyList parts, Vector start, IReadOnlyList items,
+ Box bounds, bool alongX, Func, Vector, Vector?, int[]> blockTour)
+ {
+ double Along(Vector point) => alongX ? point.X : point.Y;
+ double Across(Vector point) => alongX ? point.Y : point.X;
+ Vector At(double along, double across) => alongX ? new Vector(along, across) : new Vector(across, along);
+
+ var (low, high) = alongX ? (bounds.Left, bounds.Right) : (bounds.Bottom, bounds.Top);
+ var (lowAcross, highAcross) = alongX ? (bounds.Bottom, bounds.Top) : (bounds.Left, bounds.Right);
+ var nearLow = System.Math.Abs(Along(start) - low) <= System.Math.Abs(Along(start) - high);
+ // Nearest the start first; equal positions keep the given order.
+ var sorted = parts.OrderBy(p => nearLow ? Along(items[p].Extent.Center) : -Along(items[p].Extent.Center)).ToArray();
+ var weights = sorted.Select(p => System.Math.Max(items[p].CutLength, 1e-9)).ToArray();
+ var half = weights.Sum() / 2;
+ var split = 0;
+ for (var sum = 0.0; split < sorted.Length && sum + weights[split] <= half; split++)
+ sum += weights[split];
+ split = System.Math.Clamp(split, MinimumFrontParts, sorted.Length - MinimumFrontParts);
+ var near = sorted.Take(split).ToArray();
+ var far = sorted.Skip(split).ToArray();
+ var meetAlong = (Along(items[near[^1]].Extent.Center) + Along(items[far[0]].Extent.Center)) / 2;
+ var meet = At(meetAlong, (lowAcross + highAcross) / 2);
+ var farStart = At(nearLow ? high : low, System.Math.Clamp(Across(start), lowAcross, highAcross));
+ return [blockTour(near, start, meet), blockTour(far, farStart, meet)];
+ }
+
+ // Cuts along the blocks, each step the next part of whichever block costs least: travel seconds
+ // plus weighted heat, plus RaiseSeconds for a move to another block across a part already cut,
+ // which becomes a jump. Null when no block's next part may be cut (a prerequisite waits deeper
+ // in another block).
+ private static (int[] Order, int[] Jumps)? Interleave(int[][] blocks, IReadOnlyList parts, Vector start,
+ IReadOnlyList items, IReadOnlyList> prerequisites, CuttingHeat heat,
+ CancellationToken token)
+ {
+ var inSet = parts.ToHashSet();
+ var cut = new HashSet();
+ var cutExtents = new List<(int Part, Box Extent)>(parts.Count);
+ var heads = new int[blocks.Length];
+ var estimate = new HeatEstimate(heat);
+ var order = new int[parts.Count];
+ var jumps = new List();
+ var position = start;
+ var current = -1;
+ var last = -1;
+ for (var step = 0; step < order.Length; step++)
+ {
+ token.ThrowIfCancellationRequested();
+ var chosen = -1;
+ var chosenCost = double.MaxValue;
+ var chosenJump = false;
+ // The current block first, so a tie keeps cutting along it.
+ foreach (var block in Enumerable.Range(0, blocks.Length).OrderBy(b => b == current ? 0 : 1))
+ {
+ if (heads[block] >= blocks[block].Length)
+ continue;
+ var part = blocks[block][heads[block]];
+ if (prerequisites[part].Any(p => inSet.Contains(p) && !cut.Contains(p)))
+ continue;
+ var item = items[part];
+ var jump = block != current && current >= 0 && Crosses(position, item.Arrival, cutExtents, last, part);
+ // A part that cannot be reached head-up is reached head-down, as the plain tour's
+ // leg would be, and only when no other block's part may come next.
+ var blocked = jump && !item.CanRaise;
+ if (blocked)
+ jump = false;
+ var travel = estimate.TravelSeconds(position.DistanceTo(item.Arrival));
+ var cost = (blocked ? BlockedSeconds : 0) + travel + (jump ? RaiseSeconds : 0)
+ + heat.Weight * estimate.TemperatureAt(item.Extent.Center, estimate.Time + travel);
+ if (cost < chosenCost)
+ (chosen, chosenCost, chosenJump) = (block, cost, jump);
+ }
+ if (chosen < 0)
+ return null;
+ var next = blocks[chosen][heads[chosen]++];
+ var nextItem = items[next];
+ estimate.Cut(nextItem, estimate.TravelSeconds(position.DistanceTo(nextItem.Arrival)));
+ order[step] = next;
+ if (chosenJump)
+ jumps.Add(next);
+ cut.Add(next);
+ cutExtents.Add((next, nextItem.Extent));
+ position = nextItem.Exit;
+ current = chosen;
+ last = next;
+ }
+ return (order, jumps.ToArray());
+ }
+
+ // Whether the straight move from one point to another passes over the cut extent of a part
+ // already cut, other than the part it leaves and the part it reaches.
+ private static bool Crosses(Vector from, Vector to, List<(int Part, Box Extent)> cut, int leaving, int reaching)
+ {
+ foreach (var (part, extent) in cut)
+ if (part != leaving && part != reaching && SegmentHitsBox(from, to, extent))
+ return true;
+ return false;
+ }
+
+ // Liang-Barsky clipping of the segment against the box.
+ internal static bool SegmentHitsBox(Vector from, Vector to, Box box)
+ {
+ var t0 = 0.0;
+ var t1 = 1.0;
+ var dx = to.X - from.X;
+ var dy = to.Y - from.Y;
+ return Clip(-dx, from.X - box.Left) && Clip(dx, box.Right - from.X)
+ && Clip(-dy, from.Y - box.Bottom) && Clip(dy, box.Top - from.Y);
+
+ bool Clip(double p, double q)
+ {
+ if (System.Math.Abs(p) < 1e-12)
+ return q >= 0;
+ var r = q / p;
+ if (p < 0)
+ {
+ if (r > t1)
+ return false;
+ if (r > t0)
+ t0 = r;
+ }
+ else
+ {
+ if (r < t0)
+ return false;
+ if (r < t1)
+ t1 = r;
+ }
+ return true;
+ }
+ }
+
+ ///
+ /// A cheap stand-in for for choosing an order: each cut part
+ /// leaves a Gaussian blob of the heat its cut put in (absorbed power times its torch-on time),
+ /// as wide as the part to begin with, widening as the heat conducts (4αΔt) and fading with the
+ /// loss from both faces. Torch-on time is the part's cut length at the outside feed plus its
+ /// pierces; travel runs at the rapid rate. It ignores kerfs, dropped slugs and the support bed.
+ /// Like the grid model, its temperatures are relative, for comparing orders.
+ ///
+ internal sealed class HeatEstimate
+ {
+ ///
+ /// The most recent parts whose heat is summed; older blobs have spread into a near-uniform
+ /// background that hardly changes which part is next.
+ ///
+ internal const int MaxDeposits = 200;
+
+ private readonly Queue deposits = new();
+ private readonly double diffusivity;
+ private readonly double heatCapacity;
+ private readonly double loss;
+ private readonly double squareMeters;
+ private readonly double absorbedPower;
+ private readonly double feedRate;
+ private readonly double rapidRate;
+ private readonly double pierceSeconds;
+
+ internal HeatEstimate(CuttingHeat heat)
+ {
+ var thermal = heat.Thermal;
+ var meters = thermal.MetersPerUnit;
+ var material = thermal.Material;
+ diffusivity = material.Diffusivity / (meters * meters);
+ heatCapacity = material.Density * material.SpecificHeat * thermal.Thickness * meters;
+ loss = 2 * thermal.SurfaceCoefficient / heatCapacity;
+ squareMeters = meters * meters;
+ absorbedPower = thermal.AbsorbedPower;
+ var perSecond = thermal.Units == Units.Millimeters ? 1.0 : 1.0 / 60;
+ feedRate = heat.Times.Feedrate * perSecond;
+ rapidRate = heat.Times.RapidTravelRate * perSecond;
+ pierceSeconds = System.Math.Max(0, heat.Times.PierceTime.TotalSeconds);
+ }
+
+ /// Seconds into the cut, after the parts cut so far.
+ internal double Time { get; private set; }
+
+ internal double TravelSeconds(double distance) => distance / rapidRate;
+
+ internal double TorchSeconds(CuttingHeatItem item) =>
+ System.Math.Max(0, item.CutLength) / feedRate + System.Math.Max(0, item.Pierces) * pierceSeconds;
+
+ /// Travels to the part, then cuts it, laying down its heat.
+ internal void Cut(CuttingHeatItem item, double travelSeconds)
+ {
+ var torch = TorchSeconds(item);
+ Time += travelSeconds + torch;
+ if (torch <= 0)
+ return;
+ if (deposits.Count == MaxDeposits)
+ deposits.Dequeue();
+ var extent = item.Extent;
+ deposits.Enqueue(new(extent.Center, absorbedPower * torch, Time,
+ (extent.Width * extent.Width + extent.Length * extent.Length) / 4));
+ }
+
+ /// The estimated temperature rise, in °C, at and .
+ internal double TemperatureAt(Vector at, double time)
+ {
+ var total = 0.0;
+ foreach (var deposit in deposits)
+ {
+ var elapsed = System.Math.Max(0, time - deposit.Time);
+ var spread2 = 4 * diffusivity * elapsed + deposit.Spread2;
+ if (spread2 <= 0)
+ continue;
+ var dx = at.X - deposit.Center.X;
+ var dy = at.Y - deposit.Center.Y;
+ total += deposit.Energy / (heatCapacity * System.Math.PI * spread2 * squareMeters)
+ * System.Math.Exp(-(dx * dx + dy * dy) / spread2 - loss * elapsed);
+ }
+ return total;
+ }
+
+ private readonly record struct Deposit(Vector Center, double Energy, double Time, double Spread2);
+ }
+}
diff --git a/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs b/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs
index cebbbf24..5bc0db70 100644
--- a/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs
+++ b/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs
@@ -84,15 +84,17 @@ public sealed class CuttingPlanBatch
/// worker never reads it.
///
/// The nest's units, which size etched bend letters (docs/label-box.md).
+ /// The feeds and pierce time a heat-aware part order times the cut with
+ /// (); null takes .
public static CuttingPlanBatch Capture(IReadOnlyList plates, CuttingParameters confirmedParameters,
bool preservePartOrder, IReadOnlyList plateNumbers = null, CancellationToken token = default,
- double budgetMultiplier = DefaultBudgetMultiplier, Units units = Units.Inches) =>
- Capture(plates, confirmedParameters, preservePartOrder, plateNumbers, null, token, budgetMultiplier, units);
+ double budgetMultiplier = DefaultBudgetMultiplier, Units units = Units.Inches, CutParameters cutTimes = null) =>
+ Capture(plates, confirmedParameters, preservePartOrder, plateNumbers, null, token, budgetMultiplier, units, cutTimes);
/// Overrides the new-order budget (tests); null gives .
internal static CuttingPlanBatch Capture(IReadOnlyList plates, CuttingParameters confirmedParameters,
bool preservePartOrder, IReadOnlyList plateNumbers, int? reorderBudget, CancellationToken token,
- double budgetMultiplier = DefaultBudgetMultiplier, Units units = Units.Inches)
+ double budgetMultiplier = DefaultBudgetMultiplier, Units units = Units.Inches, CutParameters cutTimes = null)
{
ArgumentNullException.ThrowIfNull(plates);
ArgumentNullException.ThrowIfNull(confirmedParameters);
@@ -126,7 +128,7 @@ public sealed class CuttingPlanBatch
// over the same owned geometry, programs and freshness record.
var captured = CuttingPlanService.Capture(CuttingPlanRequest.ForPlate(plate,
expansionBudget: budget, confirmedParameters: confirmedParameters,
- preservePartOrder: preservePartOrder, units: units), token);
+ preservePartOrder: preservePartOrder, units: units, cutTimes: cutTimes), token);
var keepOrder = preservePartOrder ? captured : captured.WithPreservedOrder();
var reorder = preservePartOrder ? null
: reorderBudget is { } reorderLimit ? captured.WithSearchLimits(reorderLimit, captured.MaxEntries) : captured;
@@ -560,7 +562,10 @@ public sealed class CuttingPlanProposal
: $" {Count(plate.ReversedCutOffCount, "cutoff segment")} at the far edge change direction.")
+ (result.HeadRaises == 0 ? ""
: $" No route found keeps the head down over every cut part, so {Count(result.HeadRaises, "rapid")} "
- + $"{(result.HeadRaises == 1 ? "raises" : "raise")} the head; each is listed below.");
+ + $"{(result.HeadRaises == 1 ? "raises" : "raise")} the head; each is listed below.")
+ + (result.HeatRaises == 0 ? ""
+ : $" To spread the heat, {Count(result.HeatRaises, "rapid")} {(result.HeatRaises == 1 ? "raises" : "raise")} "
+ + "the head to jump to a cooler area; each is listed below.");
// A ready plan's findings are advisory notes (head raises, support tabs that may not hold a part level).
foreach (var line in Limit(result.Findings.Select(DescribeFinding)))
yield return line;
diff --git a/OpenNest.Engine/CuttingPlanning/CuttingPlanModels.cs b/OpenNest.Engine/CuttingPlanning/CuttingPlanModels.cs
index e0abdcfd..fd91f920 100644
--- a/OpenNest.Engine/CuttingPlanning/CuttingPlanModels.cs
+++ b/OpenNest.Engine/CuttingPlanning/CuttingPlanModels.cs
@@ -38,10 +38,16 @@ public sealed class CuttingPlanRequest
///
public static CuttingPlanRequest ForPlate(Plate plate, Vector startPoint = default, int expansionBudget = 20000,
CuttingParameters confirmedParameters = null, IEnumerable eligibleParts = null,
- bool preservePartOrder = false, int maxEntries = 16, Units units = Units.Inches) =>
+ bool preservePartOrder = false, int maxEntries = 16, Units units = Units.Inches, CutParameters cutTimes = null) =>
new(plate?.Parts, startPoint, expansionBudget, confirmedParameters, eligibleParts,
preservePartOrder, maxEntries)
- { Plate = plate, SupportBed = plate?.SupportBed, SupportQuadrant = plate?.Quadrant ?? 1, Units = units };
+ {
+ Plate = plate,
+ SupportBed = plate?.SupportBed,
+ SupportQuadrant = plate?.Quadrant ?? 1,
+ Units = units,
+ CutTimes = cutTimes,
+ };
/// The plate scope, or null for a detached part list that cannot be applied.
public Plate Plate { get; private init; }
@@ -61,6 +67,13 @@ public sealed class CuttingPlanRequest
/// bend lines (docs/label-box.md).
///
public Units Units { get; init; } = Units.Inches;
+
+ ///
+ /// The feeds, rapid rate and pierce time the cut is timed with, in , for a
+ /// heat-aware part order (); null takes
+ /// .
+ ///
+ public CutParameters CutTimes { get; init; }
public CuttingParameters ConfirmedParameters { get; }
public IReadOnlyList EligibleParts { get; }
public bool PreservePartOrder { get; }
@@ -100,10 +113,14 @@ public sealed class CuttingPlanSnapshot
/// rapids may cross it as its retained material allows; with
/// its outside is an obstacle all the same.
///
- internal ReleasedContourState NewReleasedState() =>
+ /// For the search and what places cut-offs in its plan: the parts in
+ /// are then reached with the head raised. Replay leaves it off and reads
+ /// the marks the plan's programs carry instead.
+ internal ReleasedContourState NewReleasedState(bool planning = false) =>
new(reportMissingLeadIns: false, null, CommonLineMembers.Count == 0 ? null : CommonLineMembers.Contains)
{
AvoidTabbedPart = AvoidsTabbedParts ? part => !CrossableTabbedParts.Contains(part) : null,
+ RaisesArrival = planning && Heat != null ? part => HeatJumps.Contains(part - 1) : null,
};
///
@@ -173,6 +190,19 @@ public sealed class CuttingPlanSnapshot
///
internal bool SupportTabsSkipped { get; init; }
+ /// What a heat-aware part order weighs; null orders by travel alone.
+ internal CuttingHeat Heat { get; init; }
+
+ /// Each placement as the heat-aware order sees it, built once by the search that needs it.
+ internal CuttingHeatItem[] HeatItems { get; set; }
+
+ ///
+ /// The parts (source ordinals) the heat-aware order jumps to across parts already cut: the
+ /// search reaches each with the head raised, and the plan marks that rapid (docs/plate-heat-map.md).
+ /// Owned by the one search planning this capture; a copy starts empty.
+ ///
+ internal HashSet HeatJumps { get; } = [];
+
// A worker-only search variant over the same owned capture. Never recapture the live plate:
// both proposals retain the identical freshness record and confirmed settings.
internal CuttingPlanSnapshot WithSearchLimits(int expansionBudget, int maxEntries) =>
@@ -208,6 +238,7 @@ public sealed class CuttingPlanSnapshot
Dependencies, BestEffort)
{
SupportTabsSkipped = SupportTabsSkipped,
+ Heat = Heat,
CommonLineMembers = CommonLineMembers,
CommonLineOrder = CommonLineOrder,
AcceptsTabLeadOuts = acceptsTabLeadOuts,
@@ -472,6 +503,12 @@ public sealed class CuttingPlanResult
///
public int HeadRaises { get; init; }
+ ///
+ /// Rapids a heat-aware order () raises the head on to
+ /// jump across cut parts to a cooler area; designed, not a fallback, and not in .
+ ///
+ public int HeatRaises { get; init; }
+
/// The captured input this result was planned from; binds Apply to its freshness record.
internal CuttingPlanSnapshot Snapshot { get; set; }
}
diff --git a/OpenNest.Engine/CuttingPlanning/CuttingPlanService.cs b/OpenNest.Engine/CuttingPlanning/CuttingPlanService.cs
index 59398d7d..e86a581b 100644
--- a/OpenNest.Engine/CuttingPlanning/CuttingPlanService.cs
+++ b/OpenNest.Engine/CuttingPlanning/CuttingPlanService.cs
@@ -5,6 +5,7 @@ using System.Threading;
using OpenNest.CNC;
using OpenNest.CNC.CuttingPlanning;
using OpenNest.CNC.CuttingStrategy;
+using OpenNest.CNC.Thermal;
using OpenNest.CutOffs;
using OpenNest.Diagnostics;
using OpenNest.Geometry;
@@ -248,6 +249,7 @@ public static class CuttingPlanService
SupportTabsSkipped = SupportTabSettings.SkipsForNoRange(request.ConfirmedParameters, request.SupportBed),
CommonLineMembers = commonLines?.MemberNumbers(request.Parts) ?? new HashSet(),
CommonLineOrder = commonLineOrder.ToHashSet(),
+ Heat = Heat(request),
};
}
catch (OperationCanceledException)
@@ -452,7 +454,16 @@ public static class CuttingPlanService
// Capture warnings (drawing pins that could not be honored) stay visible on a refusal.
if (joint.Status != CuttingPlanStatus.Ready)
return new(joint.Status, findings: snapshot.Findings.Concat(joint.Findings), expansions: joint.Expansions);
- return ReplayPrograms(snapshot, joint.Order, joint.Expansions, token);
+ var order = joint.Order;
+ try
+ {
+ order = RaisedRapids.MarkHeatJumps(snapshot, order, token);
+ }
+ catch (Exception ex) when (ex is ArgumentException or NotSupportedException)
+ {
+ // A route that cannot be read for marking keeps its crossings, and replay refuses them.
+ }
+ return ReplayPrograms(snapshot, order, joint.Expansions, token);
}
var search = FixedProgramSearch.Run(snapshot, token);
if (search.Status != CuttingPlanStatus.Ready)
@@ -577,6 +588,7 @@ public static class CuttingPlanService
// Rapids that raise the head over cut parts are listed, never refused.
var raises = new List();
var raisedRapids = 0;
+ var heatRaises = 0;
var materialOwners = snapshot.Placements.Where(p => !p.IsCutOff).ToArray();
var materials = new LeadMaterialSet(materialOwners.Select(p => p.Material));
foreach (var proposal in order)
@@ -615,8 +627,17 @@ public static class CuttingPlanService
var isFixed = proposal.FixedMotions(execution);
var (strict, fixedFindings, raised, tabLeadOuts) = checker.Check(execution, position,
source.SourceOrdinal + 1, source.IsCutOff, isFixed, token, snapshot.WarnsTabLeadOuts(source));
- raises.AddRange(RaisedRapids.Notes(snapshot, source, raised));
- raisedRapids += RaisedRapids.Count(raised);
+ // A rapid the heat-aware order raised to jump to this part is designed, not a last resort.
+ if (!safestRoute && snapshot.HeatJumps.Contains(source.SourceOrdinal))
+ {
+ raises.AddRange(RaisedRapids.HeatNotes(snapshot, source, raised));
+ heatRaises += RaisedRapids.Count(raised);
+ }
+ else
+ {
+ raises.AddRange(RaisedRapids.Notes(snapshot, source, raised));
+ raisedRapids += RaisedRapids.Count(raised);
+ }
findings.AddRange(JointCuttingPlanSearch.Map(snapshot, strict));
warnings.AddRange(fixedFindings.Select(f => FixedLeadWarnings.FromChecker(snapshot, source, f)));
// A configured lead-out that cuts its tab free is kept and reported, never refused.
@@ -666,10 +687,10 @@ public static class CuttingPlanService
if (warnings.Count != 0)
return new(CuttingPlanStatus.BestEffort, order, warnings.Concat(notes).Distinct(), expansions,
distance, independentlyReplayed: true)
- { HeadRaises = raisedRapids };
+ { HeadRaises = raisedRapids, HeatRaises = heatRaises };
return new(CuttingPlanStatus.Ready, order, notes, expansions: expansions,
rapidDistance: distance, independentlyReplayed: true)
- { HeadRaises = raisedRapids };
+ { HeadRaises = raisedRapids, HeatRaises = heatRaises };
}
private static CuttingPlanFinding DependencyFinding(CuttingPlanSnapshot snapshot,
@@ -692,4 +713,21 @@ public static class CuttingPlanService
private static bool SameBits(double source, double proposed) =>
BitConverter.DoubleToInt64Bits(source) == BitConverter.DoubleToInt64Bits(proposed);
+ // The heat a heat-aware part order weighs, from the confirmed parameters' weight, material and
+ // thickness and the request's feeds; null when the weight is zero or nothing to estimate with.
+ private static CuttingHeat Heat(CuttingPlanRequest request)
+ {
+ var parameters = request.ConfirmedParameters;
+ if (parameters == null || !(parameters.HeatWeight > 0))
+ return null;
+ var times = request.CutTimes ?? CutParameters.Default;
+ var thermal = ThermalParameters.For(parameters.MaterialName, parameters.Grade, parameters.Thickness, request.Units);
+ return CuttingHeat.For(parameters.HeatWeight, thermal, new CutParameters
+ {
+ Feedrate = times.Feedrate,
+ RapidTravelRate = times.RapidTravelRate,
+ PierceTime = times.PierceTime,
+ Units = request.Units,
+ });
+ }
}
diff --git a/OpenNest.Engine/CuttingPlanning/JointCuttingPlanSearch.cs b/OpenNest.Engine/CuttingPlanning/JointCuttingPlanSearch.cs
index de09c66e..332f9f2e 100644
--- a/OpenNest.Engine/CuttingPlanning/JointCuttingPlanSearch.cs
+++ b/OpenNest.Engine/CuttingPlanning/JointCuttingPlanSearch.cs
@@ -315,6 +315,52 @@ internal static class JointCuttingPlanSearch
// shorter. The parts before a sheet separator then finish beside the end it can be cut from,
// rather than beside its origin-side start when that start lies beyond parts already cut.
private static int[] Tour(CuttingPlanSnapshot snapshot, IReadOnlyList parts, Vector start,
+ CuttingNestedOrder.Context nesting) =>
+ Heated(snapshot, parts, start, nesting, TravelTour(snapshot, parts, start, nesting));
+
+ // With a heat weight, the order may instead move between blocks of parts (CuttingHeatOrder)
+ // when that spreads the heat for less than the weight is worth; the parts it jumps to across
+ // cut parts are reached with the head raised. Parts nested in other parts keep the travel
+ // tour, which keeps each host's group together.
+ private static int[] Heated(CuttingPlanSnapshot snapshot, IReadOnlyList parts, Vector start,
+ CuttingNestedOrder.Context nesting, int[] order)
+ {
+ if (snapshot.Heat == null || parts.Any(part => nesting.Inside[part].Count != 0))
+ return order;
+ var items = snapshot.HeatItems ??= snapshot.Placements.Select((placement, part) =>
+ HeatItem(placement, nesting.Centers[part], (nesting.Exits ?? nesting.Centers)[part])).ToArray();
+ var (heated, jumps) = CuttingHeatOrder.Plan(order, parts, start, items, nesting.Prerequisites, snapshot.Heat,
+ (block, from, toward) => CuttingPartOrder.Plan(block, nesting.Centers, from, nesting.Prerequisites,
+ nesting.Token, toward, nesting.Exits, nesting.Visits), nesting.Token);
+ // A replan keeps the jumps of the parts already cut and decides those of the rest anew.
+ snapshot.HeatJumps.ExceptWith(parts);
+ snapshot.HeatJumps.UnionWith(jumps);
+ return heated;
+ }
+
+ // A part's cut extent, cut length and pierces as its program stands, for the heat estimate.
+ private static CuttingHeatItem HeatItem(FixedProgramPlacement placement, Vector arrival, Vector exit)
+ {
+ var length = 0.0;
+ var pierces = 0;
+ var torchOn = false;
+ foreach (var motion in placement.Execution.Motions)
+ {
+ var cuts = !motion.Rapid && motion.Layer is LayerType.Cut or LayerType.Display or LayerType.Leadin
+ or LayerType.Leadout or LayerType.Break;
+ if (cuts)
+ {
+ length += motion.Length;
+ if (!torchOn)
+ pierces++;
+ }
+ torchOn = cuts;
+ }
+ var extent = CutExtent(placement) ?? new Box(arrival.X, arrival.Y, 0, 0);
+ return new(arrival, exit, extent, length, pierces, placement.Prepared != null && !placement.IsCutOff);
+ }
+
+ private static int[] TravelTour(CuttingPlanSnapshot snapshot, IReadOnlyList parts, Vector start,
CuttingNestedOrder.Context nesting)
{
var order = CuttingNestedOrder.Plan(parts, start, nesting);
@@ -598,7 +644,7 @@ internal static class JointCuttingPlanSearch
internal Attempt Follow(int[] sequence, int? stall, Node resume, bool preferredOnly = false, bool contourRecovery = false,
HashSet[] prerequisites = null, int? expansionLimit = null)
{
- var root = resume ?? new Node([], snapshot.StartPoint, snapshot.NewReleasedState(), null, null);
+ var root = resume ?? new Node([], snapshot.StartPoint, snapshot.NewReleasedState(planning: true), null, null);
var attempt = new Attempt(sequence);
var progressExpansions = Expansions;
var stack = new Stack();
@@ -1715,7 +1761,7 @@ internal static class JointCuttingPlanSearch
internal IReadOnlyList FollowSegments(IReadOnlyList order)
{
var followed = order.ToArray();
- var checker = snapshot.NewReleasedState();
+ var checker = snapshot.NewReleasedState(planning: true);
var position = snapshot.StartPoint;
try
{
diff --git a/OpenNest.Engine/CuttingPlanning/RaisedRapids.cs b/OpenNest.Engine/CuttingPlanning/RaisedRapids.cs
index 394c1f09..ba517c74 100644
--- a/OpenNest.Engine/CuttingPlanning/RaisedRapids.cs
+++ b/OpenNest.Engine/CuttingPlanning/RaisedRapids.cs
@@ -51,6 +51,41 @@ internal static class RaisedRapids
return marked;
}
+ ///
+ /// with the arrival rapid of each part the heat-aware order jumps to
+ /// () marked to raise the head where it crosses parts
+ /// already cut, as the search judged it. Every other rapid was kept head-down by the search.
+ ///
+ internal static IReadOnlyList MarkHeatJumps(CuttingPlanSnapshot snapshot,
+ IReadOnlyList order, CancellationToken token)
+ {
+ if (snapshot.HeatJumps.Count == 0)
+ return order;
+ var checker = snapshot.NewReleasedState();
+ var position = snapshot.StartPoint;
+ var marked = new List(order.Count);
+ foreach (var proposal in order)
+ {
+ token.ThrowIfCancellationRequested();
+ var program = proposal.CopyProgram();
+ var execution = ExecutionMotionReader.Read(program, proposal.Location, position, token);
+ var placement = proposal;
+ if (snapshot.HeatJumps.Contains(proposal.SourceOrdinal) && proposal.Prepared != null && !proposal.IsCutOff
+ && Crossing(checker.Copy(), proposal, execution, position, snapshot.WarnsTabLeadOuts(proposal), token).Codes
+ is { Count: > 0 } rapids)
+ {
+ var raised = HeadRaise.Mark(program, rapids);
+ execution = ExecutionMotionReader.Read(raised, proposal.Location, position, token);
+ placement = proposal.Propose(raised, execution, proposal.ContourChoices, token);
+ }
+ checker.Check(execution, position, proposal.SourceOrdinal + 1, proposal.IsCutOff,
+ proposal.FixedMotions(execution), token, snapshot.WarnsTabLeadOuts(proposal));
+ marked.Add(placement);
+ position = execution.DeparturePoint;
+ }
+ return marked;
+ }
+
///
/// The places along an unmarked whose planner-chosen rapids cross parts
/// already cut, each with the source ordinals of the parts crossed, walked as replay walks it.
@@ -128,6 +163,19 @@ internal static class RaisedRapids
{ Witness = rapid.First() };
});
+ /// One advisory note per rapid of a heat-aware order raised to jump to it.
+ internal static IEnumerable HeatNotes(CuttingPlanSnapshot snapshot,
+ FixedProgramPlacement source, IReadOnlyList raised) =>
+ raised.GroupBy(f => (f.RapidStart, f.RapidEnd)).Select(rapid =>
+ {
+ var parts = rapid.Select(f => f.OtherPartNumber).OfType().Distinct().Order().ToArray();
+ var other = parts.Length == 1 ? snapshot.Placements[parts[0] - 1] : null;
+ var over = other != null ? "a part already cut" : $"parts {string.Join(", ", parts)}, already cut,";
+ return new CuttingPlanFinding(source.SourceOrdinal, source.SourcePart, other?.SourceOrdinal,
+ other?.SourcePart, null, $"A rapid raises the head over {over} to cut a cooler area of the sheet next.")
+ { Witness = rapid.First() };
+ });
+
/// The raised rapids in : crossings of one rapid count once.
internal static int Count(IEnumerable raised) =>
raised.Select(f => (f.RapidStart, f.RapidEnd)).Distinct().Count();
diff --git a/OpenNest.IO/CuttingParametersDto.cs b/OpenNest.IO/CuttingParametersDto.cs
index 858313e4..2b605301 100644
--- a/OpenNest.IO/CuttingParametersDto.cs
+++ b/OpenNest.IO/CuttingParametersDto.cs
@@ -43,6 +43,9 @@ public class CuttingParametersDto
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
public PartLabelMode LabelMode { get; set; }
+ // Written only when set, so files and settings saved without it are unchanged.
+ [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
+ public double HeatWeight { get; set; }
// Read only: the old on/off part label option, which meant the number with its bend groups.
// Never written; files saved with it load as PartNumberAndBendGroups.
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
diff --git a/OpenNest.IO/CuttingParametersSerializer.cs b/OpenNest.IO/CuttingParametersSerializer.cs
index 6ee45cff..04d5f1cc 100644
--- a/OpenNest.IO/CuttingParametersSerializer.cs
+++ b/OpenNest.IO/CuttingParametersSerializer.cs
@@ -95,6 +95,7 @@ public static class CuttingParametersSerializer
NoBedTabMaxWidth = parameters.TabSizeMaxWidth,
SliceTippingSlugs = parameters.SliceTippingSlugs,
LabelMode = parameters.LabelMode,
+ HeatWeight = parameters.HeatWeight,
};
}
@@ -131,6 +132,7 @@ public static class CuttingParametersSerializer
TabSizeMaxWidth = dto.NoBedTabMaxWidth,
SliceTippingSlugs = dto.SliceTippingSlugs,
LabelMode = dto.ResolvedLabelMode,
+ HeatWeight = double.IsFinite(dto.HeatWeight) && dto.HeatWeight > 0 ? dto.HeatWeight : 0,
};
}
diff --git a/OpenNest.Tests/CuttingPlanning/CuttingHeatOrderTests.cs b/OpenNest.Tests/CuttingPlanning/CuttingHeatOrderTests.cs
new file mode 100644
index 00000000..9a1bdf69
--- /dev/null
+++ b/OpenNest.Tests/CuttingPlanning/CuttingHeatOrderTests.cs
@@ -0,0 +1,85 @@
+using OpenNest.CNC;
+using OpenNest.CNC.CuttingPlanning;
+using OpenNest.CNC.CuttingStrategy;
+using OpenNest.Engine.CuttingPlanning;
+using OpenNest.Geometry;
+using OpenNest.IO;
+
+namespace OpenNest.Tests.CuttingPlanning;
+
+public class CuttingHeatOrderTests
+{
+ private static CuttingParameters Parameters(double weight)
+ {
+ var parameters = ExplicitContourTests.Parameters();
+ parameters.MaterialName = "Mild Steel";
+ parameters.Thickness = 0.125;
+ parameters.HeatWeight = weight;
+ return parameters;
+ }
+
+ // A dense grid of small squares: the run of neighbors the heat weight spreads out.
+ private static Plate Grid(int columns = 10, int rows = 10, double size = 0.75, double gap = 0.25)
+ {
+ var drawing = TestHelpers.MakeSquareDrawing(size);
+ var plate = new Plate(30, 30);
+ for (var row = 0; row < rows; row++)
+ for (var column = 0; column < columns; column++)
+ plate.Parts.Add(new Part(drawing, new Vector(1 + column * (size + gap), 1 + row * (size + gap))));
+ return plate;
+ }
+
+ private static CuttingPlanResult Plan(Plate plate, double weight) =>
+ CuttingPlanService.Plan(CuttingPlanRequest.ForPlate(plate, Vector.Zero, confirmedParameters: Parameters(weight)));
+
+ private static string[] Order(CuttingPlanResult result) =>
+ result.ProposedOrder.Select(p => $"{p.SourceOrdinal}:{ExplicitContourTests.Fingerprint(p.CopyProgram())}").ToArray();
+
+ [Fact]
+ public void Setting_RoundTripsAndIsLeftOutWhenOff()
+ {
+ var on = CuttingParametersSerializer.Serialize(Parameters(0.25));
+ var off = CuttingParametersSerializer.Serialize(Parameters(0));
+
+ Assert.Contains("heatWeight", on, StringComparison.OrdinalIgnoreCase);
+ Assert.DoesNotContain("heatWeight", off, StringComparison.OrdinalIgnoreCase);
+ Assert.Equal(0.25, CuttingParametersSerializer.Deserialize(on).HeatWeight);
+ Assert.Equal(0, CuttingParametersSerializer.Deserialize(off).HeatWeight);
+ }
+
+ [Fact]
+ public void Setting_IsCopiedAndChangesTheFingerprintOnlyWhenSet()
+ {
+ Assert.Equal(0.25, OwnedCuttingParameters.Copy(Parameters(0.25)).HeatWeight);
+
+ var withoutProperty = StateFingerprint.Of(Parameters(0));
+ Assert.DoesNotContain("heatWeight", withoutProperty);
+ Assert.NotEqual(withoutProperty, StateFingerprint.Of(Parameters(0.25)));
+ }
+
+ [Fact]
+ public void WeightOff_PlansTheTravelOrder()
+ {
+ var plain = Plan(Grid(), 0);
+ var again = Plan(Grid(), 0);
+
+ Assert.Equal(CuttingPlanStatus.Ready, plain.Status);
+ Assert.Equal(0, plain.HeatRaises);
+ Assert.Equal(Order(plain), Order(again));
+ }
+
+ [Fact]
+ public void HighWeight_JumpsBetweenBlocksWithMarkedRaises()
+ {
+ var plain = Plan(Grid(), 0);
+ var heated = Plan(Grid(), 1);
+
+ Assert.Equal(CuttingPlanStatus.Ready, heated.Status);
+ Assert.False(heated.IsSafestRouteFallback);
+ Assert.Equal(0, heated.HeadRaises);
+ Assert.True(heated.HeatRaises > 0);
+ Assert.True(heated.RapidDistance > plain.RapidDistance);
+ Assert.NotEqual(plain.ProposedOrder.Select(p => p.SourceOrdinal), heated.ProposedOrder.Select(p => p.SourceOrdinal));
+ Assert.Equal(heated.HeatRaises, heated.ProposedOrder.Count(p => HeadRaise.IsMarked(p.CopyProgram())));
+ }
+}
diff --git a/OpenNest.Tests/CuttingPlanning/HeatOrderMeasurementTests.cs b/OpenNest.Tests/CuttingPlanning/HeatOrderMeasurementTests.cs
new file mode 100644
index 00000000..112ac97b
--- /dev/null
+++ b/OpenNest.Tests/CuttingPlanning/HeatOrderMeasurementTests.cs
@@ -0,0 +1,135 @@
+using System.Diagnostics;
+using OpenNest.CNC;
+using OpenNest.CNC.CuttingPlanning;
+using OpenNest.CNC.Thermal;
+using OpenNest.Engine.CuttingPlanning;
+using OpenNest.IO;
+using Xunit.Abstractions;
+
+namespace OpenNest.Tests.CuttingPlanning;
+
+///
+/// Measures how a heat weight changes a plate's plan: the hottest-zone percentiles from
+/// , travel, cut time and head raises. Opt-in: set
+/// OPENNEST_HEAT_PLATES to "path.nest:2;other.nest:1" (1-based plate numbers) and optionally
+/// OPENNEST_HEAT_WEIGHTS to "0,0.1,0.2". See docs/plate-heat-map.md#sequencing.
+///
+[Trait("Category", "HeatOrder")]
+public class HeatOrderMeasurementTests(ITestOutputHelper output)
+{
+ private const string PlatesVariable = "OPENNEST_HEAT_PLATES";
+ private const string WeightsVariable = "OPENNEST_HEAT_WEIGHTS";
+
+ [SkippableFact]
+ public void HeatOrder_Measure()
+ {
+ var plates = Environment.GetEnvironmentVariable(PlatesVariable);
+ Skip.If(string.IsNullOrWhiteSpace(plates), $"Set {PlatesVariable} to measure heat-aware plans.");
+ var weights = (Environment.GetEnvironmentVariable(WeightsVariable) ?? "0,0.1,0.2")
+ .Split(',', StringSplitOptions.RemoveEmptyEntries).Select(w => double.Parse(w.Trim(), System.Globalization.CultureInfo.InvariantCulture))
+ .ToArray();
+ foreach (var item in plates!.Split(';', StringSplitOptions.RemoveEmptyEntries))
+ {
+ var split = item.LastIndexOf(':');
+ var path = item[..split].Trim();
+ var number = int.Parse(item[(split + 1)..]);
+ foreach (var weight in weights)
+ output.WriteLine(Measure(path, number, weight));
+ }
+ }
+
+ internal static string Measure(string path, int number, double weight)
+ {
+ Nest nest;
+ using (var stream = File.OpenRead(path))
+ nest = new NestReader(stream).Read();
+ var plate = nest.Plates[number - 1];
+ var parameters = plate.CuttingParameters ?? ProblemNestRegressionTests.DefaultParameters();
+ parameters.MaterialName = nest.Material?.Name;
+ parameters.Grade = nest.Material?.Grade;
+ parameters.Thickness = nest.Thickness;
+ parameters.HeatWeight = weight;
+ var watch = Stopwatch.StartNew();
+ var proposal = CuttingPlanBatch.Capture([plate], parameters, preservePartOrder: false, [number],
+ units: nest.Units).Plan();
+ var planSeconds = watch.Elapsed.TotalSeconds;
+ var planned = proposal.Plates[0];
+ var result = planned.Result;
+ var label = $"{Path.GetFileNameWithoutExtension(path)} plate {number} ({plate.Parts.Count} parts, {nest.Thickness} in) w={weight}";
+ if (!proposal.CanApply && !proposal.CanApplyWithWarnings)
+ return $"{label}: {result.Status}, not applied: " + string.Join(" | ", result.Findings.Take(4).Select(f => f.Message));
+ var commit = proposal.Apply(acceptWarnings: true);
+ if (commit.Status != CuttingCommitStatus.Applied)
+ return $"{label}: {result.Status}, apply {commit.Status}";
+ var cut = CutParameters.Default;
+ cut.Units = nest.Units;
+ var simulation = CutSimulation.Build(plate, cut);
+ var zone = double.TryParse(Environment.GetEnvironmentVariable("OPENNEST_HEAT_ZONE"),
+ System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var size) ? size : 4.0;
+ var (p95, p75) = Zones(plate, simulation, nest, zone, Environment.GetEnvironmentVariable("OPENNEST_HEAT_DUMP") is { Length: > 0 } dump
+ ? Path.Combine(dump, $"{Path.GetFileNameWithoutExtension(path)}-{number}-w{weight}") : null);
+ return $"{label}: {result.Status}{(result.IsSafestRouteFallback ? " (safest route)" : "")}"
+ + $"{(planned.KeptCurrentOrder ? " (kept order)" : "")}, travel {result.RapidDistance:0.0}, "
+ + $"cut {simulation.TotalTime.TotalSeconds:0.0} s, raises {result.HeadRaises}, heat raises {result.HeatRaises}, "
+ + $"zone P95 {p95:0.0}, P75 {p75:0.0}, expansions {result.Expansions}, plan {planSeconds:0.0} s";
+ }
+
+ // The hottest average over each 4 in square during the cut, as the 95th and 75th percentile
+ // over squares. Cells whose slug fell away do not count.
+ internal static (double P95, double P75) Zones(Plate plate, CutSimulation simulation, Nest nest, double zoneInches = 4,
+ string? dump = null)
+ {
+ if (dump != null)
+ File.WriteAllLines(dump + "-order.csv", plate.Parts.Select(p => FormattableString.Invariant(
+ $"{p.BoundingBox.Center.X},{p.BoundingBox.Center.Y},{p.BoundingBox.Length},{p.BoundingBox.Width}")));
+ var heat = new PlateHeatSimulation(plate, simulation, new ThermalParameters
+ {
+ Material = ThermalMaterial.ForName($"{nest.Material?.Name} {nest.Material?.Grade}"),
+ Thickness = nest.Thickness,
+ Units = nest.Units,
+ SupportBed = plate.SupportBed,
+ });
+ var zone = nest.Units == Units.Millimeters ? zoneInches * 25.4 : zoneInches;
+ var per = System.Math.Max(1, (int)System.Math.Round(zone / heat.CellSize));
+ var zoneColumns = (heat.Columns + per - 1) / per;
+ var zoneRows = (heat.Rows + per - 1) / per;
+ var hottest = new double[zoneColumns * zoneRows];
+ var seen = new bool[hottest.Length];
+ var sums = new double[hottest.Length];
+ var counts = new int[hottest.Length];
+ var end = simulation.TotalTime.TotalSeconds + 30;
+ for (var t = 1.0; t <= end; t += 1.0)
+ {
+ heat.AdvanceTo(TimeSpan.FromSeconds(t));
+ Array.Clear(sums);
+ Array.Clear(counts);
+ var temperatures = heat.Temperatures;
+ for (var row = 0; row < heat.Rows; row++)
+ for (var column = 0; column < heat.Columns; column++)
+ {
+ var index = row * heat.Columns + column;
+ if (heat.IsRemoved(index))
+ continue;
+ var z = row / per * zoneColumns + column / per;
+ sums[z] += temperatures[index];
+ counts[z]++;
+ }
+ for (var z = 0; z < hottest.Length; z++)
+ if (counts[z] > 0)
+ {
+ seen[z] = true;
+ hottest[z] = System.Math.Max(hottest[z], sums[z] / counts[z]);
+ }
+ }
+ if (dump != null)
+ {
+ var peaks = heat.Peaks.ToArray();
+ File.WriteAllLines(dump + "-peaks.csv", Enumerable.Range(0, heat.Rows).Select(row => string.Join(",",
+ Enumerable.Range(0, heat.Columns).Select(column => heat.IsRemoved(row * heat.Columns + column) ? "nan"
+ : peaks[row * heat.Columns + column].ToString(System.Globalization.CultureInfo.InvariantCulture)))));
+ }
+ var values = hottest.Where((_, z) => seen[z]).OrderBy(v => v).ToArray();
+ return values.Length == 0 ? (0, 0)
+ : (values[(int)(0.95 * (values.Length - 1))], values[(int)(0.75 * (values.Length - 1))]);
+ }
+}
diff --git a/OpenNest/Controls/CuttingPanel.cs b/OpenNest/Controls/CuttingPanel.cs
index cb4096d8..37ac4e03 100644
--- a/OpenNest/Controls/CuttingPanel.cs
+++ b/OpenNest/Controls/CuttingPanel.cs
@@ -39,6 +39,7 @@ namespace OpenNest.Controls
private readonly ComboBox cboLabelMode;
private readonly NumericUpDown nudPierceClearance;
private readonly NumericUpDown nudPierceDiameter;
+ private readonly NumericUpDown nudHeatWeight;
private CuttingParameters loaded;
@@ -319,6 +320,20 @@ namespace OpenNest.Controls
nudPierceClearance.ValueChanged += (s, e) => OnParametersChanged();
nudPierceDiameter.ValueChanged += (s, e) => OnParametersChanged();
+ // Heat: the part order spreads the cut's heat; see docs/plate-heat-map.md.
+ AddSection("Heat");
+
+ var heatGrid = ControlFactory.SettingsGrid(0);
+ nudHeatWeight = CreateNumeric(0, 0.01);
+ nudHeatWeight.Maximum = 100;
+ AddRow(heatGrid, "Spread heat (s per °C):", nudHeatWeight, 0, "0 = off");
+ toolTip.SetToolTip(nudHeatWeight,
+ "Plan Cutting cuts the parts in blocks and moves to a cooler block when the heat estimated where "
+ + "the next part is cut, times this many seconds per degree, outweighs the extra travel. A move "
+ + "across parts already cut raises the head. 0 orders the parts by travel alone.");
+ column.Controls.Add(heatGrid);
+ nudHeatWeight.ValueChanged += (s, e) => OnParametersChanged();
+
Controls.Add(layout);
// Sized for the type with the most fields, so picking one never moves the sections below;
@@ -391,6 +406,7 @@ namespace OpenNest.Controls
parameters.TabSizeMaxWidth = (double)nudTabSizeMax.Value;
parameters.SliceTippingSlugs = chkSliceSlugs.Checked;
parameters.LabelMode = (PartLabelMode)System.Math.Max(0, cboLabelMode.SelectedIndex);
+ parameters.HeatWeight = (double)nudHeatWeight.Value;
return parameters;
}
@@ -420,6 +436,7 @@ namespace OpenNest.Controls
cboLabelMode.SelectedIndex = System.Enum.IsDefined(p.LabelMode) ? (int)p.LabelMode : (int)PartLabelMode.Off;
nudPierceClearance.Value = Clamp(nudPierceClearance, p.PierceClearance);
nudPierceDiameter.Value = Clamp(nudPierceDiameter, p.PierceDiameter);
+ nudHeatWeight.Value = Clamp(nudHeatWeight, p.HeatWeight);
chkRoundLeadInAngles.Checked = p.RoundLeadInAngles;
nudLeadInAngleIncrement.Value = Clamp(nudLeadInAngleIncrement, p.LeadInAngleIncrement);
nudLeadInAngleIncrement.Enabled = p.RoundLeadInAngles;
diff --git a/OpenNest/Forms/CuttingInspectionPanel.cs b/OpenNest/Forms/CuttingInspectionPanel.cs
index 8acfc65e..3072c279 100644
--- a/OpenNest/Forms/CuttingInspectionPanel.cs
+++ b/OpenNest/Forms/CuttingInspectionPanel.cs
@@ -838,7 +838,7 @@ internal sealed class CuttingInspectionPanel : UserControl
// Capture on the owner thread; no worker recapture of the live plate or settings.
var batch = CuttingPlanBatch.Capture(plates, parameters, keepOrderCheckBox.Checked, plateNumbers,
budgetMultiplier: CuttingPlanBatch.ClampBudgetMultiplier(Properties.Settings.Default.CuttingPlanEffort),
- units: units);
+ units: units, cutTimes: SavedCutParameters.Load(units));
var run = ++generation;
var completion = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
PlanningTask = completion.Task;
@@ -1006,6 +1006,9 @@ internal sealed class CuttingInspectionPanel : UserControl
var rapid = planned.Result.RapidDistance.ToString("0.#", CultureInfo.CurrentCulture);
var raises = planned.Result.HeadRaises == 0 ? ""
: $" {Count(planned.Result.HeadRaises, "rapid")} must raise the head over cut parts (listed below).";
+ if (planned.Result.HeatRaises != 0)
+ raises += $" {Count(planned.Result.HeatRaises, "rapid")} {(planned.Result.HeatRaises == 1 ? "raises" : "raise")} "
+ + "the head to jump to a cooler area (listed below).";
return $"{name}: {Count(planned.PartCount, "part")}, {order}, {rapid} {UnitsHelper.GetShortString(units)} of rapids."
+ raises;
}
diff --git a/docs/cutting-planner.md b/docs/cutting-planner.md
index a650a39a..95f50885 100644
--- a/docs/cutting-planner.md
+++ b/docs/cutting-planner.md
@@ -260,7 +260,7 @@ wider than that, no two parts in one cell, at least a quarter of the cells fille
as interleaved rows fill half), is toured as a serpentine: line by line, alternating
direction, along whichever axis and from whichever corner gives the shortest route
from the start point. Its 2-opt and Or-opt passes would grow with the square of the
-part count. Replans after a learned rule use the plain tour. If a part on that order cannot be
+part count. Replans after a learned rule use the plain tour (or its heat blocks, below). If a part on that order cannot be
reached without crossing parts already cut, the search learns "cut this part
before those", backs up to just before the earliest of them and re-plans the rest
from the tool position there; parts cut before that point are kept. The last of them was
@@ -913,6 +913,32 @@ overlap check may likewise be accepted with warnings. `CanApply` and parameterle
explicit review path. `CuttingPlanService.Apply` still rejects best-effort results directly.
Acceptance never skips the separate pre-post checks or grants posting consent.
+### Heat blocks
+
+With `CuttingParameters.HeatWeight` above 0 (seconds of travel per °C, off by default; saved per
+material and thickness, see [machine cutting defaults](machine-cutting-defaults.md)), `Tour` may
+replace the plain tour of a plate without nested parts by an order that spreads the cut's heat
+(`CuttingHeatOrder`). Large grids keep their serpentine. Candidates are the plain tour, two
+cutting fronts (the plate split where half the cut length lies on each side, along its long and
+its short axis, each half toured toward the split) and blocks on 2x2, 3x3, 4x4 and 6x6 grids,
+each block toured with the plain tour from its corner nearest the start. Blocks are interleaved
+greedily: each step takes the ready block head with the least cost, the current block first on
+ties. A move to another block whose straight rapid crosses the box of a part already cut is a
+heat jump. Each order is scored as travel seconds, plus 2 s per jump, plus the weight times the
+temperature estimated at each part when the tool reaches it, and the cheapest wins; ties keep the
+plain tour. The estimate is the removed sequencer's
+([plate heat map](plate-heat-map.md#sequencing)): a Gaussian per finished part, spreading and
+fading with time, fed by the Cut Simulator's feeds and pierce (`CuttingPlanRequest.CutTimes`,
+`CutParameters.Default` when not given).
+
+The arrival rapid of a part the order reaches by a heat jump is raised in the strict search
+(`ReleasedContourState.RaisesArrival`), so its crossings are not findings, and marked `HEAD RAISE`
+before replay (`RaisedRapids.MarkHeatJumps`). Such a jump is designed: it is counted in
+`CuttingPlanResult.HeatRaises`, not `HeadRaises`, and each is listed as a note. A part with a
+locked program or a cut-off cannot carry the mark, so a move to one that crosses cut parts costs so
+much it is taken only when nothing else is ready, and then is checked head-down as before. With the
+weight at 0 nothing here runs, and plans are byte-identical to the plain tour's.
+
### Safest-route fallback when the search runs out
Planning ranks routes safest first, then fastest. The strict search only accepts a route that
@@ -942,8 +968,9 @@ before the rapid in the part's program, which saves with the nest. A sub-program
so it is never marked: when the rapid arrives at a hole sub-program (a round hole is cut as one),
the comment goes directly before the part's own call, and the call's arrival rapid is the raised
one (`ExecutionMotion.CallCode` names the call a sub-program's motions run in). Apart from the
-slug exits below, this is the only place a raise is added, so a plate the strict search can plan
-never gets one: it is the last resort for a route no search kept head-down, not a shortcut.
+slug exits below and the heat jumps of an opt-in heat weight ([Heat blocks](#heat-blocks)), this is
+the only place a raise is added, so a plate the strict search can plan never gets one: it is the
+last resort for a route no search kept head-down, not a shortcut.
A cutout's lead-out ends in its slug, which is cut free and may drop or tip, so the rapid after
it always leaves over the cutout just cut. Emission therefore marks that rapid to raise the head
diff --git a/docs/machine-cutting-defaults.md b/docs/machine-cutting-defaults.md
index 00df1de9..42b28ace 100644
--- a/docs/machine-cutting-defaults.md
+++ b/docs/machine-cutting-defaults.md
@@ -28,7 +28,7 @@ save them on close; thicknesses matching none stay blank.
Every setting in Plan Cutting's Cutting Parameters dialog and the Place Lead-in panel is kept on
the nest's machine thickness: leads on the Outside Cuts and Inside Cuts tabs, lead-in angle
-rounding, tabs, [slug slicing](support-tabs.md#slug-slices), [part label etching](label-box.md#etching-the-label) (off, part number, or part number and bend groups) and pierce on the Tabs & Pierce tab
+rounding, tabs, [slug slicing](support-tabs.md#slug-slices), [part label etching](label-box.md#etching-the-label) (off, part number, or part number and bend groups), pierce and the [heat weight](cutting-planner.md#heat-blocks) on the Tabs & Pierce tab
(`ThicknessConfig.Cutting`). So 0.25 in can
tab parts while 0.5 in tabs none, and in Database mode every workstation gets the same
settings. The dialog names what it edits above its fields ("Saved for Fiber 1 · Mild Steel A36
diff --git a/docs/plate-heat-map.md b/docs/plate-heat-map.md
index 14e0622c..8771dfab 100644
--- a/docs/plate-heat-map.md
+++ b/docs/plate-heat-map.md
@@ -3,7 +3,7 @@
`OpenNest.Core/CNC/Thermal/PlateHeatSimulation.cs` estimates how heat builds up in the sheet
while a [cut simulation](cut-time-estimates.md) plays. The Cut Simulator shows it under the cut
trail (Heat: Now or Peak so far). It is a display and analysis aid and never changes the plate;
-a removed heat-aware sequencer used a cheaper estimate of the same physics ([Sequencing](#sequencing)).
+Plan Cutting's opt-in heat weight orders parts with a cheaper estimate of the same physics ([Sequencing](#sequencing)).
## Model
@@ -120,39 +120,37 @@ bed, and its heat label says whether the sheet is cooled by air only or by air a
## Sequencing
-A heat-aware part sequencer was tried and removed: the cut order comes from Plan Cutting or the
-user, and OpenNest keeps no automatic part sequencers (the code is in git history before the
-commit that removed them). A heat-aware order belongs in Plan Cutting's search once FLIR
-thermal-camera readings calibrate the model. What was tried:
+Plan Cutting's part order spreads the heat when the cutting parameters set `HeatWeight` (seconds
+of travel per °C, 0 = off, saved per material and thickness on the Tabs & Pierce tab). The order
+is still Plan Cutting's: it cuts the parts in blocks or from two fronts and moves to a cooler block
+when the estimated heat outweighs the travel; a move across parts already cut raises the head
+(`HEAD RAISE`, counted as heat raises). See [heat blocks](cutting-planner.md#heat-blocks). This
+simulation only scores finished plans; the order uses a cheaper estimate, ported from the
+sequencer removed earlier:
-- Order: a forward greedy from the plate's origin corner. The next part was the one with the least
- travel seconds plus `HeatWeight` (seconds per °C, 0.15 by default) times the estimated
- temperature at its center when the tool got there. Without a thickness it was nearest neighbor.
-- Estimate: each finished part left a Gaussian blob of its energy
- (`AbsorbedPower` times its torch-on time), as wide as the part to begin with (a quarter of its
- squared diagonal), widening by 4αΔt and fading with the surface loss; only the latest 200 parts
- count. Torch-on time comes from each part's cut length and pierces at stand-in feeds by
- thickness: 400 in/min up to 0.135 in, 150 up to 0.26 in, 80 above, a 0.5 s pierce up to 0.26 in
- and 1.5 s above, and 3000 in/min travel.
+- Each finished part leaves a Gaussian blob of its energy (`AbsorbedPower` times its torch-on
+ time), as wide as the part to begin with (a quarter of its squared diagonal), widening by 4αΔt
+ and fading with the surface loss; only the latest 200 parts count.
+- Torch-on time comes from each part's cut length and pierces at the Cut Simulator's feeds and
+ pierce time (`CutParameters`, this PC's saved values in the desktop, `CutParameters.Default`
+ elsewhere), and travel time at its rapid rate.
-Why it did not help: Plan Cutting plans its own shortest tour (nearest neighbor, 2-opt, Or-opt),
-which already traveled a fraction of the removed row-based `Advanced` sequencer's distance, so the
-heat order's travel savings over `Advanced` did not carry over. And its
-strict search refuses head-down rapids over parts already cut free. A heat-spreading order skips
-neighbors and comes back to them across cut parts, so the search stalls, learns rules, and ends on
-its shortest tour or the safest-route fallback; a heat order used only where it does not stall
-moved the zone metric by noise (±3-5%). Kept as given through Plan Cutting, the heat order does
-spread the heat, at this cost against the planned shortest tour (2ER and N26-2GT, weights 0.1-0.4,
-stand-in feeds):
+Measured with `HeatOrderMeasurementTests` (opt-in, `OPENNEST_HEAT_PLATES`), default timing
+(100 in/min cut, 300 in/min rapid, 0.5 s pierce), against the plan with the weight off. The zone
+metric is the hottest average over each 4 in square during the cut, as a percentile over zones:
-| Plate | Travel | Cut time | Head raises (tour: 0) | Zone P95 | Zone P75 |
-|-------|--------|----------|-----------------------|----------|----------|
-| 2ER plate 1 (130 parts, 0.25 in) | +52 to +82% | +0.8 to +1.2% | 59-78 | −14 to −18% | −18 to −23% |
-| N26-2GT plate 1 (112 parts, 0.09 in) | +50 to +65% | +2.3 to +3.1% | 54-62 | −24 to −25% | −26 to −28% |
-| N26-2GT plate 2 (148 parts, 0.09 in) | +64 to +102% | +1.8 to +2.8% | 53-75 | −12 to −20% | −18 to −24% |
+| Plate | Weight | Travel | Cut time | Heat raises | Zone P95 | Zone P75 |
+|-------|--------|--------|----------|-------------|----------|----------|
+| Dense small parts (121 parts, 0.12 in) | 0.03 | +162% | +7.8% | 25 | −30% | −30% |
+| | 0.1 | +237% | +11.4% | 37 | −37% | −37% |
+| | 0.3 | +338% | +16.2% | 57 | −34% | −34% |
+| 130 parts, 0.25 in | 0.1 | 0 | 0 | 0 | 0 | 0 |
+| | 1 | +51% | +5.1% | 41 | −10% | −11% |
+| 110 parts, 0.12 in, locked programs | 0.03 | +98% | +1.4% | 0 | −23% | −13% |
+| | 0.1 | +303% | +4.4% | 0 | −29% | −24% |
-The zone metric is the hottest average over each 4 in square during the cut, as a percentile over
-zones; pierces and hole clusters inside one part set the hottest cell whatever the order. The head
-raises are the safest-route fallback's last-resort markers, which the strict search never adds, so
-a heat order that spreads heat would need designed head raises (or rapids routed around cut parts).
-Revisit once FLIR readings calibrate the absorbed power and the feeds.
+No plan gained a fallback head raise. Thin sheets of dense small parts gain most; thick sheets,
+where the sheet carries the heat away faster than the order moves, barely change below a weight of
+1. Parts with locked programs cannot carry a raise, so the order reaches them head-down. Above
+about 0.3 the extra jumps stop helping. Calibrate the absorbed power and feeds against FLIR
+thermal-camera readings before tuning further.