36 lines
1.6 KiB
Python
36 lines
1.6 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'
|
|
print(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)} \n nombre de voitures {cc.carsDestroyed}")
|
|
|
|
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)} \n nombre de voitures {cc.carsDestroyed}"
|
|
|
|
nbThreads = 7
|
|
poly = "rdpt_polytech_fixed.net.xml"
|
|
paths = [
|
|
[poly, "rdpt_polytech_burst.rou.xml"],
|
|
[poly, "rdpt_polytech_burst_dynSpeed.rou.xml"],
|
|
[poly, "rdpt_polytech_burst_div2.rou.xml"],
|
|
[poly, "rdpt_polytech_burst_IA.rou.xml"],
|
|
["rdpt_polytech_shortcut_3.net.xml", "rdpt_polytech_burst_shortcut_3.rou.xml"],
|
|
["comp_inter.net.xml", "comp_inter.rou.xml"],
|
|
["comp_rdp.net.xml", "comp_rdp.rou.xml"]
|
|
]
|
|
paths2 = [
|
|
[poly, "rdpt_polytech_3600.rou.xml"],
|
|
#[poly, "rdpt_polytech_burst.rou.xml"]
|
|
]
|
|
with Pool(nbThreads) as p:
|
|
for l in p.map(runSim,paths2):
|
|
print(l)
|