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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mohcine Chraibi
cellular_automata
Commits
e801a08e
Commit
e801a08e
authored
7 years ago
by
Mohcine Chraibi
Browse files
Options
Downloads
Patches
Plain Diff
sanity check forbox
parent
fc1ed864
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
+21
-8
21 additions, 8 deletions
cellular_automaton.py
with
21 additions
and
8 deletions
cellular_automaton.py
+
21
−
8
View file @
e801a08e
...
@@ -99,17 +99,19 @@ def init_walls(exit_cells, ):
...
@@ -99,17 +99,19 @@ def init_walls(exit_cells, ):
return
OBST
return
OBST
def
check_N_pedestrians
(
box
,
N_pedestrians
):
def
check_N_pedestrians
(
_
box
,
N_pedestrians
):
"""
"""
check if <N_pedestrian> is too big. if so change it to fit in <box>
check if <N_pedestrian> is too big. if so change it to fit in <box>
"""
"""
# holding box, where to distribute pedestrians
# holding box, where to distribute pedestrians
# ---------------------------------------------------
# ---------------------------------------------------
from_x
,
to_x
=
box
[
0
],
box
[
1
]
_from_x
=
_box
[
0
]
from_y
,
to_y
=
box
[
2
],
box
[
3
]
_to_x
=
_box
[
1
]
_from_y
=
_box
[
2
]
_to_y
=
_box
[
3
]
# ---------------------------------------------------
# ---------------------------------------------------
nx
=
to_x
-
from_x
+
1
nx
=
_
to_x
-
_
from_x
+
1
ny
=
to_y
-
from_y
+
1
ny
=
_
to_y
-
_
from_y
+
1
if
N_pedestrians
>
nx
*
ny
:
if
N_pedestrians
>
nx
*
ny
:
logging
.
warning
(
"
N_pedestrians (%d) is too large (max. %d). Set to max.
"
%
(
N_pedestrians
,
nx
*
ny
))
logging
.
warning
(
"
N_pedestrians (%d) is too large (max. %d). Set to max.
"
%
(
N_pedestrians
,
nx
*
ny
))
N_pedestrians
=
nx
*
ny
N_pedestrians
=
nx
*
ny
...
@@ -148,7 +150,7 @@ def plot_sff2(SFF, walls, i):
...
@@ -148,7 +150,7 @@ def plot_sff2(SFF, walls, i):
cmap
=
plt
.
get_cmap
()
cmap
=
plt
.
get_cmap
()
cmap
.
set_bad
(
color
=
'
k
'
,
alpha
=
0.8
)
cmap
.
set_bad
(
color
=
'
k
'
,
alpha
=
0.8
)
vect
=
SFF
*
walls
vect
=
SFF
*
walls
vect
[
vect
<
-
20
0
]
=
np
.
Inf
vect
[
vect
<
0
]
=
np
.
Inf
# print (vect)
# print (vect)
max_value
=
np
.
max
(
SFF
)
max_value
=
np
.
max
(
SFF
)
min_value
=
np
.
min
(
SFF
)
min_value
=
np
.
min
(
SFF
)
...
@@ -410,6 +412,7 @@ def setup_dir(dir, clean):
...
@@ -410,6 +412,7 @@ def setup_dir(dir, clean):
def
simulate
(
args
):
def
simulate
(
args
):
n
,
npeds
,
box
,
sff
,
shuffle
,
reverse
,
drawP
,
giveD
=
args
n
,
npeds
,
box
,
sff
,
shuffle
,
reverse
,
drawP
,
giveD
=
args
print
(
"
init %d agents in box=[%d, %d, %d, %d]
"
%
(
npeds
,
box
[
0
],
box
[
1
],
box
[
2
],
box
[
3
]))
peds
=
init_peds
(
npeds
,
box
)
peds
=
init_peds
(
npeds
,
box
)
dff
=
init_DFF
()
dff
=
init_DFF
()
...
@@ -437,7 +440,12 @@ def simulate(args):
...
@@ -437,7 +440,12 @@ def simulate(args):
else
:
else
:
return
t
return
t
def
check_box
(
box
):
"""
exit if box is not well defined
"""
assert
(
box
[
0
]
<
box
[
1
]),
"
from_x smaller than to_x
"
assert
(
box
[
2
]
<
box
[
3
]),
"
from_y smaller than to_y
"
...
@@ -458,6 +466,7 @@ def main(args):
...
@@ -458,6 +466,7 @@ def main(args):
height
=
args
.
height
# in meters
height
=
args
.
height
# in meters
parallel
=
args
.
parallel
parallel
=
args
.
parallel
box
=
args
.
box
box
=
args
.
box
check_box
(
box
)
moore
=
args
.
moore
moore
=
args
.
moore
# check if no box is specified
# check if no box is specified
if
moore
:
if
moore
:
...
@@ -481,7 +490,11 @@ def main(args):
...
@@ -481,7 +490,11 @@ def main(args):
nruns
=
args
.
nruns
nruns
=
args
.
nruns
exit_cells
=
frozenset
(((
dim_x
//
2
,
dim_y
-
1
),
(
dim_x
//
2
+
1
,
dim_y
-
1
)))
exit_cells
=
frozenset
(((
dim_x
//
2
,
dim_y
-
1
),
(
dim_x
//
2
+
1
,
dim_y
-
1
),
(
dim_x
-
1
,
dim_y
//
2
+
1
)
,
(
dim_x
-
1
,
dim_y
//
2
),
(
0
,
dim_y
//
2
+
1
)
,
(
1
,
dim_y
//
2
),
(
dim_x
//
2
+
1
,
0
)
,
(
dim_x
//
2
,
0
)
))
delta
=
args
.
decay
delta
=
args
.
decay
alpha
=
args
.
diffusion
alpha
=
args
.
diffusion
...
...
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
register
or
sign in
to comment