prio flow

This commit is contained in:
leo 2022-05-03 13:46:59 +02:00
parent 7b22784002
commit 48bb475e0b
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
6 changed files with 34 additions and 19 deletions

10
Car.py
View File

@ -54,7 +54,7 @@ class Car():
self.v=0
self.a=10
self.b=20
self.minSpace=10
self.minSpace=1
self.leaderBefore=False
self.distToInter=0
@ -350,6 +350,10 @@ class Car():
self.updateGraph(self.leaderDist, self.distToInter, 0)
return
"""
if False and ("f_0" in self.id or "f_1" in self.id or "f_2" in self.id):
self.v = 0
return
if leader is None:
vd = min(self.v + self.a * dt, vmax)
self.v = max(0, vd-self.nu)
@ -406,10 +410,10 @@ class Car():
def update(self,dt):
if self.controller.t < self.startTime:
return
"""
if self.v < 1 and self.getCurrentEdge().isSpecial():
print(f"{self.id} stalled where he souldn't have")
"""
self.leader=self.getLeader(100)
self.conduiteKrauss(self.vmax,self.leader,dt)

View File

@ -164,8 +164,8 @@ class CarController:
self.t+=self.dt
for car in self.cars:
car.update(self.dt)
for flow in self.flows:
for flow in sorted(self.flows, key=lambda f: f.priority, reverse = True):
if flow.shouldSpawn(self.t):
carsClose = self.getCarsClose(flow.carModel)
try:
@ -175,7 +175,8 @@ class CarController:
else:
self.spawnFailed += 1
flow.addCar2Counter()
#print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
flow.priority += 1
print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
def draw(self,painter):
for ind,car in enumerate(self.cars):

View File

@ -13,6 +13,7 @@ class Flow:
self.adjVPH = self.vph + randint(0,self.randomVal)
self.carModel = Car("model",self.route,start,parentMap,parentController,None)
self.carsSpawned = 0
self.priority = 0
self.cc = parentController
def prepareRoute(self):
@ -27,6 +28,7 @@ class Flow:
newCar.id = self.id + str(self.carsSpawned)
self.carsSpawned += 1
self.adjVPH = self.vph + randint(0,self.randomVal)
self.priority = 0
return newCar
def addCar2Counter(self):

View File

@ -86,9 +86,9 @@ class mainLoop(QObject):
@threadSafe
def quickLoad(self):
self.map.fromPath("test12.net.xml")
self.map.fromPath("rdpt_polytech.net.xml")
self.painter.generateTransform()
self.controller.fromPath("test21.rou.xml")
self.controller.fromPath("rdpt_polytech.rou.xml")
self.controller.prepareRoute()
def updateFps(self):

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated on 2022-04-26 15:30:13 by Eclipse SUMO netedit Version 1.12.0
<!-- generated on 2022-04-26 16:30:05 by Eclipse SUMO netedit Version 1.12.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
<input>
@ -30,6 +30,10 @@
<walkingareas value="false"/>
</pedestrian>
<netedit>
<route-files value="/home/leo/Sketchbook/python/Traffic/rdpt_polytech.rou.xml"/>
</netedit>
<report>
<aggregate-warnings value="5"/>
</report>
@ -39,7 +43,7 @@
<net version="1.9" junctionCornerDetail="5" limitTurnSpeed="5.50" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd">
<location netOffset="-611958.90,-5237000.16" convBoundary="116.96,76.89,573.99,634.84" origBoundary="-1.519674,47.276916,-1.509883,47.285858" projParameter="+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"/>
<location netOffset="-611958.90,-5237000.16" convBoundary="96.06,71.34,573.99,634.84" origBoundary="-1.519674,47.276916,-1.509883,47.285858" projParameter="+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"/>
<type id="highway.bridleway" priority="1" numLanes="1" speed="2.78" allow="pedestrian" oneway="1" width="2.00"/>
<type id="highway.bus_guideway" priority="1" numLanes="1" speed="27.78" allow="bus" oneway="1"/>
@ -159,6 +163,9 @@
<edge id=":4921070996_1" function="internal">
<lane id=":4921070996_1_0" index="0" disallow="tram rail_urban rail rail_electric rail_fast ship" speed="13.89" length="0.59" shape="454.45,447.45 454.82,447.91"/>
</edge>
<edge id=":50695857_0" function="internal">
<lane id=":50695857_0_0" index="0" allow="private emergency authority army vip passenger hov taxi bus coach delivery truck trailer motorcycle evehicle custom1 custom2" speed="18.05" length="2.86" shape="121.26,85.78 120.56,85.30 120.04,85.05 119.49,84.83 118.72,84.48"/>
</edge>
<edge id=":878876537_0" function="internal">
<lane id=":878876537_0_0" index="0" disallow="pedestrian tram rail_urban rail rail_electric rail_fast ship" speed="11.11" length="0.38" shape="244.87,424.07 244.51,424.22"/>
</edge>
@ -221,8 +228,8 @@
<param key="origId" value="143886851"/>
</lane>
</edge>
<edge id="26745142" from="293352605" to="50695857" priority="9" type="highway.motorway_link" spreadType="center" shape="394.94,370.89 393.56,360.45 391.16,355.37 384.58,343.55 377.25,331.29 364.69,311.93 356.58,300.53 341.13,281.87 310.15,250.70 271.16,213.11 254.62,196.83 229.16,172.25 211.18,156.04 190.74,137.97 169.68,121.73 145.73,103.74 126.56,89.78 127.11,83.58">
<lane id="26745142_0" index="0" allow="private emergency authority army vip passenger hov taxi bus coach delivery truck trailer motorcycle evehicle custom1 custom2" speed="22.22" length="397.38" shape="394.69,368.99 393.56,360.45 391.16,355.37 384.58,343.55 377.25,331.29 364.69,311.93 356.58,300.53 341.13,281.87 310.15,250.70 271.16,213.11 254.62,196.83 229.16,172.25 211.18,156.04 190.74,137.97 169.68,121.73 145.73,103.74 126.56,89.78 127.05,84.21">
<edge id="26745142" from="293352605" to="50695857" priority="9" type="highway.motorway_link" spreadType="center" shape="394.94,370.89 393.56,360.45 391.16,355.37 384.58,343.55 377.25,331.29 364.69,311.93 356.58,300.53 341.13,281.87 310.15,250.70 271.16,213.11 254.62,196.83 229.16,172.25 211.18,156.04 190.74,137.97 169.68,121.73 145.73,103.74 126.56,89.78 114.09,80.37">
<lane id="26745142_0" index="0" allow="private emergency authority army vip passenger hov taxi bus coach delivery truck trailer motorcycle evehicle custom1 custom2" speed="22.22" length="398.44" shape="394.69,368.99 393.56,360.45 391.16,355.37 384.58,343.55 377.25,331.29 364.69,311.93 356.58,300.53 341.13,281.87 310.15,250.70 271.16,213.11 254.62,196.83 229.16,172.25 211.18,156.04 190.74,137.97 169.68,121.73 145.73,103.74 126.56,89.78 121.26,85.78">
<param key="origId" value="26745142"/>
</lane>
</edge>
@ -300,8 +307,8 @@
<edge id="E2" from="J2" to="3241296483" priority="-1">
<lane id="E2_0" index="0" speed="13.89" length="11.97" shape="368.67,226.29 372.51,237.63"/>
</edge>
<edge id="E3" from="J3" to="50695857" priority="-1">
<lane id="E3_0" index="0" speed="13.89" length="8.84" shape="117.84,75.55 125.22,80.42"/>
<edge id="E3" from="50695857" to="J3" priority="-1">
<lane id="E3_0" index="0" speed="13.89" length="26.15" shape="118.72,84.48 95.34,72.77"/>
</edge>
<junction id="293352605" type="priority" x="398.03" y="370.08" incLanes="143886851#0_0 143886851#0_1" intLanes=":293352605_0_0 :293352605_1_0" shape="393.74,372.64 399.93,371.01 399.30,368.39 393.10,369.20 393.27,370.49 393.34,370.93 393.43,371.38 393.55,371.92">
@ -352,7 +359,9 @@
<request index="0" response="00" foes="00" cont="0"/>
<request index="1" response="00" foes="00" cont="0"/>
</junction>
<junction id="50695857" type="dead_end" x="127.11" y="83.58" incLanes="E3_0 26745142_0" intLanes="" shape="126.10,79.08 124.34,81.75 125.02,82.38 125.25,82.75 125.39,83.15 125.47,83.59 125.46,84.07 128.65,84.36 128.50,82.26 128.16,81.34 127.65,80.50 126.96,79.75"/>
<junction id="50695857" type="priority" x="114.09" y="80.37" incLanes="26745142_0" intLanes=":50695857_0_0" shape="120.29,87.06 122.22,84.50 121.25,83.86 120.89,83.68 120.50,83.53 120.04,83.33 119.44,83.05 118.00,85.91 118.88,86.29 119.20,86.41 119.50,86.54 119.85,86.74">
<request index="0" response="0" foes="0" cont="0"/>
</junction>
<junction id="878876537" type="priority" x="244.09" y="422.67" incLanes="318654806#0_0 E0_0" intLanes=":878876537_0_0 :878876537_3_0 :878876537_2_0" shape="245.53,425.53 242.88,419.70 245.05,425.72">
<request index="0" response="000" foes="000" cont="0"/>
<request index="1" response="100" foes="100" cont="1"/>
@ -366,7 +375,7 @@
<junction id="J0" type="dead_end" x="233.21" y="426.59" incLanes="-E0_0" intLanes="" shape="233.21,426.59 234.30,429.60 233.21,426.59"/>
<junction id="J1" type="dead_end" x="573.99" y="634.84" incLanes="-E1_0" intLanes="" shape="573.99,634.84 576.92,633.55 573.99,634.84"/>
<junction id="J2" type="dead_end" x="367.16" y="226.80" incLanes="-E2_0" intLanes="" shape="367.16,226.80 364.13,227.83 367.16,226.80"/>
<junction id="J3" type="dead_end" x="116.96" y="76.89" incLanes="" intLanes="" shape="116.96,76.89 118.73,74.22"/>
<junction id="J3" type="dead_end" x="96.06" y="71.34" incLanes="E3_0" intLanes="" shape="94.63,74.20 96.06,71.34"/>
<junction id=":3241296483_3_0" type="internal" x="370.75" y="236.92" incLanes=":3241296483_1_0 E2_0" intLanes=":3241296483_2_0"/>
<junction id=":4921070995_3_0" type="internal" x="569.50" y="624.21" incLanes=":4921070995_2_0 E1_0" intLanes=":4921070995_0_0"/>
@ -383,6 +392,7 @@
<connection from="143879989#0" to="318654807#0" fromLane="0" toLane="0" via=":296978977_1_0" dir="l" state="="/>
<connection from="143886851#0" to="26745142" fromLane="0" toLane="0" via=":293352605_0_0" dir="s" state="M"/>
<connection from="143886851#0" to="301625138" fromLane="1" toLane="0" via=":293352605_1_0" dir="s" state="M"/>
<connection from="26745142" to="E3" fromLane="0" toLane="0" via=":50695857_0_0" dir="s" state="M"/>
<connection from="26745293#0" to="318654808" fromLane="0" toLane="0" via=":3242646161_0_0" dir="s" state="m" visibility="9.00"/>
<connection from="301625138" to="-30807871" fromLane="0" toLane="0" via=":293353900_0_0" dir="s" state="M"/>
<connection from="30807871" to="26745293#0" fromLane="0" toLane="0" via=":293353900_1_0" dir="s" state="M"/>
@ -433,6 +443,7 @@
<connection from=":4921070995_3" to="143879980" fromLane="0" toLane="0" dir="t" state="M"/>
<connection from=":4921070996_0" to="941887918#0" fromLane="0" toLane="0" dir="s" state="M"/>
<connection from=":4921070996_1" to="-143879980" fromLane="0" toLane="0" dir="s" state="M"/>
<connection from=":50695857_0" to="E3" fromLane="0" toLane="0" dir="s" state="M"/>
<connection from=":878876537_0" to="-E0" fromLane="0" toLane="0" dir="s" state="M"/>
<connection from=":878876537_1" to="-318654806#1" fromLane="0" toLane="0" via=":878876537_3_0" dir="t" state="m"/>
<connection from=":878876537_3" to="-318654806#1" fromLane="0" toLane="0" dir="t" state="M"/>

View File

@ -16,9 +16,6 @@
<flow id="f_3" begin="0.00" end="3600.00" vehsPerHour="1800.00">
<route edges="E0 -318654806#1 318654807#0 600325948 143886851#0 26745142 E3"/>
</flow>
<flow id="f_4" begin="0.00" end="3600.00" vehsPerHour="1800.00">
<route edges="E0"/>
</flow>
<flow id="f_5" begin="0.00" end="3600.00" vehsPerHour="1800.00">
<route edges="E0 -318654806#1 318654807#0 600325948 143886851#0 301625138 -30807871 -E2"/>
</flow>