IRESTE/runAllNetworks.py
2022-05-14 23:30:28 +02:00

31 lines
1.3 KiB
Python

from multiprocessing import Pool
from CarController import CarController
from Map import Map
def runSim(paths):
m = Map()
cc = CarController(m)
m.fromPath(paths[0])
cc.fromPath(paths[1])
cc.prepareRoute()
while cc.t < 3600:
cc.update()
newline = '\n'
return f"{paths[0]}/{paths[1]} : \ntemps d'arrêt moyen : {cc.totalStopped / cc.carsDestroyed:.2f}s/voitures \n<vitesse/vitesse max>T : {cc.speedPercentageTotal / cc.carsDestroyed:.2f} \nbacklog total : {cc.getFlowBacklog():.2f} \n {newline.join(f'{f.id} : {f.backlog(cc.t):.2f}' for f in cc.flows)}"
nbThreads = 5
poly = "rdpt_polytech_fixed.net.xml"
paths = [
[poly, "rdpt_polytech_burst.rou.xml"],
[poly, "rdpt_polytech_burst_2.rou.xml"],
[poly, "rdpt_polytech_burst_2_dynSpeed.rou.xml"],
[poly, "rdpt_polytech_burst_2_div2.rou.xml"],
[poly, "rdpt_polytech_burst_2_IA.rou.xml"],
["rdpt_polytech_shortcut.net.xml", "rdpt_polytech_burst_2_shortcut.rou.xml"],
["rdpt_polytech_shortcut_2.net.xml", "rdpt_polytech_burst_2_shortcut_2.rou.xml"],
["comp_inter.net.xml", "comp_inter.rou.xml"],
["comp_rdp.net.xml", "comp_rdp.rou.xml"]
]
with Pool(5) as p:
print(p.map(runSim,paths))