Notes
Notes - notes.io |
sys.path.append(os.path.join(os.path.dirname(__file__),'..', '..', '..','..', 'tools'))
sys.path.append(os.path.join(os.environ.get("SUMO_HOME",os.path.join(os.path.dirname(__file__),'..','..','..')), 'tools'))
from sumolib import checkBinary
import traci
PORT = 8813
nsg = "GrGr"
nsy = "yryr"
weg = "rGrG"
wey = "ryry"
PROGRAM = [wey,wey,wey,nsg,nsg,nsg,nsg,nsg,nsg,nsg,nsg,nsy,nsy,weg]
if not traci.isEmbedded():
N = 9000
pWE = 1./10
pEW = 1./11
pNS = 1./30
routes = open(".rou.xml", "w")
prior_v=open("prior_log.txt","w")
print >> routes, """<routes>
<vtype id="typeWE" accel="0.8" decel="4.5" sigma="0.5" length="7.5" maxspeed="16.67 minGap="2.5" guiShape="passenger/>
<vtype id="typeNS" accel="0.8" decel="4.5" sigma="0.5" length="20" maxspeed="25" guiShape="bus" minGap="3"/>
<route id="right" edges="51o 1i 2o 52i" />
<route id="left" edges="52o 2i 1o 51i" />
<route id="down" edges="54o 4i 3o 53i" />
lastVeh = 0
vehNr = 0
for i in range(N):
if random.uniform(0,1) < pWE:
print >> routes, ' <vehicle id="%i" type="typeWE" route="right" depart="%i" />' % (vehNr, i)
vehNr += 1
lastVeh = i
if random.uniform(0,1) < pEW:
print >> routes, ' <vehicle id="%i" type="typeWE" route="left" depart="%i" />' % (vehNr, i)
vehNr += 1
lastVeh = i
if random.uniform(0,1) < pNS:
print >> routes, ' <vehicle id="%i" type="typeNS" route="down" depart="%i" color="1,0,0"/>' % (vehNr, i)
vehNr += 1
lastVeh = i
print >> routes, "</routes>"
routes.close()
sumoExe = 'sumo-gui'
sumoConfig="sumoconfig.sumocfg"
if len(sys.argv) >1:
retCode = subprocess.call("%s c %s --python-script %s" % (sumoBinary,sumoConfig,__file__),shell=True,stdout=sys.stdout)
sys.exit(retCode)
else:
sumoProcess = subprocess.call("%s -c %s" % (sumoBinary,sumoConfig),shell=True,stdout=sys.stdout )
traci.init(PORT)
programPointer = len(PROGRAM)-1
step = 0
while step == 0 or traci.simulation.getMinExpectedNumber() > 0:
traci.simulationStep()
programPointer = min(programPointer+1, len(PROGRAM)-1)
no = traci.inductionloop.getLastStepVehicleNumber("0")
if no > 0:
programPointer = (0 if programPointer == len(PROGRAM)-1 else 3)
print >> prior_v,"Priority Vehicle Enter at ",traci.simulation.getCurrentTime()," Vehicle-Number :",traci.edge.getLastStepVehicleNumber("4i"),"n"
traci.trafficlights.setRedYellowGreenState("0",PROGRAM[programPointer])
step += 1
traci.close()
sys.stdout.flush()
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team