Hi Mohsen,

I have the same work to do to make my simulation more realistic.  I followed 
roughly the following:

1- A colleague suggested a python program to generate random vehicle starts in 
a xml file. I did not check whether it was consistent with my data but it seems 
realistic. 

Be careful with the syntax, it could not match SUMO definitions. For instance « 
departlane »  must be written like this : « departLane »… I changed it inthe 
program below.

This is the code :

##############CODE#############################

import subprocess, sys, socket, time, struct, random

RUNS=180 #numbers of runs
N=1000 #number of cars per road
p1=0.5 #cars per second in road1
p2=0.5 #cars per second in road2

sumoexec= "sumo"

for j in range(RUNS):
        routes = open("routes.rou.xml", "w")
        print >> routes, '<routes>'
        print >> routes,  ' <vtypeDistribution id="random">'
        print >> routes,  '      <vtype vclass="vip" id="Car" accel="4.5" 
decel="10" sigma="0.5" length="3" maxspeed="33" probability="0.9"/>'
        print >> routes,  '      <vtype vclass="delivery" id="Truck" 
accel="1.8" decel="6" sigma="0.5" length="10" maxspeed="25" probability="0.1"/>'
        print >> routes,  ' </vtypeDistribution>'
        print >> routes,  ' <route id="route1" edges="road1 union1" 
departLane="free" departpos="free"/>'
        print >> routes,  ' <route id="route2" edges="road2 union2" 
departLane="free" departpos="free"/>'

lastcar1=0;
lastcar2=0;

for i in range(N):
        nextcar1=lastcar1+random.expovariate(p1)
        lastcar1=nextcar1
        print >> routes, ' <vehicle route="route1" id="0_%i" type="random" 
depart="%f" departLane="%i"/>' % (i,nextcar1,(i % 2))
        nextcar2=lastcar2+random.expovariate(p2)
        lastcar2=nextcar2
        print >> routes, ' <vehicle route="route2" id="1_%i" type="random" 
depart="%f" departLane="%i"/>'% (i,nextcar2, (i % 2))
        

print >> routes, "</routes>"
        
        
routes.close()

2- I made a  python program to put departure times in the correct order. 
Otherwise SUMO do not take into account.

#!/usr/bin python
import os
import re
import nltk
import collections
from collections import *
import codecs
import shutil


# //////////////////////////////////////////////////////////////
#
# ****************  ordonner_routes poisson ********************************
#
#       FAUT QUE LES TEMPS DEPART SE SUIVENT EN ORDRE CROISSANT DANS SUMO
#       TIME DEPARTURE OF EACH VEHICULE MUST BE IN CHRONOLOGICAL ORDER
#
# //////////////////////////////////////////////////////////////

def List_route (INPUT_routes):  

# fichier INITIAL routes.rou.xml

        global route,routes,list_route
        print "\n  FICHIER INITIAL routes.rou.xml Temps depart ne sont pas en 
ordre \n "
        f_depart=open (INPUT_routes,"r")
        lines = f_depart.readlines()
        i=0
        while i< len(lines):
                print lines[i],
                i=i+1
        f_depart.close()
        print "\n\n\n "

# partie du BAS

        fo = open (INPUT_routes,"r,w")
        fich_xml=fo.read()
        p = re.compile('depart="[0-9]+.[0-9]+"')
        route=p.findall(fich_xml)
        routes=len(route)
        fo.seek(0, 0)   
        fo.read
        list_route=[]
        i=0
        while (i<routes):  
                n=route[i]
                n_sub1 = re.sub('depart="', "", n)              
                n_sub2=re.sub('"',"",n_sub1)
                list_route.append(n_sub2)
                i=i+1
        fo.close()
        T2=map(float, list_route)
        list_2=[]
        T2_ordre=sorted (T2)   # classe les temps de depart en ordre
        i=0
        while (i<len(T2)): 
                string_value = str(T2_ordre[i])
                list_2.append(string_value)
                i=i+1
        List=[]
        List = open(INPUT_routes).readlines()
        List_bas=[]             # liste du bas sera classe temps de depart 
croissant
        i=0
        j=0
        while i<len(List) :   
                j=0
                for line in List:
                        if (i <len(list_2)):
                                temps_depart=list_2[i]
                                match = re.search(temps_depart, line)
                                
new_line=re.sub('depart="[0-9]+.[0-9]+"','depart=\"' + temps_depart+'\"',line)
                                if match:
                                        List_bas.append(new_line)
                        j=j+1                           
                i=i+1

# partie du HAUT

        fo=open(INPUT_routes, 'r')
        lecture = fo.readlines()
        N_lignes = len(lecture)
        top=N_lignes-len(list_2)-1
        fo.close()
        List_top=[]
        fo = open(INPUT_routes, 'r')
        line = fo.readline()
        List_top.append(line)
        i=0
        while i<top-1:
                
                line = fo.readline()
                List_top.append(line)
                i=i+1
        fo.close()

# FINAL au complet en ordre croissant ecran ET NOUVEAU FICHIER routes_2.rou.xml
# FINAL in chronological order

        print "\n  FICHIER FINAL routes_2.rou.xml Temps depart en ordre \n "
        list_compl=List_top+List_bas
        list_compl.append("</routes>")
        long_list=len(list_compl)
        i=0
        while i< long_list:
                print list_compl[i],
                i=i+1
        f = open("routes_2.rou.xml", 'w')
        for item in list_compl:
                f.write("%s" % item)
        f.close()

        print "\n\n "


3. Pay attention to the syntax because that can distort the running of the 
program.

4- Michael Behrisch recommended me to correct certain errors in syntax and 
replace the header to avoid syntax errors. It can detect syntax errors.

Michael recommandation :
Also please enable schema checking by using
the following header for your route file (instead of the <routes> line):
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";;
xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd";>;

This will point out misspelled or misused attributes automatically.

By bringing all these parties (and some adjustments), it seems to work 
correctly.

I suggest also to see some tutorials in Excel (youtube) that can give you an 
idea of poisson law.

Hope that help

François Vaudrin
Université Laval, CANADA
________________________________________
De : Jakob Erdmann [[email protected]]
Date d'envoi : 28 avril 2015 06:25
À : mohsen hs
Cc : [email protected]
Objet : Re: [sumo-user] Arrival rate,   Distribution of vehicles within an hour

http://en.wikipedia.org/wiki/Poisson_distribution
http://en.wikipedia.org/wiki/Binomial_distribution
also see
http://sumo.dlr.de/trac.wsgi/browser/trunk/sumo/tools/randomTrips.py:323-328
for some code

2015-04-28 12:03 GMT+02:00 mohsen hs <[email protected]>:

> Hello there
> I am looking for a method to simulate the vehicles' distributions within
> an hour.  As far as I know, OD matrix distributes vehicles within an hour
> uniformly. I was wondering if anybody could kindly provide me with some
> information, papers, or formulas to improve this distribution within an
> hour. The data that I have, counted the number of vehicle per hours.
> Since,I need a distribution model for simulation within an hour. Any Help
> is highly appreciated.
>
> Kind regardsMohsen
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> sumo-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sumo-user
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to