示例#1
0
        public void Run(Clock clock, IPopulationState state, IDimensions dimensions)
        {
            var s = state;
            var t = clock.Current;

            if (clock.IsFirstTimestep)
            {
                double globalpopulation = 0.0;

                foreach (var r in dimensions.GetValues <Region>())
                {
                    s.population[t, r]    = s.pop0[r];
                    s.populationin1[t, r] = s.population[t, r] * 1000000.0;

                    globalpopulation = globalpopulation + s.populationin1[t, r];
                }

                s.globalpopulation[t] = globalpopulation;
            }
            else
            {
                var globalPopulation = 0.0;
                // Calculate population
                foreach (var r in dimensions.GetValues <Region>())
                {
                    s.population[t, r] = (1.0 + 0.01 * s.pgrowth[t - 1, r]) * (s.population[t - 1, r] +
                                                                               (
                                                                                   (t >= Timestep.FromSimulationYear(40)) && !s.runwithoutpopulationperturbation ? (s.enter[t - 1, r] / 1000000.0) - (s.leave[t - 1, r] / 1000000.0) - (s.dead[t - 1, r] >= 0 ? s.dead[t - 1, r] / 1000000.0 : 0) : 0
                                                                               )
                                                                               );

                    if (s.population[t, r] < 0)
                    {
                        s.population[t, r] = 0.000001;
                    }
                    //raise new Exception;

                    s.populationin1[t, r] = s.population[t, r] * 1000000.0;
                    globalPopulation      = globalPopulation + s.populationin1[t, r];
                }
                s.globalpopulation[t] = globalPopulation;
            }
        }
示例#2
0
        public void Run(Clock clock, IPopulationState state, IDimensions dimensions)
        {
            var s = state;
            var t = clock.Current;

            if (clock.IsFirstTimestep)
            {
                double globalpopulation = 0.0;

                foreach (var r in dimensions.GetValues<Region>())
                {
                    s.population[t, r] = s.pop0[r];
                    s.populationin1[t, r] = s.population[t, r] * 1000000.0;

                    globalpopulation = globalpopulation + s.populationin1[t, r];
                }

                s.globalpopulation[t] = globalpopulation;
            }
            else
            {
                var globalPopulation = 0.0;
                // Calculate population
                foreach (var r in dimensions.GetValues<Region>())
                {
                    s.population[t, r] = (1.0 + 0.01 * s.pgrowth[t - 1, r]) * (s.population[t - 1, r] +
                        (
                        (t >= Timestep.FromSimulationYear(40)) && !s.runwithoutpopulationperturbation ? (s.enter[t - 1, r] / 1000000.0) - (s.leave[t - 1, r] / 1000000.0) - (s.dead[t - 1, r] >= 0 ? s.dead[t - 1, r] / 1000000.0 : 0) : 0
                          )
                    );

                    if (s.population[t, r] < 0)
                        s.population[t, r] = 0.000001;
                    //raise new Exception;

                    s.populationin1[t, r] = s.population[t, r] * 1000000.0;
                    globalPopulation = globalPopulation + s.populationin1[t, r];
                }
                s.globalpopulation[t] = globalPopulation;

            }
        }