Dear user group,

I experienced misbehaviour in my LuST simulation. The problem is that
the simulation I ran recently has way more traces than anticipated. I
will attach the source code (extracttraces.py) for the simulation as
well as the lust.config.

Basically I want to generate traces over one day and insert them into
some database. Also I use the ContextSubscription feature to see if the
vehicles are within observation radius of some specific junctions (the
50 with most traffic throughput).

When I ran the simulation a few months ago I got about 209 Mio traces
with 214315 different vehicles. Unfortunately I can't determine the
source code and config of this simulation, but it should have been the
same as I use now.

However when I run the simulation now I get more than the double amount
of traces (427 Mio) with slightly less vehicles (213424).

So somehow the new simulation generated way more traces which is very
unfortunate.

By comparing the both databases I found out that both of them have
roughly the same amount of trace within the simulation time 0s < time <
60000s  (around 90 Mio traces).

At some point after this the new database and the old one diverge in the
number of traces.

(60000s < time < 86400s : old : 120 Mio, new 338 Mio traces).

So something is going wrong there but I can't figure out what it is.

It could be that I ran the old dabase on an older version of sumo. The
new one is running on sumo 1.6.0.

I recently read that I should only use version 0.26 for the LuST
scenario, but it is hard to imagine that this misbehaviour comes from
different versions.

However, if you have any advice for me I will be glad to hear from you.

Kind regards

Knut


from __future__ import print_function
import time as t

starttime = t.time()
import os, sys, sqlite3
import random



############################ Einstellungen ############################

# Path to sumo tools (version 1.6.0)
tools_path = "/opt/sumo-1.6/tools"

db_path_lw = "/media/ssd/berling/lwdb/lwdb.sqlite"
db_path_junctions = "/media/ssd/berling/all_junctions.sqlite"
db_path_traces = "/media/ssd/berling/sumo24htest50.sqlite"

# lust_0to24.sumocfg  is attached in the email 
config_path = os.path.join(os.getcwd(), "./res/lust_0to24.sumocfg")

# start sumo
command = ["sumo", "-c", config_path, "--xml-validation", "never"]

# observed junction ID's controlled by an attacker 
#(in this case he controls the 50 traffic junctions with the most traffic throughput)
dbconj = sqlite3.connect(db_path_junctions)
cursorj = dbconj.cursor()
cursorj.execute("SELECT jid FROM junctions ORDER BY density DESC LIMIT 50")
res = cursorj.fetchall()
observed_jids = []
for r in res:
    observed_jids.append(str(r[0]))
dbconj.close()

# observation radius within the junction
radius = 100

sim_start = 0
sim_end = 86400

#######################################################################


sys.path.append(tools_path)
import traci, traci.constants as const

# extract random sizes from some databas
# those size will be assigned to vehicles later
def sample_sizes():
    dbconlw = sqlite3.connect(db_path_lw)
    cursorlw = dbconlw.cursor()
    cursorlw.execute("SELECT Length, Width,ROW_COUNT FROM joined_tables")
    results_lw = [{'Length': col1, 'Width': col2, 'ROW_COUNT': col3} for (col1, col2, col3) in cursorlw.fetchall()]
    lux_vektor = []
    for col in results_lw:
        count = 1
        while count <= col['ROW_COUNT']:
            lux_vektor.append([col['Length'], col['Width']])
            count += 1
    dbconlw.close()
    return random.sample(lux_vektor, len(lux_vektor))


print("\nSimulation und Extraktion der Traces")
print("====================================")

print("Datenbank: %s\nBefehl: %s\nStartzeit: %i\nEndzeit: %i" % (db_path_traces, command, sim_start, sim_end))

if os.path.exists(db_path_traces):
    print("Verbinde zur Datenbank...")
else:
    print("Erstelle Datenbank...")
dbcon = sqlite3.connect(db_path_traces)
cursor = dbcon.cursor()

print("Leere Datenbank...")
cursor.execute("DROP TABLE IF EXISTS traces")
cursor.execute("VACUUM")
dbcon.commit()
cursor.execute('''CREATE TABLE traces (vid TEXT NOT NULL, time INTEGER NOT NULL, Length INTEGER, Width INTEGER,
x_location REAL NOT NULL, y_location REAL NOT NULL, pseudonym TEXT, event TEXT, observed_at_jid TEXT, distance REAL, PRIMARY KEY(vid,time))''')
dbcon.commit()

print("Starte SUMO...")
traci.start(command)
for jid in observed_jids:

    traci.junction.subscribeContext(jid, const.CMD_GET_VEHICLE_VARIABLE, radius, [const.TRACI_ID_LIST])

lux_vid = {}
lux_samples = sample_sizes()
lux_vid_step = 0
time = sim_start
values = []
while time <= sim_end:
    traci.simulationStep()
    vids = traci.vehicle.getIDList()
    for vid in vids:

        if not lux_vid.has_key(vid):
            # add length and width if vehicle is not known
            length = lux_samples[lux_vid_step][0]
            width = lux_samples[lux_vid_step][1]
            lux_vid[vid] = lux_samples[lux_vid_step]  # <key: vid, value:[Length,Width]>
            lux_vid_step += 1
        else:
            length = lux_vid[vid][0]
            width = lux_vid[vid][1]

        observed_at_jid = None

        for jid in observed_jids:
            observed_vids = traci.junction.getContextSubscriptionResults(jid)
            if observed_vids == None:
                continue
	    # find the first attacker junction, that is observing the vehicle (with a distance <= 100m)
            if vid in observed_vids:
                observed_at_jid = jid
                break
		# if several junctions observe  the vehicle at the same time (because they are very 			close), only one junction ID will be saved in observed_at_jid

        location = traci.vehicle.getPosition(vid)
        values.append(
            (vid, time, length, width, location[0], location[1], observed_at_jid, traci.vehicle.getDistance(vid)))

    if time % 500 == 0:
        cursor.executemany("INSERT INTO traces VALUES (?, ?,?,?, ?, ?, NULL, NULL, ?, ?)", values)
        dbcon.commit()
        values = []
    time += 1

cursor.executemany("INSERT INTO traces VALUES (?, ?,?,?, ?, ?, NULL, NULL, ?, ?)", values)
dbcon.commit()
traci.close()

print("Erstelle Indizes...")
cursor.execute("CREATE INDEX jid ON traces (observed_at_jid ASC)")
cursor.execute("CREATE INDEX jid_time ON traces (observed_at_jid ASC, time ASC)")
cursor.execute("CREATE INDEX vid_jid ON traces (vid ASC, observed_at_jid ASC)")
cursor.execute("CREATE INDEX vid_time ON traces (vid ASC, time ASC)")
dbcon.commit()
dbcon.close()

<?xml version="1.0" encoding="UTF-8"?>

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="http://sumo-sim.org/xsd/sumoConfiguration.xsd";>

    <input>
        <net-file value="lust.net.xml"/>
        <route-files value="local.static.0.rou.xml, local.static.1.rou.xml, local.static.2.rou.xml"/>
        <additional-files value="vtypes.add.xml, tll.static.xml"/>
    </input>

    <output>
        <summary-output value="due.static.summary.xml"/>
        <tripinfo-output value="due.static.tripinfo.xml"/>
    </output>

    <time>
        <begin value="0"/>
        <step-length value="1"/>
    </time>

    <processing>
        <ignore-junction-blocker value="20"/>
        <time-to-teleport value="600"/>
        <max-depart-delay value="600"/>
        <routing-algorithm value="dijkstra"/>
    </processing>

    <report>
        <verbose value="true"/>
        <log value="due.static.log"/>
    </report>

</configuration>
_______________________________________________
sumo-user mailing list
sumo-user@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to