Economy checks: an undefined radius refuses; factor refusal says why
This commit is contained in:
parent
c6c8b4465b
commit
6b89019c02
2 changed files with 2 additions and 1 deletions
|
|
@ -317,6 +317,7 @@ public static class EconomyChecks
|
||||||
var component = Enumerable.Range(0, n).Where(i => reach[start, i] && reach[i, start]).ToList();
|
var component = Enumerable.Range(0, n).Where(i => reach[start, i] && reach[i, start]).ToList();
|
||||||
foreach (var i in component) done[i] = true;
|
foreach (var i in component) done[i] = true;
|
||||||
var rho = Irreducible(a, component);
|
var rho = Irreducible(a, component);
|
||||||
|
if (double.IsNaN(rho)) rho = double.PositiveInfinity;
|
||||||
if (rho > best) { best = rho; bestComponent = component; }
|
if (rho > best) { best = rho; bestComponent = component; }
|
||||||
}
|
}
|
||||||
return (best, bestComponent);
|
return (best, bestComponent);
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ public sealed class EconomyChecksTests
|
||||||
public void ProductiveRefusesFactorsBelowOne()
|
public void ProductiveRefusesFactorsBelowOne()
|
||||||
{
|
{
|
||||||
using var f = new EconomyFixture();
|
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 { WorkforceFactor = 0.5 }));
|
||||||
Assert.Throws<ArgumentException>(() => EconomyChecks.Productive(f.Cache, new EconomyLoad { UpkeepFactor = double.NaN }));
|
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 }));
|
Assert.Empty(EconomyChecks.Productive(f.Cache, new EconomyLoad { InputFactor = 1, WorkforceFactor = 1, UpkeepFactor = 1 }));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue