-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_sim.py
65 lines (54 loc) · 2.22 KB
/
check_sim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Compatibility check for BioSim simulations.
This script shall function with biosim packages written for
the INF200 project January 2023.
"""
__author__ = "Hans Ekkehard Plesser, NMBU"
__email__ = "[email protected]"
import textwrap
import matplotlib.pyplot as plt
from biosim.simulation import BioSim
if __name__ == '__main__':
geogr = """\
WWWWWWWWWWWWWWWWWWWWW
WWWWWWWWHWWWWLLLLLLLW
WHHHHHLLLLWWLLLLLLLWW
WHHHHHHHHHWWLLLLLLWWW
WHHHHHLLLLLLLLLLLLWWW
WHHHHHLLLDDLLLHLLLWWW
WHHLLLLLDDDLLLHHHHWWW
WWHHHHLLLDDLLLHWWWWWW
WHHHLLLLLDDLLLLLLLWWW
WHHHHLLLLDDLLLLWWWWWW
WWHHHHLLLLLLLLWWWWWWW
WWWHHHHLLLLLLLWWWWWWW
WWWWWWWWWWWWWWWWWWWWW"""
geogr = textwrap.dedent(geogr)
ini_herbs = [{'loc': (10, 10),
'pop': [{'species': 'Herbivore',
'age': 5,
'weight': 20}
for _ in range(150)]}]
ini_carns = [{'loc': (10, 10),
'pop': [{'species': 'Carnivore',
'age': 5,
'weight': 20}
for _ in range(40)]}]
sim = BioSim(island_map=geogr, ini_pop=ini_herbs,
seed=123456,
hist_specs={'fitness': {'max': 1.0, 'delta': 0.05},
'age': {'max': 60.0, 'delta': 2},
'weight': {'max': 60, 'delta': 2}},
cmax_animals={'Herbivore': 100, 'Carnivore': 100},
img_dir='results',
img_base='sample', log_file=f'data/simulation_hc_{1:05d}')
sim.set_animal_parameters('Herbivore', {'zeta': 3.2, 'xi': 1.8})
sim.set_animal_parameters('Carnivore', {'a_half': 70, 'phi_age': 0.5,
'omega': 0.3, 'F': 65,
'DeltaPhiMax': 9.})
sim.set_landscape_parameters('L', {'f_max': 700})
sim.simulate(num_years=50)
sim.add_population(population=ini_carns)
sim.simulate(num_years=200)
plt.savefig('results/check_sim.pdf')
sim.make_movie()