mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-25 10:07:40 -05:00
test(corpus): score a Ready plan with a lead off the plate as blocked
The corpus ranked plates by plan outcome alone, and before db4b573e the
planner called a plan with a lead-in pierced past the sheet edge Ready,
so N26-2D6 (added to the corpus for that bug) could not catch it coming
back. A Ready plate whose planned lead-in or lead-out runs past the
plate's box now scores LeadOffPlate, a blocked outcome. It is judged on
the plate, not on what the planner was told, so losing the planner's
sheet check fails here. With that check disabled N26-2D6 plate 2 scores
LeadOffPlate; with it every corpus plate keeps its outcome.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db4b573e3b
commit
93fa24a9d7
2 files changed
+24
-7
No files matched your search
@@ -696,7 +696,7 @@ public partial class ProblemNestRegressionTests(ITestOutputHelper output)
|
||||
{
|
||||
var planned = CuttingPlanBatch.Capture([plate], plate.CuttingParameters ?? DefaultParameters(),
|
||||
preservePartOrder: false, [number], cancellation.Token).Plan(token: cancellation.Token).Plates[0];
|
||||
return (planned.Result.Status == CuttingPlanStatus.Canceled ? Timeout : Outcome(planned), planned);
|
||||
return (planned.Result.Status == CuttingPlanStatus.Canceled ? Timeout : Outcome(planned, plate), planned);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -763,9 +763,24 @@ public partial class ProblemNestRegressionTests(ITestOutputHelper output)
|
||||
&& result.Status is CuttingPlanStatus.Ready or CuttingPlanStatus.BestEffort
|
||||
? (double)result.Expansions / budget : null;
|
||||
|
||||
// Ready means replayed and overlap-clear; a ready route with overlapping parts is still blocked.
|
||||
internal static string Outcome(CuttingPlanPlateResult planned) =>
|
||||
planned.IsReady ? "Ready" : planned.IsRouteReady ? "Overlap" : planned.Result.Status.ToString();
|
||||
// Ready means replayed and overlap-clear; a ready route with overlapping parts is still blocked,
|
||||
// and so is one with a lead off the plate (given the plate), which cuts air or the table.
|
||||
internal static string Outcome(CuttingPlanPlateResult planned, Plate plate = null) =>
|
||||
planned.IsReady ? (plate != null && LeadsOffPlate(planned, plate) ? LeadOffPlate : "Ready")
|
||||
: planned.IsRouteReady ? "Overlap" : planned.Result.Status.ToString();
|
||||
|
||||
internal const string LeadOffPlate = "LeadOffPlate";
|
||||
|
||||
// Whether any planned lead-in or lead-out of a part runs past the plate's box. Judged on the
|
||||
// plate itself, not on what the planner was told, so losing the planner's sheet check fails here.
|
||||
internal static bool LeadsOffPlate(CuttingPlanPlateResult planned, Plate plate)
|
||||
{
|
||||
var sheet = plate.BoundingBox(includeParts: false);
|
||||
return planned.Result.ProposedOrder.Any(proposal => !proposal.IsCutOff
|
||||
&& proposal.Execution.Motions.Any(motion => !motion.Rapid && motion.Curve != null
|
||||
&& motion.Layer is OpenNest.CNC.LayerType.Leadin or OpenNest.CNC.LayerType.Leadout
|
||||
&& OpenNest.CNC.CuttingPlanning.LeadPathValidator.OffSheet(motion, sheet) != null));
|
||||
}
|
||||
|
||||
internal static int Rank(string outcome) => outcome switch
|
||||
{
|
||||
@@ -1104,9 +1119,10 @@ public class ProblemNestBaselineTests
|
||||
[Fact]
|
||||
public void Rank_OrdersReadyAboveBestEffortAboveBudgetAboveBlockedAboveTimeout()
|
||||
{
|
||||
var ranks = new[] { "Ready", "BestEffort", "NoSolutionWithinBudget", "UnsupportedGeometry", "Overlap", "Timeout" }
|
||||
var ranks = new[] { "Ready", "BestEffort", "NoSolutionWithinBudget", "UnsupportedGeometry", "Overlap",
|
||||
"LeadOffPlate", "Timeout" }
|
||||
.Select(ProblemNestRegressionTests.Rank).ToArray();
|
||||
|
||||
Assert.Equal([3, 2, 1, 0, 0, -1], ranks);
|
||||
Assert.Equal([3, 2, 1, 0, 0, 0, -1], ranks);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,8 @@ as `Timeout`, so a plate that never finishes cannot hang the run.
|
||||
|
||||
Each plate is ranked: `Ready` (replayed with no overlaps) above `BestEffort` above
|
||||
`NoSolutionWithinBudget` above every blocked outcome (`UnsupportedGeometry`,
|
||||
`ConstraintConflict`, `InvalidInput`, `Overlap`) above `Timeout`. The test fails when a plate ranks below its
|
||||
`ConstraintConflict`, `InvalidInput`, `Overlap`, `LeadOffPlate`: a Ready plan with a lead-in or
|
||||
lead-out past the plate's box) above `Timeout`. The test fails when a plate ranks below its
|
||||
baseline, when a nest has no baseline, or when the baseline's plate numbers differ from the
|
||||
nest's. A different outcome at the same or a better rank is only reported. When it is
|
||||
intended, update the baseline.
|
||||
|
||||
Reference in new issue
Block a user