Ejemplo n.º 1
0
        public void ExportXYZ(float scale, int startYear, int endYear, int gender)
        {
            var frame  = Frame.CreateEmpty <int, int>();
            var length = AgeProbability.Source[gender, 0].Count;

            frame.AddColumn(-1, AgeProbability.Source[gender, 0]);

            for (int y = startYear; y <= endYear; y++)
            {
                var index = AgeProbability.YearIndex(y);
                frame.AddColumn(index, AgeProbability.Weights[gender, index]);
            }
            frame.SaveCsv($"./AgeTests/3d-{Constants.DisplayNames[gender]}.csv");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Warms up a society by scale. i.e. 0.1 will start a population on a 10% scale.
        /// </summary>
        /// <param name="scale"></param>
        public void Warmup(float scale)
        {
            // Recreate Total population by year counting number of people per age group.
            var index = AgeProbability.YearIndex(Environment.StartDate.Year);

            // Traverse all age categories for males and females.
            for (int age = 0; age < AgeProbability.Source[0, 0].Count; age++)
            {
                var people = (int)(AgeProbability.Weights[Constants.idx_gender_male, index][age] * scale);
                for (int j = 0; j < people; j++)
                {
                    new Person(Environment, age);
                }
            }
        }
Ejemplo n.º 3
0
        public void AgeDistribution(float scale, int startYear, int endYear, int gender)
        {
            // Arrange
            var env = new SimSharp.ThreadSafeSimulation(42);

            for (int y = startYear; y <= endYear; y++)
            {
                var index = AgeProbability.YearIndex(y);
                Helpers.Sample(this, scale, y.ToString(), gender,
                               AgeProbability.Source[gender, index],
                               AgeProbability.Weights[gender, index],
                               "Age distribution"
                               );
            }
        }