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
0996085b
Commit
0996085b
authored
Apr 12, 2019
by
Ahmad Reza Cheraghi
Browse files
some code cleaning based on the results of sonarqube
parent
b43d3d20
Changes
1
Hide whitespace changes
Inline
Side-by-side
multiple.py
View file @
0996085b
...
...
@@ -6,19 +6,13 @@ import configparser
def
main
(
argv
):
max_round
=
2000
seedvalue
=
1
0
seedvalue
=
1
config
=
configparser
.
ConfigParser
(
allow_no_value
=
True
)
config
.
read
(
"config.ini"
)
try
:
scenario_file
=
config
.
get
(
"File"
,
"scenario"
)
except
(
configparser
.
NoOptionError
)
as
noe
:
scenario_file
=
"init_scenario.py"
scenario
=
config
.
get
(
"File"
,
"scenario"
)
try
:
solution_file
=
config
.
get
(
"File"
,
"solution"
)
except
(
configparser
.
NoOptionError
)
as
noe
:
solution_file
=
"solution.py"
nTime
=
datetime
.
now
().
strftime
(
'%Y-%m-%d_%H:%M:%S'
)[:
-
1
]
solution
=
config
.
get
(
"File"
,
"solution"
)
local_time
=
datetime
.
now
().
strftime
(
'%Y-%m-%d_%H:%M:%S'
)[:
-
1
]
try
:
opts
,
args
=
getopt
.
getopt
(
argv
,
"hs:w:r:n:v:"
,
[
"scenaro="
,
"solution="
])
except
getopt
.
GetoptError
:
...
...
@@ -29,30 +23,32 @@ def main(argv):
print
(
'multiple.py -r <randomeSeed> -w <scenario> -s <solution> -n <maxRounds>'
)
sys
.
exit
()
elif
opt
in
(
"-s"
,
"--solution"
):
solution
_file
=
arg
solution
=
arg
elif
opt
in
(
"-w"
,
"--scenario"
):
s
im_file
=
arg
s
cenario
=
arg
elif
opt
in
(
"-r"
,
"--seed"
):
seedvalue
=
int
(
arg
)
elif
opt
in
(
"-n"
,
"--maxrounds"
):
max_round
=
int
(
arg
)
round
=
1
dir
=
"./outputs/mulitple/"
+
str
(
nTime
)
+
"_"
+
scenario_file
.
rsplit
(
'.'
,
1
)[
0
]
+
"_"
+
\
solution_file
.
rsplit
(
'.'
,
1
)[
0
]
dir
=
"./outputs/mulitple/"
+
str
(
local_time
)
+
\
"_"
+
scenario
+
"_"
+
\
solution
if
not
os
.
path
.
exists
(
dir
):
os
.
makedirs
(
dir
)
out
=
open
(
dir
+
"/multiprocess.txt"
,
"w"
)
child_processes
=
[]
for
seed
in
range
(
1
,
seedvalue
+
1
):
process
=
"python3.6"
,
"run.py"
,
"-n"
+
str
(
max_round
),
"-m 1"
,
"-d"
+
str
(
nTime
),
\
"-r"
+
str
(
seed
),
"-v"
+
str
(
0
)
p
=
subprocess
.
Popen
(
process
,
stdout
=
out
,
stderr
=
out
)
process
=
"python3.6"
,
"run.py"
,
"-w"
+
scenario
,
"-s"
+
solution
\
,
"-n"
+
str
(
max_round
),
"-m 1"
,
"-d"
+
str
(
local_time
),
\
"-r"
+
str
(
seed
),
"-v"
+
str
(
0
)
p
=
subprocess
.
call
(
process
,
stdout
=
out
,
stderr
=
out
)
print
(
"Round Nr. "
,
round
,
"finished"
)
child_processes
.
append
(
p
)
round
+=
1
for
cp
in
child_processes
:
cp
.
wait
()
#
#
for cp in child_processes:
#
cp.wait()
fout
=
open
(
dir
+
"/all_aggregates.csv"
,
"w+"
)
...
...
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