Skip to content
Snippets Groups Projects
Commit c98b0f2a authored by Mohcine Chraibi's avatar Mohcine Chraibi
Browse files

Save evacuation times to *npy-files

parent c8457006
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ import numpy as np ...@@ -12,7 +12,7 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
####################################################### #######################################################
MAX_STEPS = 500 MAX_STEPS = 1000
steps = range(MAX_STEPS) steps = range(MAX_STEPS)
cellSize = 0.4 # m cellSize = 0.4 # m
...@@ -36,7 +36,7 @@ logging.basicConfig(filename=logfile, level=logging.INFO, format='%(asctime)s - ...@@ -36,7 +36,7 @@ logging.basicConfig(filename=logfile, level=logging.INFO, format='%(asctime)s -
def get_parser_args(): def get_parser_args():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Cellular Automaton. Floor Field Model [Burstedde2001] Simulation of pedestrian' description='Cellular Automaton. Floor Field Model [Burstedde2001] Simulation of pedestrian'
'dynamics using a two-dimensional cellular automaton Physica A, 2001, 295, 507-525') 'dynamics using a two-dimensional cellular automaton Physica A, 295, 507-525, 2001')
parser.add_argument('-s', '--ks', type=float, default=2, parser.add_argument('-s', '--ks', type=float, default=2,
help='sensitivity parameter for the Static Floor Field (default 2)') help='sensitivity parameter for the Static Floor Field (default 2)')
parser.add_argument('-d', '--kd', type=float, default=1, parser.add_argument('-d', '--kd', type=float, default=1,
...@@ -61,12 +61,12 @@ def get_parser_args(): ...@@ -61,12 +61,12 @@ def get_parser_args():
parser.add_argument('--diffusion', type=float, default=0.1, parser.add_argument('--diffusion', type=float, default=0.1,
help='the diffusion probability of the Dynamic Floor Field (default 0.2)') help='the diffusion probability of the Dynamic Floor Field (default 0.2)')
parser.add_argument('-W', '--width', type=float, default=4.0, parser.add_argument('-W', '--width', type=float, default=4.0,
help='the width of the simulated are in meters, excluding walls') help='the width of the simulation area in meter, excluding walls')
parser.add_argument('-H', '--height', type=float, default=4.0, parser.add_argument('-H', '--height', type=float, default=4.0,
help='the height of the are in meters, excluding walls') help='the height of the simulation room in meter, excluding walls')
parser.add_argument('-c', '--clean', action='store_const', const=True, default=False, parser.add_argument('-c', '--clean', action='store_const', const=True, default=False,
help='remove files from dff/ and peds/') help='remove files from directories dff/ sff/ and peds/')
parser.add_argument('-N', '--nruns', type=int, default=1, parser.add_argument('-N', '--nruns', type=int, default=1,
help='repeat the simulation N times') help='repeat the simulation N times')
...@@ -77,10 +77,10 @@ def get_parser_args(): ...@@ -77,10 +77,10 @@ def get_parser_args():
help='use moore neighborhood. Default= Von Neumann') help='use moore neighborhood. Default= Von Neumann')
parser.add_argument('--box', type=int, nargs=4, default=DEFAULT_BOX, parser.add_argument('--box', type=int, nargs=4, default=DEFAULT_BOX,
help='are which is populated with pedestrians: from_x, to_x, from_y, to_y. Default: The whole room') help='Rectangular box, initially populated with agents: from_x, to_x, from_y, to_y. Default: The whole room')
args = parser.parse_args() _args = parser.parse_args()
return args return args_
def init_obstacles(): def init_obstacles():
...@@ -329,8 +329,6 @@ def seq_update_cells(peds, sff, dff, kappaD, kappaS, shuffle, reverse): ...@@ -329,8 +329,6 @@ def seq_update_cells(peds, sff, dff, kappaD, kappaS, shuffle, reverse):
dff_diff = np.zeros((dim_x, dim_y)) dff_diff = np.zeros((dim_x, dim_y))
grid = list(it.product(range(1, dim_x - 1), range(1, dim_y - 1))) + list(exit_cells) grid = list(it.product(range(1, dim_x - 1), range(1, dim_y - 1))) + list(exit_cells)
if shuffle: # sequential random update if shuffle: # sequential random update
random.shuffle(grid) random.shuffle(grid)
...@@ -420,7 +418,7 @@ def simulate(args): ...@@ -420,7 +418,7 @@ def simulate(args):
if giveD: if giveD:
old_dffs.append((t, dff.copy())) old_dffs.append((t, dff.copy()))
if not peds.any() or int(np.sum(peds)) == 1: # is everybody out? if not peds.any(): # is everybody out? TODO: check this. Some bug is lurking here
print("Quite simulation") print("Quite simulation")
break break
# else: # else:
...@@ -523,6 +521,12 @@ def main(args): ...@@ -523,6 +521,12 @@ def main(args):
tsim += t tsim += t
print("time ", tsim) print("time ", tsim)
times.append(t * dt) times.append(t * dt)
if moore:
print("save moore.npy")
np.save("moore.npy",times)
else:
print("save neumann.npy")
np.save("neumann.npy",times)
else: else:
nproc = min(nruns, 8) nproc = min(nruns, 8)
...@@ -544,8 +548,6 @@ def main(args): ...@@ -544,8 +548,6 @@ def main(args):
tsim = sum(results) tsim = sum(results)
t2 = time.time() t2 = time.time()
print_logs(npeds, width, height, tsim, dt, nruns, t2 - t1) print_logs(npeds, width, height, tsim, dt, nruns, t2 - t1)
if drawD_avg: if drawD_avg:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment