Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2f6e153
Bisschen Cleanup im Code für bessere readability
elFleppo Dec 19, 2024
9b28d58
Massenbewegung angefangen
elFleppo Dec 19, 2024
5cc69f5
Erste Version von Abstossender Wirkung anderer Agenten entwickelt, un…
elFleppo Dec 19, 2024
9dcff07
mittlere Geschwindigkeit + Fundamentaldiagram. Break Condition für Si…
Silivanili Dec 24, 2024
8c39ea2
Erste Version Social Penalty
elFleppo Dec 27, 2024
cf2b1fe
Erste Version Social Penalty
elFleppo Dec 27, 2024
8edddc9
Erste Version Social Penalty, noch weiter angepasst. Gibt immernoch P…
elFleppo Dec 27, 2024
c4d60f9
WIP am Fundamentaldiagram
elFleppo Dec 28, 2024
66d1e97
WIP am Fundamentaldiagram
elFleppo Dec 28, 2024
c5ff376
WIP am Fundamentaldiagram
elFleppo Dec 28, 2024
b8f1be8
Fundamentaldiagram fast fertig
elFleppo Dec 29, 2024
9c8c6fa
Rimea4 Map von #Lima und Gruppenvisualisierung von #Sil
elFleppo Dec 29, 2024
3e81c50
Rimea4 Map von #Lima und Gruppenvisualisierung von #Sil
elFleppo Dec 29, 2024
e565626
Movement range und geschwindigkeitsreduktion sollten jetzt passen, Up…
elFleppo Dec 29, 2024
7602223
Passing all unit tests, simulation looks fine also
elFleppo Dec 29, 2024
6d1cad7
Visualisierungsklasse überarbeitet und kommentiert.
Silivanili Dec 29, 2024
ac27fe3
Passing all unit tests, simulation looks fine also
elFleppo Dec 29, 2024
37906ed
Some more changes
elFleppo Dec 29, 2024
c3c47c0
Merge branch 'v1.0' of https://github.com/elFleppo/CellularAutomata i…
elFleppo Dec 29, 2024
5c406d2
Y2k hysteria was probably more relaxing then this
elFleppo Dec 29, 2024
b075779
run.py für besseres Testing am anpassen, noch nicht fertig
elFleppo Dec 30, 2024
40cb9b8
Run.py kann jezt ausgeführt werden und bei Ausführung können die Simu…
elFleppo Dec 30, 2024
63c204b
Almost there, maybe 1-2 more pushes
elFleppo Dec 30, 2024
ed28bc0
Almost there, maybe 1-2 more pushes
elFleppo Dec 30, 2024
1823434
Almost there, maybe 1-2 more pushes
elFleppo Dec 30, 2024
d3ab801
Final push (probably)
elFleppo Dec 31, 2024
0f210e0
Last one
elFleppo Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
364 changes: 170 additions & 194 deletions Application/Cell.py

Large diffs are not rendered by default.

478 changes: 394 additions & 84 deletions Application/Grid.py

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions Application/calculations.py

This file was deleted.

