Commit 0996085b authored by Ahmad Reza Cheraghi's avatar Ahmad Reza Cheraghi
Browse files

some code cleaning based on the results of sonarqube

parent b43d3d20
......@@ -6,19 +6,13 @@ import configparser
def main(argv):
max_round = 2000
seedvalue = 10
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"):
sim_file = arg
scenario = 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+")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment