Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ahmad Reza Cheraghi
swarm-sim
Commits
eb1c00fc
Commit
eb1c00fc
authored
Oct 18, 2019
by
Ahmad Reza
Browse files
Moved the scenario calling from world.py and into swarm-sim.py
parent
3db8d81b
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/world.py
View file @
eb1c00fc
...
...
@@ -52,15 +52,6 @@ class World:
seed
=
config_data
.
seed_value
,
directory
=
config_data
.
direction_name
)
mod
=
importlib
.
import_module
(
'scenario.'
+
self
.
config_data
.
scenario
)
mod
.
scenario
(
self
)
if
self
.
config_data
.
particle_random_order
:
random
.
shuffle
(
self
.
particles
)
if
config_data
.
visualization
:
self
.
window
=
vis
.
VisWindow
(
config_data
.
window_size_x
,
config_data
.
window_size_y
,
self
)
def
csv_aggregator
(
self
):
self
.
csv_round
.
aggregate_metrics
()
particle_csv
=
csv_generator
.
CsvParticleFile
(
self
.
config_data
.
direction_name
)
...
...
swarm-sim.py
View file @
eb1c00fc
...
...
@@ -6,7 +6,7 @@ import os
import
sys
import
time
import
random
from
lib
import
world
,
config
from
lib
import
world
,
config
,
vis
from
lib.gnuplot_generator
import
gnuplot_generator
...
...
@@ -27,11 +27,16 @@ def swarm_sim(argv):
swarm_sim_world
=
world
.
World
(
config_data
)
draw_scenario
(
config_data
,
swarm_sim_world
)
if
config_data
.
visualization
:
window
=
vis
.
VisWindow
(
config_data
.
window_size_x
,
config_data
.
window_size_y
,
swarm_sim_world
)
while
swarm_sim_world
.
get_actual_round
()
<=
config_data
.
max_round
and
swarm_sim_world
.
get_end
()
is
False
:
round_start_timestamp
=
time
.
perf_counter
()
if
config_data
.
visualization
:
swarm_sim_world
.
window
.
draw_world
(
round_start_timestamp
)
if
swarm_sim_world
.
window
.
window_active
is
False
:
window
.
draw_world
(
round_start_timestamp
)
if
window
.
window_active
is
False
:
break
run_solution
(
swarm_sim_world
)
...
...
@@ -42,6 +47,13 @@ def swarm_sim(argv):
logging
.
info
(
'Finished'
)
def
draw_scenario
(
config_data
,
swarm_sim_world
):
mod
=
importlib
.
import_module
(
'scenario.'
+
config_data
.
scenario
)
mod
.
scenario
(
swarm_sim_world
)
if
config_data
.
particle_random_order
:
random
.
shuffle
(
swarm_sim_world
.
particles
)
def
read_cmd_args
(
argv
,
config_data
):
try
:
opts
,
args
=
getopt
.
getopt
(
argv
,
"hs:w:r:n:m:d:v:"
,
[
"solution="
,
"scenario="
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment