pool sim
This commit is contained in:
parent
a3cc2fb442
commit
55cb4e8cc7
30
runAllNetworks.py
Normal file
30
runAllNetworks.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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))
|
Loading…
x
Reference in New Issue
Block a user