/// <summary> /// Simulate a test population until all original people are deceased and use the /// final population distribution as a basis for distributing newly created populations. /// </summary> private static IReadOnlyList <double> GetDistributionRatios(RacialTemplate racialTemplate) { long testPopulation = 1000000; var ageRange = (double)racialTemplate.CohortTemplates.Sum(x => (x.PastEndAge - x.StartAge).TickOffset); var pops = racialTemplate.CohortTemplates .Select(cohortTemplate => { var cohortAgeRange = (double)(cohortTemplate.PastEndAge - cohortTemplate.StartAge).TickOffset; return((long)((double)testPopulation * cohortAgeRange / ageRange)); }); var testCohorts = new CohortCollection(racialTemplate, pops); var maxDate = new TimePoint(0) + testCohorts.Cohorts.Last().PastEnd; for (var date = new TimePoint(0); date < maxDate; date += TimeOffset.OneTick) { testCohorts = new CohortCollection(racialTemplate, PopulationUtility.ProcessTick(testCohorts, out var _)); } var finalTestPopulation = (double)testCohorts.TotalPopulation; return(testCohorts.Cohorts .Select(x => (double)x.Population / finalTestPopulation) .AsReadOnlyList()); }
private CohortCollection(CohortCollection that, IEnumerable <long> populations) : this(that.RacialTemplate, populations.Select((pop, i) => new CohortImpl(that.RacialTemplate.CohortTemplates[i], pop)).ToArray(), that.m_distributionRatios) { }
private CohortCollection(CohortCollection that) : this(that.RacialTemplate, that.m_cohorts.Select(x => x.Clone()).ToArray(), that.m_distributionRatios) { }