fix(production): correct blueprint power and planner edge cases

Read the Advanced Mining Machine speed stored with station settings in prebuild
and blueprint captures, and count charging power nodes such as Satellite
Substations at their idle draw. Skip recipes that consume their own product when
choosing an item's default recipe, so Refined Oil uses Plasma Refining instead
of Reforming Refine.

Run each planner recipe in one proliferation mode and report conflicting
explicit modes, keep material flows for recipe types the catalog does not know,
and attribute receiver warnings to their recipe. Compare simplex ratio ties
relatively and drive out near-zero artificials without amplifying residuals.
Bound the steady-state reduction so lossless cycles cannot stall blueprint
descriptions, and choose power units after rounding.

Remove redundant code: share the numeric and flow helpers, and drop the unused
IsExcessIntermediate threshold, legacy constructor and Capture overloads, the
multi-field updater, and the unused proliferator source table.
This commit is contained in:
soarqin committed 2026-10-25 22:01:05 +08:00
1 parent 6345562c66
commit f0773ffb9b
24 files changed
+463 -404

No files matched your search

+14 -5
View File
@@ -29,6 +29,7 @@ internal static class TwoPhaseSimplex
{
private const double PivotTolerance = 1e-10;
private const double ReducedTolerance = 1e-8;
private const double RatioTieTolerance = 1e-9;
internal static LinearSolveResult Solve(double[,] coefficients, double[] rightHandSide,
IReadOnlyList<double[]> objectives, int iterationBudget, CancellationToken cancellation)
@@ -102,12 +103,19 @@ internal static class TwoPhaseSimplex
if (Math.Abs(tableau[row, width]) > ReducedTolerance)
return new LinearSolveResult(LinearSolveStatus.Infeasible);
// The remaining artificial counts as zero. Pivot it out on its largest coefficient at exactly zero so a
// tiny residual divided by a tiny coefficient cannot move the other rows.
var pivotColumn = -1;
for (var column = 0; column < columnCount; column++)
{
if (isBasic[column] || Math.Abs(tableau[row, column]) <= PivotTolerance) continue;
Pivot(tableau, basis, isBasic, row, column);
break;
if (pivotColumn < 0 || Math.Abs(tableau[row, column]) > Math.Abs(tableau[row, pivotColumn]))
pivotColumn = column;
}
if (pivotColumn < 0) continue;
tableau[row, width] = 0;
Pivot(tableau, basis, isBasic, row, pivotColumn);
}
var optimizedObjectives = new List<double[]>();
@@ -170,9 +178,10 @@ internal static class TwoPhaseSimplex
var coefficient = tableau[row, entering];
if (coefficient <= PivotTolerance) continue;
var ratio = Math.Max(0, tableau[row, rightColumn]) / coefficient;
if (ratio < minRatio - ReducedTolerance ||
Math.Abs(ratio - minRatio) <= ReducedTolerance &&
(leaving < 0 || basis[row] < basis[leaving]))
// Ties are relative: an absolute tolerance would merge distinct small ratios and leave a row infeasible.
var tie = leaving < 0 ? 0 : RatioTieTolerance * Math.Max(ratio, minRatio);
if (ratio < minRatio - tie ||
Math.Abs(ratio - minRatio) <= tie && (leaving < 0 || basis[row] < basis[leaving]))
{
minRatio = ratio;
leaving = row;