110 changes: 110 additions & 0 deletions Application/packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Name Version Build Channel
asttokens 2.4.1 pyhd8ed1ab_0 conda-forge
blas 1.0 mkl
bottleneck 1.4.2 py312h4b0e54e_0
brotli 1.0.9 h2bbff1b_8
brotli-bin 1.0.9 h2bbff1b_8
bzip2 1.0.8 h2bbff1b_6
ca-certificates 2024.9.24 haa95532_0
colorama 0.4.6 pyhd8ed1ab_0 conda-forge
comm 0.2.2 pyhd8ed1ab_0 conda-forge
contourpy 1.2.0 py312h59b6b97_0
cycler 0.11.0 pyhd3eb1b0_0
debugpy 1.6.7 py312hd77b12b_0
decorator 5.1.1 pyhd8ed1ab_0 conda-forge
exceptiongroup 1.2.2 pyhd8ed1ab_0 conda-forge
executing 2.1.0 pyhd8ed1ab_0 conda-forge
expat 2.6.3 h5da7b33_0
fonttools 4.51.0 py312h2bbff1b_0
freetype 2.12.1 ha860e81_0
icc_rt 2022.1.0 h6049295_2
icu 73.1 h6c2663c_0
importlib-metadata 8.5.0 pyha770c72_0 conda-forge
intel-openmp 2023.1.0 h59b6b97_46320
ipykernel 6.29.5 pyh4bbf305_0 conda-forge
ipython 8.29.0 pyh7428d3b_0 conda-forge
jedi 0.19.2 pyhff2d567_0 conda-forge
joblib 1.4.2 py312haa95532_0
jpeg 9e h827c3e9_3
jupyter_client 8.6.3 pyhd8ed1ab_0 conda-forge
jupyter_core 5.7.2 py312haa95532_0
kiwisolver 1.4.4 py312hd77b12b_0
krb5 1.20.1 h5b6d351_0
lcms2 2.12 h83e58a3_0
lerc 3.0 hd77b12b_0
libbrotlicommon 1.0.9 h2bbff1b_8
libbrotlidec 1.0.9 h2bbff1b_8
libbrotlienc 1.0.9 h2bbff1b_8
libclang 14.0.6 default_hb5a9fac_1
libclang13 14.0.6 default_h8e68704_1
libdeflate 1.17 h2bbff1b_1
libffi 3.4.4 hd77b12b_1
libpng 1.6.39 h8cc25b3_0
libpq 12.20 h70ee33d_0
libsodium 1.0.18 h8d14728_1 conda-forge
libtiff 4.5.1 hd77b12b_0
libwebp-base 1.3.2 h3d04722_1
lz4-c 1.9.4 h2bbff1b_1
matplotlib 3.9.2 py312haa95532_0
matplotlib-base 3.9.2 py312hbdc63d0_0
matplotlib-inline 0.1.7 pyhd8ed1ab_0 conda-forge
mkl 2023.1.0 h6b88ed4_46358
mkl-service 2.4.0 py312h2bbff1b_1
mkl_fft 1.3.11 py312h827c3e9_0
mkl_random 1.2.8 py312h0158946_0
nest-asyncio 1.6.0 pyhd8ed1ab_0 conda-forge
numexpr 2.10.1 py312h4cd664f_0
numpy 1.26.4 py312hfd52020_0
numpy-base 1.26.4 py312h4dde369_0
openjpeg 2.5.2 hae555c5_0
openssl 3.0.15 h827c3e9_0
packaging 24.1 py312haa95532_0
pandas 2.2.2 py312h0158946_0
parso 0.8.4 pyhd8ed1ab_0 conda-forge
patsy 0.5.6 py312haa95532_0
pickleshare 0.7.5 py_1003 conda-forge
pillow 10.4.0 py312h827c3e9_0
pip 24.2 py312haa95532_0
platformdirs 4.3.6 pyhd8ed1ab_0 conda-forge
ply 3.11 py312haa95532_1
prompt-toolkit 3.0.48 pyha770c72_0 conda-forge
psutil 5.9.0 py312h2bbff1b_0
pure_eval 0.2.3 pyhd8ed1ab_0 conda-forge
pybind11-abi 5 hd3eb1b0_0
pygments 2.18.0 pyhd8ed1ab_0 conda-forge
pyparsing 3.2.0 py312haa95532_0
pyqt 5.15.10 py312hd77b12b_0
pyqt5-sip 12.13.0 py312h2bbff1b_0
python 3.12.7 h14ffc60_0
python-dateutil 2.9.0post0 py312haa95532_2
python-tzdata 2023.3 pyhd3eb1b0_0
pytz 2024.1 py312haa95532_0
pywin32 305 py312h2bbff1b_0
pyzmq 25.1.2 py312hd77b12b_0
qt-main 5.15.2 h19c9488_10
scikit-learn 1.5.1 py312h0158946_0
scipy 1.13.1 py312hbb039d4_0
seaborn 0.13.2 py312haa95532_0
setuptools 75.1.0 py312haa95532_0
sip 6.7.12 py312hd77b12b_0
six 1.16.0 pyhd3eb1b0_1
sqlite 3.45.3 h2bbff1b_0
stack_data 0.6.2 pyhd8ed1ab_0 conda-forge
statsmodels 0.14.2 py312h4b0e54e_0 anaconda
tbb 2021.8.0 h59b6b97_0
threadpoolctl 3.5.0 py312hfc267ef_0
tk 8.6.14 h0416ee5_0
tornado 6.4.1 py312h827c3e9_0
traitlets 5.14.3 pyhd8ed1ab_0 conda-forge
typing_extensions 4.12.2 pyha770c72_0 conda-forge
tzdata 2024b h04d1e81_0
unicodedata2 15.1.0 py312h2bbff1b_0
vc 14.40 h2eaa2aa_1
vs2015_runtime 14.40.33807 h98bb1dd_1
wcwidth 0.2.13 pyhd8ed1ab_0 conda-forge
wheel 0.44.0 py312haa95532_0
xz 5.4.6 h8cc25b3_1
zeromq 4.3.5 hd77b12b_0
zipp 3.21.0 pyhd8ed1ab_0 conda-forge
zlib 1.2.13 h8cc25b3_1
zstd 1.5.6 h8880b57_0
107 changes: 59 additions & 48 deletions Application/run.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,69 @@
from Grid import Grid
from Cell import Cell, SpawnCell, BorderCell, ObstacleCell, Agent, TargetCell
from Cell import Cell, SpawnCell, ObstacleCell, Agent, TargetCell
import matplotlib.pyplot as plt
import numpy as np
from Grid import Grid, Visualization
from tests import room_square, ChickenTest, RiMEA9, RiMEA4
import tests
grid = RiMEA9(1, "floodfill")
from tests import room_square, ChickenTest, RiMEA9, RiMEA4, Experiment
import matplotlib
#This line is needed for the plots to render in Pychamr Sciplot-View
matplotlib.use("Qt5Agg")
#Abschnitt in dem Die simulations Parameter angegeben werden.
time_input = input("Bitte geben sie die Anzahl Zeitschritte an (ein Zeitschritt ist 1 Sekunde)")
timesteps = int(time_input)
user_input = input("Bitte geben sie an welchen Test (RiMEA4, RiMEA9 oder Experiment) sie durchführen wollen")
user_input = user_input.lower()
if user_input == "rimea9":
door_input = input("Bitte Anzahl (1-4) Türen angeben")
pathfinding = input("Bitte Algorithmus wählen (dijkstra, floodfill)")
if pathfinding == "floodfill":
algo = "floodfill"
elif pathfinding == "dijkstra":
algo = "dijkstra"
else:
algo = "dijkstra" #Standardwert ist dijkstra
doors = int(door_input)
grid, door_cells, roi = RiMEA9(movement_method=algo, Doors=doors)
elif user_input == "rimea4":
pathfinding = input("Bitte Algorithmus wählen (dijkstra, floodfill)")
if pathfinding == "floodfill":
algo = "floodfill"
elif pathfinding == "dijkstra":
algo = "dijkstra"
else:
algo = "dijkstra" #Standardwert ist dijkstra
spawn_input = input("Bitte spawnrate zwischen 0 und 1 eingeben um Personendichte zu variieren (Wird mit einer Zufallsvariable zwischen 0 und 1 verglichen um spawn zu bestimmen)")
grid, door_cells, roi = RiMEA4(movement_method=algo,spawn_rate=float(spawn_input))
elif user_input == "experiment":
pathfinding = input("Bitte Algorithmus wählen (dijkstra, floodfill)")
if pathfinding == "floodfill":
algo = "floodfill"
elif pathfinding == "dijkstra":
algo = "dijkstra"
else:
algo = "dijkstra" # Standardwert ist dijkstra
spawn_input = input("Bitte spawnrate zwischen 0 und 1 eingeben um Personendichte zu variieren (Wird mit einer Zufallsvariable zwischen 0 und 1 verglichen um spawn zu bestimmen)")
grid, door_cells, roi = Experiment(movement_method=algo, spawn_rate=float(spawn_input))
####################################################
#Visualisierung initialisieren und Variablen für Resultate anlegen
visualization = Visualization(grid)

