Economy checks: an undefined radius refuses; factor refusal says why

This commit is contained in:
soul 2026-10-23 04:24:32 +02:00
commit 6b89019c02
2 changed files with 2 additions and 1 deletions

View file

@ -317,6 +317,7 @@ public static class EconomyChecks
var component = Enumerable.Range(0, n).Where(i => reach[start, i] && reach[i, start]).ToList();
foreach (var i in component) done[i] = true;
var rho = Irreducible(a, component);
if (double.IsNaN(rho)) rho = double.PositiveInfinity;
if (rho > best) { best = rho; bestComponent = component; }
}
return (best, bestComponent);

View file

@ -220,7 +220,7 @@ public sealed class EconomyChecksTests
public void ProductiveRefusesFactorsBelowOne()
{
using var f = new EconomyFixture();
Assert.Throws<ArgumentException>(() => EconomyChecks.Productive(f.Cache, new EconomyLoad { InputFactor = 0.5 }));
Assert.Contains("at least 1", Assert.Throws<ArgumentException>(() => EconomyChecks.Productive(f.Cache, new EconomyLoad { InputFactor = 0.5 })).Message);
Assert.Throws<ArgumentException>(() => EconomyChecks.Productive(f.Cache, new EconomyLoad { WorkforceFactor = 0.5 }));
Assert.Throws<ArgumentException>(() => EconomyChecks.Productive(f.Cache, new EconomyLoad { UpkeepFactor = double.NaN }));
Assert.Empty(EconomyChecks.Productive(f.Cache, new EconomyLoad { InputFactor = 1, WorkforceFactor = 1, UpkeepFactor = 1 }));