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
e5d60a98
Commit
e5d60a98
authored
Aug 20, 2019
by
Ahmad Reza
Browse files
Some name changes in the config. mm_limit is renamed to
memory_limitation
parent
bb888ff7
Changes
5
Hide whitespace changes
Inline
Side-by-side
config.ini
View file @
e5d60a98
...
...
@@ -17,9 +17,10 @@ random_order = 1
window_size_x
=
600
window_size_y
=
800
## 0 = Unlimited world size
## 1 = limited world size
border
=
0.0
[World]
## False = Unlimited world size
## True = limited world size
border
=
False
## Swarm-World world size in points
## Works only with border flag set on 1
...
...
@@ -31,10 +32,10 @@ max_particles = 10000
[Matter]
## with memory (mm) limitation 1=Yes 0=No
m
m
_limitation
=
0
m
emory
_limitation
=
False
## mm size in quantity
## Works only with m
m
_limitation flag set on 1
## Works only with m
emory
_limitation flag set on 1
marker_mm_size
=
2
particle_mm_size
=
2
tile_mm_size
=
2
...
...
lib/config.py
View file @
e5d60a98
...
...
@@ -11,6 +11,19 @@ class ConfigData:
self
.
max_round
=
config
.
getint
(
"Simulator"
,
"max_round"
)
self
.
random_order
=
config
.
getboolean
(
"Simulator"
,
"random_order"
)
self
.
visualization
=
config
.
getint
(
"Simulator"
,
"visualization"
)
self
.
window_size_x
=
config
.
getint
(
"Simulator"
,
"window_size_x"
)
self
.
window_size_y
=
config
.
getint
(
"Simulator"
,
"window_size_y"
)
self
.
size_x
=
config
.
getfloat
(
"World"
,
"size_x"
)
self
.
size_y
=
config
.
getfloat
(
"World"
,
"size_y"
)
self
.
border
=
config
.
getboolean
(
"World"
,
"border"
)
self
.
max_particles
=
config
.
getint
(
"World"
,
"max_particles"
)
self
.
memory_limitation
=
config
.
getboolean
(
"Matter"
,
"memory_limitation"
)
self
.
particle_mm_size
=
config
.
getint
(
"Matter"
,
"particle_mm_size"
)
self
.
tile_mm_size
=
config
.
getint
(
"Matter"
,
"tile_mm_size"
)
self
.
marker_mm_size
=
config
.
getint
(
"Matter"
,
"marker_mm_size"
)
try
:
self
.
scenario
=
config
.
get
(
"File"
,
"scenario"
)
except
configparser
.
NoOptionError
as
noe
:
...
...
@@ -20,16 +33,6 @@ class ConfigData:
self
.
solution
=
config
.
get
(
"File"
,
"solution"
)
except
configparser
.
NoOptionError
as
noe
:
self
.
solution
=
"solution.py"
self
.
size_x
=
config
.
getfloat
(
"Simulator"
,
"size_x"
)
self
.
size_y
=
config
.
getfloat
(
"Simulator"
,
"size_y"
)
self
.
window_size_x
=
config
.
getint
(
"Simulator"
,
"window_size_x"
)
self
.
window_size_y
=
config
.
getint
(
"Simulator"
,
"window_size_y"
)
self
.
border
=
config
.
getfloat
(
"Simulator"
,
"border"
)
self
.
max_particles
=
config
.
getint
(
"Simulator"
,
"max_particles"
)
self
.
mm_limitation
=
config
.
getboolean
(
"Matter"
,
"mm_limitation"
)
self
.
particle_mm_size
=
config
.
getint
(
"Matter"
,
"particle_mm_size"
)
self
.
tile_mm_size
=
config
.
getint
(
"Matter"
,
"tile_mm_size"
)
self
.
marker_mm_size
=
config
.
getint
(
"Matter"
,
"marker_mm_size"
)
self
.
local_time
=
datetime
.
now
().
strftime
(
'%Y-%m-%d_%H-%M-%S'
)[:
-
1
]
self
.
multiple_sim
=
0
lib/matter.py
View file @
e5d60a98
...
...
@@ -21,7 +21,7 @@ class Matter:
self
.
__modified
=
False
self
.
__alpha
=
alpha
self
.
type
=
type
self
.
m
m
_limit
=
world
.
config_data
.
m
m
_limitation
self
.
m
emory
_limit
ation
=
world
.
config_data
.
m
emory
_limitation
self
.
mm_size
=
mm_size
self
.
modified
=
False
self
.
created
=
False
...
...
@@ -90,7 +90,7 @@ class Matter:
:return: True: Successful written into the memory; False: Unsuccessful
"""
if
(
self
.
m
m
_limit
==
True
and
len
(
self
.
_memory
)
<
self
.
mm_size
)
or
not
self
.
m
m
_limit
:
if
(
self
.
m
emory
_limit
ation
==
True
and
len
(
self
.
_memory
)
<
self
.
mm_size
)
or
not
self
.
m
emory
_limit
ation
:
self
.
_memory
[
key
]
=
data
self
.
world
.
csv_round
.
update_metrics
(
memory_write
=
1
)
return
True
...
...
@@ -107,7 +107,7 @@ class Matter:
:return: True: Successful written into the memory; False: Unsuccessful
"""
if
(
self
.
m
m
_limit
==
True
and
len
(
self
.
_memory
)
<
self
.
mm_size
)
or
not
self
.
m
m
_limit
:
if
(
self
.
m
emory
_limit
ation
==
True
and
len
(
self
.
_memory
)
<
self
.
mm_size
)
or
not
self
.
m
emory
_limit
ation
:
self
.
_memory
[
datetime
.
utcnow
().
strftime
(
'%Y-%m-%d %H:%M:%S.%f'
)[:
-
1
]]
=
data
self
.
world
.
csv_round
.
update_metrics
(
memory_write
=
1
)
return
True
...
...
lib/world.py
View file @
e5d60a98
...
...
@@ -81,14 +81,6 @@ class World:
self
.
csv_round
.
success
()
self
.
set_end
()
def
get_max_round
(
self
):
"""
Return the initialized endding round number
:return: The maximum round number
"""
return
self
.
config_data
.
max_round
def
get_actual_round
(
self
):
"""
The actual round number
...
...
@@ -458,7 +450,6 @@ class World:
else
:
return
False
def
add_marker
(
self
,
x
,
y
,
color
=
black
,
alpha
=
1
):
"""
Add a tile to the world database
...
...
@@ -489,7 +480,6 @@ class World:
logging
.
info
(
"for x %f and y %f not possible to draw "
,
x
,
y
)
return
False
def
remove_marker
(
self
,
id
):
"""
Removes a tile with a given tile_id from to the world database
...
...
@@ -520,7 +510,6 @@ class World:
else
:
return
False
def
remove_marker_on
(
self
,
coords
):
"""
Removes a marker on a give coordinat from to the world database
...
...
swarm-sim.py
View file @
e5d60a98
...
...
@@ -24,7 +24,7 @@ def swarm_sim(argv):
swarm_sim_world
=
world
.
World
(
config_data
)
while
swarm_sim_world
.
get_actual_round
()
<=
swarm_sim_world
.
get_
max_round
()
and
swarm_sim_world
.
get_end
()
is
False
:
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
()
run_solution
(
swarm_sim_world
)
if
config_data
.
visualization
:
...
...
Write
Preview
Markdown
is supported
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