agent_count_list = []
average_distance = []
density_list = []
timesteps = 10
fundamental_data = []

for i in range(timesteps):
grid.update(target_list=grid.target_cells, timestep=i)
#visualization.plot_grid_state(i)
grid.plot_grid_state(i)
plt.pause(0.2)

agent_count = len(grid.agents)
agent_count_list.append(agent_count)

# mittlere distanz von Agenten zu Ziel
total_distance_to_target = 0
if len(grid.agents) > 0:
total_istance_to_target = 0
for agent in grid.agents:
target = agent.find_target(grid.target_cells)
total_distance_to_target += agent.euclidean_distance_to(grid.grid[target[0]][target[1]])

average_distance.append(total_distance_to_target / len(grid.agents))
else:
average_distance.append(np.nan)


agents_crossed = {} # Dictionary to track agents crossing the boundary
for i in range(timesteps):
grid.update(target_list=grid.target_cells, timestep=i)
#Print statement trent einzelne Zeitschritte von einander (für einfacheres debugging)
print("--------------------------------------------------------------------------------------------------")
#Visualisierung aktueller grid-state
visualization.plot_grid_state(i)
#Bereich für Density berechnung von aktuelem Grid state wählen
area = grid.select_area_by_coordinates(roi[0], roi[1], roi[2], roi[3])
#grid.plot_grid_state(i)

plt.figure(figsize=(10,5))

plt.subplot(1, 3, 1)
plt.plot(agent_count_list)
plt.title('Anzahl Agenten über Zeit')
plt.xlabel('Zeitschritt')
plt.ylabel('Anzahl Agenten')

plt.subplot(1, 3, 2)
plt.plot(average_distance)
plt.title('Mittlere Distanz Agenten zum Ziel')
plt.xlabel('Zeitschritt')
plt.ylabel('Distanz')



plt.tight_layout()
plt.show()

visualization.animate_grid_states(timesteps)
#Berechnung fürs Fundamentaldiagram (Aktuelle Agenten dichte, Fluss und durchschnittsgeschwindigkeit)
fd_results = grid.calculate_fundamental_diagram(door_cells, i, agents_crossed, area)
fundamental_data.append(fd_results)
#Nachdem die Simulation durchgeführt wurde plotten wir noch die Ergebnisse der Fundamentaldiagram Berechnungen
visualization.plot_fundamental_diagram(fundamental_data)
Loading