parent
c4a202d68b
commit
f88891f3e3
21
README.md
21
README.md
|
@ -2,16 +2,17 @@
|
||||||
|
|
||||||
SoSe 2024 SCJ Projekt zur Modelierung eines Jäger, Beute Verhältnis in Julia mit Agents.jl
|
SoSe 2024 SCJ Projekt zur Modelierung eines Jäger, Beute Verhältnis in Julia mit Agents.jl
|
||||||
|
|
||||||
## Szenarien
|
## Features
|
||||||
|
**Statistik -**
|
||||||
|
Es werden zur Laufzeit des Modells Statistiken zur Population und Todesursache der Agenten bereitgestellt.
|
||||||
|
|
||||||
**Invasive Arten -**
|
**Verschiedene Spezien -**
|
||||||
Neue Arten von Jäger, Beute oder *Pflanzen?* in das Model einführen
|
Es können verschiedene Spezien mit individuellen Paramteren, Fressfeinden und Nahrungsquellen erstellt werden.
|
||||||
- Michael
|
|
||||||
|
|
||||||
**Saisonalität -**
|
|
||||||
Zyklische Veränderung von Reproduktionraten der Spezien *und anderen Parametern?*
|
|
||||||
- Daniel
|
|
||||||
|
|
||||||
**Umweltereignisse -**
|
**Umweltereignisse -**
|
||||||
Events die zu einem Zeitpunkt x die Parameter des Modells veränden z.B. Dürre, Feuer, Flut
|
Es können vordefinierte Events konfiguriert werden, die die Parameter der Agenten oder des Modells zyklisch anpassen. Folgende Events wurden implementiert.
|
||||||
- Daniel
|
- Dürre: Grass kann austrocknen, Räuber können weiter sehen.
|
||||||
|
- Flut: Initiale minderung der Populationen und eine höherer Energieverbrauch der Agenten.
|
||||||
|
- Winter: Auf einem gewissen Anteil der Felder wächst kein Gras.
|
||||||
|
- Saisonale Reproduktion: Anpassung der Reproduktionsraten für Räuber beziehungsweise Raubtiere.
|
||||||
|
|
||||||
|
|
|
@ -265,9 +265,8 @@ function grass_step!(model)
|
||||||
end
|
end
|
||||||
@inbounds for p in positions(model) # we don't have to enable bound checking
|
@inbounds for p in positions(model) # we don't have to enable bound checking
|
||||||
if !(model.fully_grown[p...])
|
if !(model.fully_grown[p...])
|
||||||
if model.growth[p...] ≥ model.regrowth_time#≤ 0
|
if model.growth[p...] ≥ model.regrowth_time
|
||||||
model.fully_grown[p...] = true
|
model.fully_grown[p...] = true
|
||||||
#model.growth[p...] = model.regrowth_time
|
|
||||||
else
|
else
|
||||||
model.growth[p...] += 1
|
model.growth[p...] += 1
|
||||||
end
|
end
|
||||||
|
@ -280,7 +279,7 @@ function handle_event!(model)
|
||||||
for event in model.events
|
for event in model.events
|
||||||
if event.timer == event.t_start # start event
|
if event.timer == event.t_start # start event
|
||||||
if event.name == "Drought"
|
if event.name == "Drought"
|
||||||
#model.regrowth_time = event.value
|
model.regrowth_time = event.value
|
||||||
|
|
||||||
predators = filter(id -> !("Grass" ∈ model[id].def.food), ids)
|
predators = filter(id -> !("Grass" ∈ model[id].def.food), ids)
|
||||||
for id in predators
|
for id in predators
|
||||||
|
@ -288,11 +287,19 @@ function handle_event!(model)
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif event.name == "Flood"
|
elseif event.name == "Flood"
|
||||||
model.regrowth_time = event.value
|
flood_kill_chance = event.value
|
||||||
for id in ids
|
for id in ids
|
||||||
abmproperties(model)[Symbol(model[id].def.type*"_"*"Δenergy")] -= 1
|
if (flood_kill_chance ≥ rand(abmrng(model)))
|
||||||
|
remove_agent!(model[id], model)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for p in positions(model)
|
||||||
|
if model.fully_grown[p...]
|
||||||
|
model.growth[p...] = 0
|
||||||
|
model.fully_grown[p...] = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
elseif event.name == "PreyReproduceSeasonal"
|
elseif event.name == "PreyReproduceSeasonal"
|
||||||
prey = filter(id -> "Grass" ∈ model[id].def.food, ids)
|
prey = filter(id -> "Grass" ∈ model[id].def.food, ids)
|
||||||
|
@ -314,7 +321,6 @@ function handle_event!(model)
|
||||||
for p in positions(model)
|
for p in positions(model)
|
||||||
dry_out_chance = 0.4 * (model.growth[p...] / model.regrowth_time)
|
dry_out_chance = 0.4 * (model.growth[p...] / model.regrowth_time)
|
||||||
if model.fully_grown[p...] && (dry_out_chance ≥ rand(abmrng(model)))
|
if model.fully_grown[p...] && (dry_out_chance ≥ rand(abmrng(model)))
|
||||||
#model.growth[p...] = 0
|
|
||||||
model.growth[p...] = rand(abmrng(model), 1:model.regrowth_time) - 1
|
model.growth[p...] = rand(abmrng(model), 1:model.regrowth_time) - 1
|
||||||
model.fully_grown[p...] = false
|
model.fully_grown[p...] = false
|
||||||
end
|
end
|
||||||
|
@ -324,7 +330,7 @@ function handle_event!(model)
|
||||||
i = 1
|
i = 1
|
||||||
for p in positions(model)
|
for p in positions(model)
|
||||||
if i % block_field_every == 0
|
if i % block_field_every == 0
|
||||||
model.growth[p...] = rand(abmrng(model), 1:(model.regrowth_time / 2))
|
model.growth[p...] = 0
|
||||||
model.fully_grown[p...] = false
|
model.fully_grown[p...] = false
|
||||||
end
|
end
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -336,16 +342,21 @@ function handle_event!(model)
|
||||||
|
|
||||||
if event.timer == event.t_end # end event
|
if event.timer == event.t_end # end event
|
||||||
if event.name == "Drought"
|
if event.name == "Drought"
|
||||||
#model.regrowth_time = event.pre_value
|
model.regrowth_time = event.pre_value
|
||||||
predators = filter(id -> !("Grass" ∈ model[id].def.food), ids)
|
predators = filter(id -> !("Grass" ∈ model[id].def.food), ids)
|
||||||
for id in predators
|
for id in predators
|
||||||
abmproperties(model)[Symbol(model[id].def.type*"_"*"perception")] = 1
|
abmproperties(model)[Symbol(model[id].def.type*"_"*"perception")] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif event.name == "Flood"
|
elseif event.name == "Winter"
|
||||||
model.regrowth_time = event.pre_value
|
adjust_field_every = 2
|
||||||
for id in ids
|
i = 1
|
||||||
abmproperties(model)[Symbol(model[id].def.type*"_"*"Δenergy")] += 1
|
for p in positions(model)
|
||||||
|
if i % adjust_field_every == 0
|
||||||
|
model.growth[p...] = rand(abmrng(model), 1:(model.regrowth_time))
|
||||||
|
model.fully_grown[p...] = false
|
||||||
|
end
|
||||||
|
i += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif event.name == "PreyReproduceSeasonal"
|
elseif event.name == "PreyReproduceSeasonal"
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 8,
|
"execution_count": 1,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `~/Studium/SCJ-PredatorPrey/env`\n"
|
"\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `c:\\Users\\da93p\\Desktop\\SCJ\\SCJ-Projekt\\SCJ-PredatorPrey\\env`\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 81,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 105,
|
"execution_count": 48,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -68,13 +68,32 @@
|
||||||
"#Pkg.status([\"Agents\",\"GLMakie\"]; mode = Pkg.Types.PKGMODE_MANIFEST, io=stdout)\n",
|
"#Pkg.status([\"Agents\",\"GLMakie\"]; mode = Pkg.Types.PKGMODE_MANIFEST, io=stdout)\n",
|
||||||
"using GLMakie\n",
|
"using GLMakie\n",
|
||||||
"GLMakie.activate!()\n",
|
"GLMakie.activate!()\n",
|
||||||
"events = RecurringEvent[\n",
|
"\n",
|
||||||
"#RecurringEvent(\"Drought\", 30, 30, 30, 60, 120, 0)\n",
|
"# Scenario 1\n",
|
||||||
"#RecurringEvent(\"Flood\", 50, 30, 70, 80, 120, 0)\n",
|
"#events = [] # -> stabiles System\n",
|
||||||
"RecurringEvent(\"Winter\", 0, 0, 18, 24, 24, 0)\n",
|
"\n",
|
||||||
"RecurringEvent(\"PreyReproduceSeasonal\", 0.5, 0.05, 1, 6, 24, 0)\n",
|
"# Scenario 2\n",
|
||||||
"#RecurringEvent(\"PredatorReproduceSeasonal\", 0.1, 0.07, 4, 6, 12, 0)\n",
|
"# events = RecurringEvent[\n",
|
||||||
"]\n",
|
"# RecurringEvent(\"Drought\", 30, 40, 100, 124, 240, 0)\n",
|
||||||
|
"# RecurringEvent(\"Flood\", 0.4, 0, 20, 20, 120, 0)\n",
|
||||||
|
"# ] # -> extreme Populationsschwankungen, Räuber stirbt aus (t=433) und System kollabiert\n",
|
||||||
|
"\n",
|
||||||
|
"# Scenario 3\n",
|
||||||
|
"# events = RecurringEvent[\n",
|
||||||
|
"# RecurringEvent(\"Winter\", 0, 0, 18, 24, 24, 0)\n",
|
||||||
|
"# RecurringEvent(\"PreyReproduceSeasonal\", 0.5, 0.1, 1, 7, 24, 0)\n",
|
||||||
|
"# RecurringEvent(\"PredatorReproduceSeasonal\", 0.1, 0.04, 6, 12, 24, 0)\n",
|
||||||
|
"# ] # -> geringere max. Population, dafür weniger starke Schwankung.\n",
|
||||||
|
"\n",
|
||||||
|
"# Scenario 4\n",
|
||||||
|
"# events = RecurringEvent[\n",
|
||||||
|
"# RecurringEvent(\"Drought\", 30, 40, 100, 124, 240, 0)\n",
|
||||||
|
"# RecurringEvent(\"Flood\", 0.4, 0, 25, 25, 120, 0)\n",
|
||||||
|
"# RecurringEvent(\"Winter\", 0, 0, 18, 24, 24, 0)\n",
|
||||||
|
"# RecurringEvent(\"PreyReproduceSeasonal\", 0.5, 0.1, 1, 7, 24, 0)\n",
|
||||||
|
"# RecurringEvent(\"PredatorReproduceSeasonal\", 0.1, 0.05, 6, 12, 24, 0)\n",
|
||||||
|
"# ] # -> starke Schwankung durch, allerdings bleibt das System stabil\n",
|
||||||
|
"\n",
|
||||||
"animal_defs = [\n",
|
"animal_defs = [\n",
|
||||||
"AnimalDefinition(30,'●',RGBAf(1.0, 1.0, 1.0, 0.8),20, 0.3, 20, 3, \"Sheep\", [\"Wolf\",\"Bear\"], [\"Grass\"])\n",
|
"AnimalDefinition(30,'●',RGBAf(1.0, 1.0, 1.0, 0.8),20, 0.3, 20, 3, \"Sheep\", [\"Wolf\",\"Bear\"], [\"Grass\"])\n",
|
||||||
"AnimalDefinition(3,'▲',RGBAf(0.2, 0.2, 0.3, 0.8),20, 0.07, 20, 1, \"Wolf\", [], [\"Sheep\"])\n",
|
"AnimalDefinition(3,'▲',RGBAf(0.2, 0.2, 0.3, 0.8),20, 0.07, 20, 1, \"Wolf\", [], [\"Sheep\"])\n",
|
||||||
|
@ -124,6 +143,13 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
Loading…
Reference in New Issue