Exemple #1
0
 def test_new_model_has_correct_first_generation(self):
     model = PopulationModel(ModelRunOptions(1, 2, 3, 100, 0, 0, 0, 0, 0))
     first_generation = model.get_generation(0)
     self.assertEqual(first_generation.juveniles, 1)
     self.assertEqual(first_generation.adults, 2)
     self.assertEqual(first_generation.seniles, 3)
     self.assertEqual(first_generation.disease_rate, 0)
Exemple #2
0
 def test_model_runs_to_second_generation_with_disease(self):
     model = PopulationModel(
         ModelRunOptions(10, 10, 10, 1, 0.5, 0.5, 0.5, 2, 1))
     model.run_all_generations()
     self.assertEqual(model.get_generations_count(), 2)
     second_generation = model.get_generation(1)
     self.assertGreater(second_generation.disease_rate, 19)
     self.assertLess(second_generation.disease_rate, 51)
Exemple #3
0
 def test_update_to_next_generation_survival_rate_of_point_five_disease_rate_of_fifty_birth_rate_of_two(
         self):
     population = Population(10, 10, 10)
     options = ModelRunOptions(10, 10, 10, 100, 0.5, 0.5, 0.5, 2, 1000)
     next_generation = population.update_to_next_generation(options, 50)
     self.assertEqual(next_generation.juveniles, 20)
     self.assertEqual(next_generation.adults, 2)
     self.assertEqual(next_generation.seniles, 7)
     self.assertEqual(next_generation.disease_rate, 50)
Exemple #4
0
 def test_specification_example(self):
     model = PopulationModel(
         ModelRunOptions(10, 10, 10, 5, 1, 1, 0, 2, 10000))
     model.run_all_generations()
     self.assert_generation(model.get_generation(0), 10, 10, 10, 0)
     self.assert_generation(model.get_generation(1), 20, 10, 10, 0)
     self.assert_generation(model.get_generation(2), 20, 20, 10, 0)
     self.assert_generation(model.get_generation(3), 40, 20, 20, 0)
     self.assert_generation(model.get_generation(4), 40, 40, 20, 0)
     self.assert_generation(model.get_generation(5), 80, 40, 40, 0)
Exemple #5
0
 def test_model_runs_to_second_generation_with_survival_rate_of_point_five_birth_rate_of_two_no_disease(
         self):
     model = PopulationModel(
         ModelRunOptions(10, 10, 10, 1, 0.5, 0.5, 0.5, 2, 1000))
     model.run_all_generations()
     self.assertEqual(model.get_generations_count(), 2)
     second_generation = model.get_generation(1)
     self.assertEqual(second_generation.juveniles, 20)
     self.assertEqual(second_generation.adults, 5)
     self.assertEqual(second_generation.seniles, 10)
Exemple #6
0
 def test_initialisation_values(self):
     options = ModelRunOptions(1, 2, 3, 100, 0.5, 1.5, 2.5, 3.5, 1000)
     self.assertEqual(options.starting_juveniles, 1)
     self.assertEqual(options.starting_adults, 2)
     self.assertEqual(options.starting_seniles, 3)
     self.assertEqual(options.generations, 100)
     self.assertEqual(options.juvenile_survival_rate, 0.5)
     self.assertEqual(options.adult_survival_rate, 1.5)
     self.assertEqual(options.senile_survival_rate, 2.5)
     self.assertEqual(options.adult_birth_rate, 3.5)
     self.assertEqual(options.disease_trigger, 1000)
Exemple #7
0
 def test_new_model_has_one_generation(self):
     model = PopulationModel(ModelRunOptions(1, 2, 3, 100, 0, 0, 0, 0, 0))
     self.assertEqual(model.get_generations_count(), 1)