Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cellular_automata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mohcine Chraibi
cellular_automata
Commits
c98b0f2a
Commit
c98b0f2a
authored
Jan 29, 2018
by
Mohcine Chraibi
Browse files
Options
Downloads
Patches
Plain Diff
Save evacuation times to *npy-files
parent
c8457006
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cellular_automaton.py
+17
-15
17 additions, 15 deletions
cellular_automaton.py
with
17 additions
and
15 deletions
cellular_automaton.py
+
17
−
15
View file @
c98b0f2a
...
@@ -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
=
5
00
MAX_STEPS
=
10
00
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 simulat
ed
are in meter
s
, excluding walls
'
)
help
=
'
the width of the simulat
ion
are
a
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 meter
s
, 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 d
irectories dff/ s
ff/ 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
pedestrian
s: from_x, to_x, from_y, to_y. Default: The whole room
'
)
help
=
'
Rectangular box, initially
populated with
agent
s: 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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment