Flood improved

Scenarios created
Readme updated
main
Daniel Philipp 2024-06-23 18:29:04 +02:00
parent c4a202d68b
commit f88891f3e3
3 changed files with 73 additions and 35 deletions

View File

@ -2,16 +2,17 @@
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 -**
Neue Arten von Jäger, Beute oder *Pflanzen?* in das Model einführen
- Michael
**Saisonalität -**
Zyklische Veränderung von Reproduktionraten der Spezien *und anderen Parametern?*
- Daniel
**Verschiedene Spezien -**
Es können verschiedene Spezien mit individuellen Paramteren, Fressfeinden und Nahrungsquellen erstellt werden.
**Umweltereignisse -**
Events die zu einem Zeitpunkt x die Parameter des Modells veränden z.B. Dürre, Feuer, Flut
- Daniel
Es können vordefinierte Events konfiguriert werden, die die Parameter der Agenten oder des Modells zyklisch anpassen. Folgende Events wurden implementiert.
- 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.

View File

@ -265,9 +265,8 @@ function grass_step!(model)
end
@inbounds for p in positions(model) # we don't have to enable bound checking
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.growth[p...] = model.regrowth_time
else
model.growth[p...] += 1
end
@ -280,7 +279,7 @@ function handle_event!(model)
for event in model.events
if event.timer == event.t_start # start event
if event.name == "Drought"
#model.regrowth_time = event.value
model.regrowth_time = event.value
predators = filter(id -> !("Grass" model[id].def.food), ids)
for id in predators
@ -288,11 +287,19 @@ function handle_event!(model)
end
elseif event.name == "Flood"
model.regrowth_time = event.value
flood_kill_chance = event.value
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
elseif event.name == "PreyReproduceSeasonal"
prey = filter(id -> "Grass" model[id].def.food, ids)
@ -314,7 +321,6 @@ function handle_event!(model)
for p in positions(model)
dry_out_chance = 0.4 * (model.growth[p...] / model.regrowth_time)
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.fully_grown[p...] = false
end
@ -324,7 +330,7 @@ function handle_event!(model)
i = 1
for p in positions(model)
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
end
i += 1
@ -336,16 +342,21 @@ function handle_event!(model)
if event.timer == event.t_end # end event
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)
for id in predators
abmproperties(model)[Symbol(model[id].def.type*"_"*"perception")] = 1
end
end
elseif event.name == "Flood"
model.regrowth_time = event.pre_value
for id in ids
abmproperties(model)[Symbol(model[id].def.type*"_"*"Δenergy")] += 1
elseif event.name == "Winter"
adjust_field_every = 2
i = 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
elseif event.name == "PreyReproduceSeasonal"

View File

@ -2,14 +2,14 @@
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"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",
"execution_count": 81,
"execution_count": 2,
"metadata": {},
"outputs": [
{
@ -60,7 +60,7 @@
},
{
"cell_type": "code",
"execution_count": 105,
"execution_count": 48,
"metadata": {},
"outputs": [],
"source": [
@ -68,13 +68,32 @@
"#Pkg.status([\"Agents\",\"GLMakie\"]; mode = Pkg.Types.PKGMODE_MANIFEST, io=stdout)\n",
"using GLMakie\n",
"GLMakie.activate!()\n",
"events = RecurringEvent[\n",
"#RecurringEvent(\"Drought\", 30, 30, 30, 60, 120, 0)\n",
"#RecurringEvent(\"Flood\", 50, 30, 70, 80, 120, 0)\n",
"RecurringEvent(\"Winter\", 0, 0, 18, 24, 24, 0)\n",
"RecurringEvent(\"PreyReproduceSeasonal\", 0.5, 0.05, 1, 6, 24, 0)\n",
"#RecurringEvent(\"PredatorReproduceSeasonal\", 0.1, 0.07, 4, 6, 12, 0)\n",
"]\n",
"\n",
"# Scenario 1\n",
"#events = [] # -> stabiles System\n",
"\n",
"# Scenario 2\n",
"# events = RecurringEvent[\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",
"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",
@ -124,6 +143,13 @@
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {