SlideShare a Scribd company logo
Road Traffic Rules Synthesis
using Grammatical Evolution
Master Degree in Computer Engineering
University of Trieste
Italy
07-06-2017
Author:
Jacopo Talamini
Supervisor:
prof. Eric Medvet
Co-Supervisors:
prof. Alberto Bartoli
prof. Lorenzo Castelli
Contents
1 Introduction and related work 1
1.1 Driverless Cars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Classification of driverless cars . . . . . . . . . . . . . . . 2
1.1.2 Benefits and issues of driverless cars . . . . . . . . . . . . 2
1.1.3 Present scenario . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Solution proposed . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Road traffic model 6
2.1 Road traffic simulator . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 The model proposed . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Roads and cars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.1 The road graph . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.2 The cars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.3 Cars management in the simulator . . . . . . . . . . . . . 9
2.4 Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.4.1 The input variables . . . . . . . . . . . . . . . . . . . . . . 12
2.4.2 The state variables . . . . . . . . . . . . . . . . . . . . . . 13
2.4.3 The output of the driver’s algorithm . . . . . . . . . . . . 13
1
2.5 The performance indexes . . . . . . . . . . . . . . . . . . . . . . 14
2.6 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.7 Rules-aware driver . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.7.1 The prediction models . . . . . . . . . . . . . . . . . . . . 17
3 Grammatical Evolution 21
4 Experiments 23
4.1 Validation of the road traffic model . . . . . . . . . . . . . . . . . 23
4.2 Synthesis of traffic rules . . . . . . . . . . . . . . . . . . . . . . . 28
5 Concluding remarks and future work 35
2
Abstract
In questo lavoro `e stato considerato uno scenario futuro in cui i conducenti
umani e artificiali coesisteranno sulle strade, e in cui le vigenti regole di cir-
colazione risulteranno inadeguate o inefficienti. Per affrontare tale scenario `e
stata considerata la sintesi automatica di regole del traffico stradale utilizzando
Grammatical Evolution (GE). `E stato sviluppato quindi un simulatore di traffico
stradale per validare le regole ottenute. Questo simulatore consente ai guidatori
di eludere le regole del traffico nel caso in cui non vi siano alternative migliori.
Ogni individuo di GE `e un insieme di regole e la sua fitness `e calcolata come
una somma ponderata dell’efficienza e della sicurezza del traffico, risultante da
una serie di simulazioni in cui tutti i conducenti sono soggetti alle stesse regole.
I risultati sperimentali ottenuti mostrano che questo approccio genera regole
che portano a un traffico pi`u sicuro e pi`u efficiente rispetto al caso in cui non
si applicano delle regole. Inoltre, le regole ottenute sperimentalmente si sono
dimostrate ancor pi`u idonee, rispetto ai parametri considerati, di altre regole
simili a quelle attualmente utilizzate.
Abstract
In this work has been considered a future scenario in which human and machine-
based driver will coexist on the roads, causing the current road rules to result
unsuitable or inefficient. The automatic synthesis of road traffic rules has been
considered in order to deal with such scenario using Grammatical Evolution
(GE). A road traffic simulator has been developed to validate the rules obtained.
This simulator allows drivers to evade traffic rules when there are no better
alternatives. Each GE individual is a set of rules and its fitness is computed
as a weighted sum of traffic efficiency and safety, as resulting from a number
of simulations where all drivers are subjected to the same rules. Experimental
results show that this approach indeed generates rules leading to a safer and
more efficient traffic than enforcing no rules. Moreover this rules have been
proved to be even more suitable, with respect to the considered parameters, than
other ones similar to those currently used.
Chapter 1
Introduction and related
work
Car driving is one of the tasks that in a not far away future will be carried out
by machines, rather than by humans.
1.1 Driverless Cars
Driverless car are vehicles that are able to navigate without the need of human
intervention. In recent years many automotive companies like Tesla, Toyota,
BMW, Ford, Nissan, Volvo, but also different companies like Google and Uber
have invested resources in the driverless car development field and some relevant
results have been obtained so far. Notwithstanding the numerous prototypes
available, a scenario in which cars can drive in full autonomy is not yet feasible.
Driverless cars, also called autonomous vehicles, are equipped with
sensors such as radar and other devices aimed at measuring distances and speeds
of other vehicles or obstacles on the track-way. They have also computer vision
systems to recognize roadway lines on the asphalt in order to navigate into the
lane but also to detect the grip of the terrain and handle properly the engine
effort and performances. Finally driver-less cars use Global Positioning System
(GPS) modules to track routes and calculate vehicle position.
These and many more are the distinctive traits of driverless vehicles:
more and more complex intelligence (software) on board, intended to replace the
perception, view, and predictive behaviour of the human driver with the sensors
inside the Engine Control Unit (ECU). These computers are way faster and
1
more efficient than human brain, and nowadays some of their features are used
in many commercial cars models in order to provide better driving experiences.
At present time cars are equipped with many distinctive components
of autonomous vehicles, but navigation is still the role of the human driver.
1.1.1 Classification of driverless cars
SAE International has provided a description of the autonomous vehicles through
the J3016 standard issued in 2014 [1]. This standard defines a classification
based on various levels of vehicle autonomy. The classification is based on the
assessment of the human intervention required:
• Level 0 (No autonomy): the human driver must take care of all aspects of
the ride, even when assisted by machine systems.
• Level 1 (Driving assistance): the machine can accelerate or brake and steer
itself in a number of situations, but the human driver must be ready to
take control back at any time.
• Level 2 (Partial Automation): accelerating, braking and steering are
actions left entirely to the machine, but the human driver must take care
of monitoring the surrounding environment in each case.
• Level 3 (Conditioning Automation): accelerating, braking, steering, but
also monitoring of the surrounding environment are tasks depending on the
machine, but the human driver must be ready to intervene when requested
by the system.
• Level 4 (High Automation): the automatic system in the machine can han-
dle any event, but it should not be activated in extreme driving situations
such as bad weather conditions.
• Level 5 (Complete Automation): the automatic system in the machine is
capable of handling all the situations that a person can handle, so there is
no need for human intervention of any kind.
1.1.2 Benefits and issues of driverless cars
The benefits of introducing autonomous vehicles are a lot, and they range
from enhanced safety both for the driver and for other vehicles, to the driving
assistance provided to the driver, and eventually to an improvement of the traffic
flow and thus reduction of vehicle emissions and less pollution produced by cars.
2
Despite the various benefits to increased vehicle automation, some issues
still persist, such as disputes concerning liability, or concerning the time needed
to convert the existing stock of vehicles from traditional cars to autonomous
ones. Another issue is that driverless car concept has to face the resistance of
people that refuse to forfeit control of their cars. Then there is to deal with the
concern about the real safety that the driverless cars would provide. One of
the main issues is the implementation of a legal framework and establishment
of government regulations for self-driving cars. Another obstacle is the ethical
problems in situations where an autonomous car’s software is forced to choose
between multiple harmful courses of action in a dangerous situation, and also
possibly insufficient adaptation to gestures and non-verbal cues by police and
pedestrians, to mention some examples.
Possible technological obstacles for autonomous cars are:
• Software reliability can not be ensured [15].
• Artificial Intelligence is not able to work properly in chaotic inner city
environments where the variables to take in consideration are a lot.
• A car computer could potentially have a fault, as could have a communica-
tion system between cars.
• The car’s sensing and navigation systems has susceptibility to different
external conditions or to deliberate interference, including jamming and
spoofing and thus could be hijacked.
• Autonomous cars may require high-quality maps to navigate properly.
Besides there has to be a default reasonable behaviour in the case these
maps may be out of date.
• The car need a radio frequency for communication leading to competition
for the spectrum.
• Driverless cars will require careful evaluation of product development and
the component supply chain.
• Current road infrastructure may be unsuitable or need changes for au-
tonomous cars to function optimally.
1.1.3 Present scenario
In a driverless car scenario a machine must be able to take a number of decisions
in real time, with a limited and possibly noisy perception of the environment.
Such decisions must take into account the need of abiding by the rules of the road
and the presence of other moving, possibly hardly predictable, agents (pedestrian,
bikers, other cars, either driverless or with a human driver).
3
Current traffic rules have been written for a scenario in which humans
drive cars and may hence be suboptimal in a driverless car scenario, or even in a
scenario where both machines and humans drive cars. In this work, traffic rules
has been taken a fresh look at and the possibility of devising a novel set of rules,
that are amenable to automation and, at the same time, able to improve global
indexes computed over the full population of vehicles, has been investigated. In
particular, it has been focused on optimizing the global traffic efficiency and
safety. It is thought that, broadly speaking, an approach of this kind could lead
to significant advantages to the society as a whole and that the driverless car
revolution could offer a unique opportunity in this respect.
1.2 Solution proposed
It has been proposed a framework based on Grammatical Evolution (GE) and
the contribution is as follows. First, it has been proposed and experimentally
evaluated a model for road traffic including the road graph, the cars, and the
rules-aware drivers who try to abide by, but can possibly evade, the rules; the
model is detailed enough to include concepts such as lanes, collisions, and safety
distance, which are significant to this study. Second, it has been proposed a
language to define rules which can be enforced in the model: rules are predicates
and the language is given in the form of a context-free grammar. Third and
finally, it has been proposed and experimentally evaluate a method for the
automatic synthesis of rules based on GE: individuals represent sets of rules
(i.e., regulations) and their fitness capture the degree to which, according to the
results of several simulations, traffic regulated by the set of rules is efficient and
safe.
The experimental evaluation shows that, using GE, it is possible to
obtain sets of rules which result in safer (less collisions) and more efficient
traffic, w.r.t. both unregulated traffic and a set of hand-written rules designed to
resemble a (simplified) real world set of rules. It is thought that no other studies
concerning the automatic synthesis of road traffic rules have been proposed
before.
Recent research has focused on how driverless cars should behave with
respect to the existing rules: by proposing flexible control strategies which mini-
mize the number of violated rules [17], by approaching the (highway) driverless
algorithm design with rules complying as a first goal (legal safety) [18], or by
formalizing rules for the sake of accountability after collisions involving driverless
cars [12].
A much deeper problem in this area consists in determining which
decision should be taken by a driverless car when facing a situation where only
less-than-ideal outcomes are possible [7, 6]. In such a case, the decision may
4
result in some sacrifice involving car users (passengers) or other people (e.g.,
pedestrians). This fundamental problem is orthogonal to this work.
Traffic is regulated not only by rules but also by the infrastructure, e.g.,
road markings and signs. In this area, several proposals have been made to modify
the working principle of traffic lights in order to avoid congestion (e.g., [19]),
also resorting to evolutionary computation [14]. More recently, motivated by
the emergence of more automated vehicles, Tachet et al. even proposed the
replacement of traffic lights with a novel (for road traffic) flow regulation solution
build upon slot-based systems [16].
From a more general point of view, automatic synthesis of rules is a task
which fits particularly well GE, since the language of the rules can be described
in terms of a grammar and candidate solutions may be evaluated by means
of simulated application of the corresponding set of rules: for instance, in [3]
GE has been used to generate trading rules for spot foreign-exchange markets.
Moreover, recent works showed that GE is suitable for addressing real problems
with complex grammars, such as learning of string similarity functions [2], or
designing components of vehicle routing algorithms [4].
5
Chapter 2
Road traffic model
2.1 Road traffic simulator
Traffic simulation or the simulation of transportation systems is the mathemati-
cal modeling of transportation systems (e.g., freeway junctions, arterial routes,
roundabouts, downtown grid systems, etc.) through the application of com-
puter software to better help plan, design and operate transportation systems.
Simulation of transportation systems started over forty years ago, and is an
important area of discipline in traffic engineering and transportation planning
today. Various national and local transportation agencies, academic institutions
and consulting firms use simulation to aid in their management of transportation
networks. The meaning of simulation in transportation is that through that it
become possible to study models too complicated for analytical or numerical
treatment. Also simulation can be used for experimental studies, can focus on
detailed relations that might be lost in analytical or numerical treatment and
can produce attractive visual demonstrations of present and future scenarios in
the field of transportation.
The concept of system state is the focus of the complete understanding
of simulation. The system state is a set of variables that contains enough
information to describe the evolution of the system over time. System state
can be either discrete or continuous. Traffic simulation models are classified
on the discrete or continuous values assumed by the variables: time, state,
and space. Employing a numerical method with a car-following model (such as
Gipps’ with Heun’s [5]) can generate important information for traffic conditions,
such as system delays and identification of bottlenecks. A class of microscopic
continuous-time models, known as car-following models, are models based on
differential equations. Significant models include the pipes, intelligent driver
6
model and Gipps’ model. They model the behavior of each individual vehicle
(“microscopic”) in order to see its implications on the whole traffic system
(“macroscopic”).
2.2 The model proposed
It has been considered a scenario with continuous space and discrete time in
which a number of cars move according to their driving algorithms. The model
used is based according with the car-following definition. Every vehicle in the
model has a fixed size in the sense of length because it is to be avoided to have
a road being occupied by an infinite number of accented vehicles. As far as
concerns the traffic simulator, there was to choose between two possible ways:
• Using an existing customizable model that was suitable for the task, and
then perform just the needed changes.
• Create a new road traffic simulator from scratch, with the chance to define
exactly all the desired features as well as keeping its structure as simple as
possible.
Some microscopic Open Source road traffic simulators has been developed for
transportation planning or traffic engineering. These models are available along
with their source code. However the simulators that matched most of the
specifications required for this study turned out to be the most complex.
Some of them have been analyzed to be used in this work, but in order
to obtain the desired features it has been considered a better solution to develop
a tailor-made model aimed to meet the specifications of the project, both in
terms of detail considered, but almost as far as concerns the driver algorithm
subject to road rules and vehicle collisions. Also starting from scratch, it was
easier to make a model that would fit as much as desired.
2.3 Roads and cars
2.3.1 The road graph
A road graph is a directed graph G = (S, I) in which edges represent road sections,
vertices represent road intersections, and where each vertex is connected to at least
two edges. A road section p ∈ S is characterized by a length l(p) ∈ R, l(p) > 0
and a width w(p) ∈ N, w(p) > 0: the former represents the length of the section
7
Figure 2.1: the small road graph used to estimate the goodness of the rules
generated during the evolution process. Blue dots represent the vehicles in the
simulation, and the red dots represent the collided vehicles that have not yet
been removed from the road graph. The road segments are defined by gray
rectangles delimited by black segments indicating lanes, dark gray balls indicate
the intersections road.
between two intersections and the latter represents the number of lanes in the
section. A road intersection p ∈ I is characterized by a size w(p) ∈ N, w(p) > 0:
without loss of generality, it is assumed that the size of an intersection is equal
to the largest width among the sections connecting the intersection.
2.3.2 The cars
A car is an agent which moves on the road graph. At a given time step, the car
is positioned somewhere on the road graph, i.e., its position can be determined in
terms of the section/intersection, lane and distance from the section/intersection
origin. The car movement is determined in terms of two speeds, i.e., along the
section and along the lanes—see Figure 2.3.
In detail, a car is a tuple (p, x, y, vx, vy, s) where p, x, y constitute the
position, vx ∈ R is the linear speed, vy ∈ {−1, 0, 1} is the lane-changing speed,
and s ∈ {alive, dead} is the status. Within the position, p ∈ S ∪ I is the section
or intersection where the car is. If p ∈ S, x ∈ [0, l(p)] and y ∈ {1, . . . , w(p)}
are the linear and lane coordinates of the car within the road section p—it is
assumed that x = 0 refers to the starting side of p. If p ∈ I, x ∈ [0, w(p)] is the
8
Figure 2.2: The big road graph used to estimate the ability of generalization of
an individual, that is, a set of rules obtained through GE, used on the small
road graph and then evaluated on the big road graph with more vehicles.
coordinate of the car within the intersection and y is not relevant.
It has been chosen to define a range of values for the maximum vehicles
speed in order to view the different behaviour of both faster and less fast vehicles
in the same simulation, subjected to the same algorithm, and also to differentiate
vehicles and thus introduce greater variability in the model. Cars acceleration
value has been kept the same for all vehicles and is equivalent to the speed of
braking.
2.3.3 Cars management in the simulator
At the initial time step of the simulation, the selected number of cars is positioned
in the road graph. The algorithm according to which the vehicles are settled
in the model will randomly select three road segments between all those in
the road graph and for the three selected segments it measure the maximum
distance between each pair of vehicles in it and place the new vehicle in the road
segment among them with more empty space. Each vehicle that is inserted in
the simulator starts with zero speed. In all the following time steps, vehicles are
inserted into the simulator whenever a condition occurs to remove a car and
replace it with a new one.
9
At each time step, if the status of a car is s = dead, the position is not
updated. To provide a situation similar to reality, each collided vehicle is kept
inside the simulator for an arbitrary number of time steps of the simulation, in
the position where it has collided. In this way, the stopped vehicle represents an
obstacle to the traffic flow, which all the other vehicles have to deal with.
At the end of the expected time steps the collided vehicle is removed
from the simulation. At each time step the simulator introduces in the simulation
a number of new vehicles equal to the number of collided ones that have been
removed.
Otherwise, if the status is s = alive, the position (p, x, y) of a car is
updated as follows. If p ∈ S and 0 ≤ x + vx ≤ l(p), then its position at the next
step is (p, x + vx, min(max(y + vy, 0), w(p))). Otherwise, if p ∈ S and x + vx < 0
or x + vx > l(p), then its position at the next step is (p , 0, 0), where p ∈ I
is the appropriate intersection between the two connected by p. Otherwise, if
p ∈ I and x + |vx| ≤ w(p) then its position at the next step is (p, x + |vx| , 0).
Otherwise and finally, if p ∈ I and x + |vx| > w(p), then its position at the
next step is (p , x0, y0), where p ∈ S is one of the sections connecting p and
x0 = 0, y0 = 0 or x0 = l(p ), y0 = w(p ) depending on whether p starts or ends
in p, respectively—in the latter case, if vx > 0, then at the next step it is set
to −vx. Concerning the choice of p , let {p1, . . . , pn} ⊆ S be the set of sections
connecting p, then p is set to pj, where j is chosen randomly in {1, . . . , n}. In
other words, a car moves on a section according to its speeds; whenever it reaches
the end (or the beginning) of the section, it enters the connected intersection.
While in an intersection, the car remains inside according to its linear speed
and the intersection size. When exiting an intersection, it enters a connecting
section.
At each time step, a collision may occur between a pair of cars. A
collision occurs if two cars meet on the same intersection or if two cars meet on
the same lane of the same road section. If a collision occurs, the status of the
two cars is set to dead. In detail, let (p
(k)
1 , x
(k)
1 , y
(k)
1 ) and (p
(k)
2 , x
(k)
2 , y
(k)
2 ) be the
positions of the two cars at time step k, a collision occurs at k if at least one of
the following conditions is met:
• p
(k)
1 = p
(k)
2 ∈ I and x
(k)
1 − x
(k)
2 < dcollision;
• p
(k)
1 = p
(k)
2 ∈ S and y
(k)
1 = y
(k)
2 and x
(k)
1 − x
(k)
2 < dcollision;
• p
(k)
1 = p
(k−1)
1 = p
(k)
2 = p
(k−1)
2 ∈ I and sign(x
(k)
1 − x
(k)
2 ) = sign(x
(k−1)
1 −
x
(k−1)
2 );
• p
(k)
1 = p
(k−1)
1 = p
(k)
2 = p
(k−1)
2 ∈ S and y
(k)
1 = y
(k)
2 and sign(x
(k)
1 − x
(k)
2 ) =
sign(x
(k−1)
1 − x
(k−1)
2 );
10
A
vx
vy
B
C
D
E
dcollision d
dview
y
0
1
2
3
x0 l(p)
Figure 2.3: A visualization of some of this model definitions. A car A is traveling
with a positive linear speed vx and a negative lane speed vy = −1 on a road
section on which there are other 4 cars. With respect to A, car C is the 1-
lane closest car, because it is on yC = 2 = yA + 1 and its distance from A
is ∆x ≤ dview; moreover, δv1 = opposite, since C is traveling in the opposite
direction w.r.t. A, and 1 = T, since C is closer than depsilon to A. There are
no other j-lane closest cars for A: in facts B is behind (not ahead) A, D is two
lanes away from A, and E distance to A is larger than dview.
• p
(k−1)
1 = p
(k−1)
2 ∈ I and p
(k)
2 = p
(k−1)
2 and p
(k)
1 = p
(k−1)
1 and x
(k−1)
1 ≤
x
(k−1)
2 ;
• p
(k−1)
1 = p
(k−1)
2 ∈ S and p
(k)
2 = p
(k−1)
2 and p
(k)
1 = p
(k−1)
1 and y
(k−1)
1 =
y
(k−1)
2 and v
(k)
x,1 > 0 and x
(k−1)
1 ≤ x
(k−1)
2 ;
• p
(k−1)
1 = p
(k−1)
2 ∈ S and p
(k)
2 = p
(k−1)
2 and p
(k)
1 = p
(k−1)
1 and y
(k−1)
1 =
y
(k−1)
2 and v
(k)
x,1 < 0 and x
(k−1)
1 ≥ x
(k−1)
2 ;
where dcollision is a parameter which represents the minimal distance between
two cars—note that with any dcollision > 0 the capacity of the road graph is
limited.
2.4 Driver
A driver is an algorithm according to which the linear and lane-changing speeds
of a car are updated. In particular, at each time step, the algorithm execution is
based on the processing of (a) a set of input variables, (b) a set of state variables,
(c) the driver’s car tuple, (d) a set of unmodifiable parameters and results in
(a) the output of a non-empty sequence of actions and (b) the modification of
the state variables.
11
2.4.1 The input variables
The input variables are based on the concept of j-lane closest car, with j ∈
{−1, 0, 1}. Each driver has a reference to the vehicles in the same lane and the
two adjacent lanes that are in front of it’s vehicle (referring to the vehicle’s
orientation along the road segment). The vehicles considered are at most 3 (the
closest ones), but if the driver’s vehicle is in one of the side lanes, the vehicles
detected are then at most 2 (the one in the same lane as the driver’s and the
one in the inner lane with respect to the driver’s lane). The vehicles behind the
driver’s car are not considered in this model (with respect to the driver’s car
orientation). In the case where the driver is crossing an intersection, each vehicle
present in the intersection with a position greater than the one of the driver’s
vehicle are considered ahead of the driver.
The j-lane closest car is the closest car ahead of the driver’s car on
the y + j lane such that its linear distance is ∆x < dview, where y is the lane of
the driver’s car and dview is a driver’s parameter. For the sake of brevity, it is
omitted a more formal definition, which covers also the case in which the driver’s
car is in (or close to) an intersection.
The cases analyzed only cover some of the real situations: in this model
a driver in a road segment sees the vehicles that are in front of him (regardless
of the direction of travel of these vehicles);
A driver in a road segment near an intersection sees vehicles within the
intersection; A driver that is crossing an intersection sees the vehicles in front
of him that are crossing the same intersection; A driver that is occupying an
intersection sees vehicles located in the road segments that start from the same
intersection and all vehicles that are traveling along adjacent road segments
starting from the intersection considered. A driver located in a road segment
near an intersection has no way of seeing any other vehicles traveling on other
road segments in the same direction (even in the other direction, but this second
case is not of interest), with the risk that more vehicles (possibly each one with
a different speed) are approaching the same intersection without being able to
prevent a situation that, without further measurements, may be the cause of
collisions, as the braking space may not be enough to stop. Note that the j-lane
closest car could not exist for some j, if no cars are closer than dview or there
is no y + j-th lane. The input variables are the following—see Figure 2.3 for a
visual interpretation of the variables.
• Three relative movement variables δv−1, δv0, and δv1. The value of δvj
is defined in {∅, opposite, −1, 0, 1} and is determined as follows. If there
is no j-lane closest car, then δvj = ∅. Otherwise, let (p , x , y , vx, vy, s )
the j-lane closest car: if sign vx = sign vx, then δvj = opposite, otherwise
δvj = sign (|vx| − |vx|). In other words, δvj says if there is a j-lane closest
12
car and, if any, if it moves in the opposite direction or, otherwise, is
becoming closer (δvj = −1), farther (δvj = 1), or has the same linear
speed, w.r.t. the driver’s car.
• Three closeness variables −1, 0, 1. The value of j is a boolean which is
true if and only if there is a j-lane closest car and its distance ∆x from the
driver’s car is ∆x ≤ d , where d < dview is a driver’s parameter. In other
words, j is set if the j-lane closest car, if any, is closer than a threshold.
If the vehicle is at a distance below the threshold then the driver must act
according to this information.
2.4.2 The state variables
The state variables include a single variable d ∈ R, d ≥ 0, which represents the
distance the driver still wants to go and which is updated at each time step as
d(k+1)
= d(k)
− |v
(k)
x |.
Each driver in the road graph has to cover an amount of distance during
the simulation. At each step, the remaining distance is updated according with
the speed of the vehicle and the distance covered in that time step. There is
no route for drivers to navigate, but once the amount of distance is covered,
the driver stops the vehicle and once it is stopped it is then removed from the
simulation and replaced with a new one. If a vehicle is involved in an accident
and the driver has not covered the total distance yet, the car will be removed
regardless of the fact that the travel has not been completed.
The parameters include dview, d (whose meaning was described above),
a value vmax ∈ R, vmax ≥ 0, and a value v∆ ∈ R, 0 < v∆ < vmax: vmax is
the maximum linear speed the driver’s car can reach and v∆ represents the
acceleration/deceleration of the driver’s car.
2.4.3 The output of the driver’s algorithm
The output of the driver’s algorithm is a non-empty sequence A of actions, i.e.,
an ordered subset of the set A of possible driver’s action, with A = {↑, , →
, ↓, , ←, , ∅}. An action determines how vx and vy are updated, as shown in
Table 2.1.
In other words, an up arrow corresponds to accelerating and a down
arrow corresponds to braking; a right arrow corresponds to moving on the right
lane and a left arrow corresponds to moving on the left lane, and so on. The
driver executes only one of the actions in A. At each time step of the simulation,
the driver must perform exactly one of the possible actions. The action which is
13
Table 2.1: Driver’s actions.
a ∈ A v
(k+1)
x v
(k+1)
y
↑ sign (v
(k)
x + v∆) min(|vmax| , v
(k)
x + v∆) 0
sign (v
(k)
x + v∆) min( v
(k)
x , v
(k)
x + v∆) − sign v
(k)
x
→ v
(k)
x − sign v
(k)
x
sign (v
(k)
x + v∆) max(0, v
(k)
x − v∆) − sign v
(k)
x
↓ sign (v
(k)
x + v∆) max(0, v
(k)
x − v∆) 0
sign (v
(k)
x + v∆) max(0, v
(k)
x − v∆) sign v
(k)
x
← v
(k)
x sign v
(k)
x
sign (v
(k)
x + v∆) min( v
(k)
x , v
(k)
x + v∆) sign v
(k)
x
∅ v
(k)
x 0
actually performed is chosen after processing A according to a procedure that
is detailed in Section 2.7 which takes traffic rules into account. The driver’s
algorithm is presented in the form of a multiway branch control in Table 2.2. The
rationale for the proposed algorithm is to resemble the behavior of a “reasonable”
driver who aims at traveling a distance d while avoiding trivial collisions: that
goal is pursued by—in essence—trying to travel at the max linear speed while
avoiding hitting other cars on the same lane. In detail, each row of Table 2.2
represents a proposition and the corresponding output A. The proposition is
composed of the conjunction of membership checks on input variables and on the
result of the comparison of the state variable d against xstop, which is defined
as xstop = kstopvx + 1
2 k2
stop − kstop v∆ where kstop = vx
v∆
; xstop represents
the distance the driver’s car would run if it constantly decrease its speed until
stopping. For instance, row 4 proposition is δv0 ∈ {−1, 0} ∧ 0 ∈ {F}, row 5
proposition is δv1 ∈ {∅, 1} ∧ δv0 ∈ {−1, 0} ∧ 1 ∈ {F} ∧ 0 ∈ {T}. The output
is determined as follows: if the row 1 proposition is true, then the output is the
row 1 A; otherwise, if the row 2 proposition is true, then the output is the row
2 A, and so on—note that the last row proposition is always true, hence it is
guaranteed that a non empty sequence is always output.
2.5 The performance indexes
• The first index is called average speed ratio (ASR) is the ratio between the
actual average speed dtot
ktot
a driver traveled at and the maximum theoretical
average speed vmax. The index average speed ratio is computed on all
vehicles in the simulator, and is calculated as the average value on 10
simulations for the same amount of traffic injected. A greater ratio is
14
Table 2.2: The driver’s algorithm.
δv1 δv0 δv−1 1 0 −1 d ≤ xstop A
1 ∀ ∀ ∀ ∀ ∀ ∀ {T} {↓, , }
2 {∅, 1} {∅, 1} {∅, 1} ∀ ∀ ∀ ∀ {↑, , , ∅, ↓}
3 ∀ {∅, 1} ∀ ∀ ∀ ∀ ∀ {↑, ∅, ↓}
4 ∀ {−1, 0} ∀ ∀ {F} ∀ ∀ {↑, ∅, ↓}
5 {∅, 1} {−1, 0} ∀ {F} {T} ∀ ∀ { , ∅, ↓}
6 ∀ {−1, 0} {∅, 1} ∀ {T} {F} ∀ { , ∅, ↓}
7 ∀ {0} ∀ ∀ {T} ∀ ∀ {∅, ↓}
8 ∀ {−1} ∀ ∀ {T} ∀ ∀ {↓}
9 ∀ {opposite} ∀ ∀ ∀ {F} ∀ {→, , ↓}
10 ∀ {opposite} ∀ {F} ∀ ∀ ∀ {←, , ↓}
11 ∀ {opposite} ∀ ∀ {T} ∀ ∀ { , , ↓}
12 ∀ ∀ ∀ ∀ ∀ ∀ ∀ {↓, , }
significant for greater traffic flow. Conversely, if you register a low index it
means the traffic is slow.
• The acceleration-per-time (ApT) is the ratio between the number nacceleration
of accelerations a car had during its travel and ktot, where nacceleration ∈ N.
It is computed as a counter for each vehicle, incremented each time a
driver performs an action that increase it’s vehicle speed, and it’s mediated
between all the cars in circulation, for each of the 10 simulations with the
same quantity of traffic injected. This index is indicative of the amount of
pollution produced by cars. For simplicity it is assumed that pollution is
greater when vehicles accelerate (and brake) often. In this respect, this
index should be kept as low as possible in order to reduce the pollution.
It is also possible to find a relationship between the first two indexes, the
average speed ratio and the acceleration-per-time, in fact in general: the
more the traffic flow is slow, the more vehicle accelerates (and brake) and
thus product more pollution.
• The collision-per-time (CpT) is the ratio between the number ncollision of
collisions a car had during its travel and ktot, where ncollision ∈ {0, 1}. it is
0 if the vehicle considered was not involved in any collision during the time
required for the total distance traveled (the vehicle lifetime), otherwise it
is worth 1 if the vehicle has collided. This value is mediated by all the
vehicles in circulation in the 10 simulations in which the same number of
vehicles is injected. The collision-per-time index is significant to represent
the safety of drivers who are in the simulator. The more this index is low
and the more the safety and the absence of collisions between vehicles
are guaranteed. There is a relationship between the index average speed
ratio and the collision-per-time since it is easier to prevent collisions if the
vehicles move slower. In other words if vehicles move slower, drivers can
15
handle in better ways dangerous situations.
From the two Figure 4.1 and Figure 4.2 it can be seen that an increase
of the number of vehicles in a simulation leads to a decrease to the average speed
ratio index that defines the traffic flow. The greater is the number of vehicles in
circulation and the more it is reasonable that a vehicle’s journey is hampered by
vehicles near this on the same lane, which force it to reduce speed. Conversely, if
the number of vehicles is low, each vehicle is free to cover the graph at maximum
speed.
Regarding the index acceleration-per-time, however, it has an opposite
curve with respect to the average speed ratio but with the same interpretation:
as the traffic increases, the vehicles are slower. Cars are forced to brake and
accelerate very often, as it occurs in real-time traffic in the most crowded cities
with higher pollution scores. In particular, the curve of the acceleration-per-time
index defines a behavior that seems to reverse the tendency to increase the
number of accelerations in accordance with the increase in the number of vehicles
in the simulator. At a given traffic value the curve comes down and this trend
can be explained by the fact that the number of vehicles is so high that the
number of collisions that occur will lower the average vehicle life and thus will
also decrease the time when they accelerate.
The collision-per-time index has a similar explanation with respect to
to the index acceleration-per-time. As the number of cars increases, it is likely
that collisions occur. On the contrary, if the graph is crossed by a few vehicles,
it is unlikely that two or more of them will collide. The curve of this index has
a monotonous trend and it is natural to imagine that the number of accidents is
mainly due to the amount of vehicles.
The trend for all three indexes above is the same in the two road graphs.
2.6 Rules
A traffic rule is a predicate defined on a set of variables concerning a car and its
driver, its j-lane closest cars, and the road graph. A car breaks a rule at a given
time step if the corresponding predicate is false.
The variables on which a traffic rule can be defined include: (a) variables
concerning the car and the corresponding driver: ˆvx, vmax, v∆, dview, d , p, ˆx,
and ˆy, where ˆvx = |vx|, ˆx = l(p) − x and ˆy = y, if vx ≥ 0, and ˆx = x and
ˆy = w(p) − y, otherwise; (b) variables concerning the car j-lane closest cars:
δv−1, δv0, δv1, ∆x−1, ∆x0, and ∆x1, where ∆xj is defined as in Section 2.4 and
is set to +∞ if the corresponding δvj = ∅; (c) variables concerning the road
graph section or intersection in which the car is: l(p) and w(p).
16
r ::= conditions
conditions ::= condition | conditions ∨ condition
condition ::= baseCondition | ¬ baseCondition
baseCondition ::= numericCondition | deltaCondition | graphCondition
numericCondition ::= numericVariable ≤ numericValue
numericVariable ::= ˆvx | vmax | v∆ | dview | d | ˆx | ˆy | ∆x−1 | ∆x0 | ∆x1 | l(p) | w(p)
numericValue ::= digit . digit e exp
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
exp ::= −1 | 0 | 1
deltaCondition ::= δv−1 = deltaValue | δv0 = deltaValue | δv1 = deltaValue
deltaValue ::= ∅ | opposite | − 1 | 0 | 1
graphCondition ::= p ∈ S
Figure 2.4: Backus-Naur Form of the context-free grammar for the traffic rules.
The set of possible traffic rules is defined by a context-free grammar
which it is presented with the Backus-Naur Form (r is the rule) in Figure 2.4.
For example, the rule stating that “the maximum speed of a car is 20”
is written as ˆvx ≤ 20. The rule stating that “the car should stay on the rightmost
free lane” is written as ˆy ≤ 0∨∆x−1 ≤ 10, where 10 represents a distance within
which a lane is not considered free. The rule stating that “the car should proceed
slowly when approaching an intersection” is written as ¬ˆx ≤ 20 ∨ ˆvx ≤ 10.
2.7 Rules-aware driver
A rules-aware driver is a driver that selects exactly one winning action out of a
sequence A = (a1, a2, . . . ) of actions, given a set R of traffic rules. In brief, a
rules-aware driver selects the action which, if repeated for the next steps, will
cause the least number of broken rules.
2.7.1 The prediction models
Four prediction models for the driver algorithm were proposed and developed.
Each one of the algorithms that are now described has the purpose of electing
one winning action from a list with priority of possible actions at any time steps,
considering as the only factor of choice the number of infringements to the rules
17
that will be caused in the future. In the process of choosing the winning action
to be performed no account is taken of collisions with other vehicles.
• The first model is called sameAction algorithm, and it performs a prediction
of the rules that will be broken in the next simulation step taking into
account that the driver will repeat the same action for each of the k future
time steps. Then the algorithm repeats the same algorithm for each of the
actions from the list provided to the driver at the first time step of the
prediction.
For example, if the driver is assessing the impact on the rules of the action
↑, then according to this model the driver will simulate to perform the
action ↑ for k steps and calculate the total number of broken rules for
that action. This kind of forecast seems reasonable especially when rules
concerns speed limits for the vehicle in a road sections.
• The second algorithm is called nullAction. This model assumes that the
driver will performs an action in the first of the future time steps of the
forecast and then simulate to execute the ∅ action for all the other future
time steps left. This corresponds to a prediction model in which the driver
maintains its parameters (speed, lane) unchanged during all the steps of
the forecast. As in the previous case, the prediction is performed for all
the actions in the list, and it choose the action that causes the lowest
number of broken rules. This model is similar to the sameAction algorithm,
in fact it’s strongly dependent on the k number of forecast steps. For
instance an action that is imagined to be fair as to brake when a speed
limit is encountered may not be a win if the number of forecast steps is
not sufficient to have a speed that respects the limits at the last step of
the prediction. All this is considered in the case of road rules dealing with
speed limits (both upper speed limit as well as lower speed limit). In the
case of handwritten rules these constraints on the cars speed have been
well defined, and it is possible that similar rules may also be created in
the case of rules obtained in another way.
• The third model is called smartAction, and it’s an algorithm that choose
at every step an action from the list of possible actions, and thus the
winning is the action that breaks the least number of rules. This algorithm
needs the evaluation of every possible sequence of actions that can be
performed for the k steps of prediction and therefore its computational
cost is high. The positive feature of this model, however, is that the driver
can create a sequence of actions so as to best fit the rules. Despite the high
performances regarding the number of broken rules, the computational
performance of the smartAction algorithm are not good enough to make
it emerge compared to other algorithm and thus it has been discarded
in favor of simpler and more reasonable models that could represent the
common sense and predictive behaviour of a human driver.
18
• The fourth model is called lazySmartAction, an algorithm that plans to
use the previous model of the smartAction with the difference that the
action taken at the previous step is placed in the first place with maximum
priority at the next step for each of the prediction steps. This algorithm
simplifies the choice of actions and provides a less costly model from the
computational point of view and performance similar to the smartAction
model.
In spite of this, the overall performance measured with the lazySmart in
term of computation has led to the predominance of the sameAction model, which
has been used in each prediction, both by hand-written rules and evolutionary
processes.
More in detail, the selection with the lazySmart algorithm is performed
as follows. First, for each action ai in A, the sequence Ai of future actions
consisting of ai repeated kadvance times is considered. Second, the number ni
of future broken rules caused by Ai is computed as the sum of the number of
rules that would be broken at each future step k + j, with 0 ≤ j ≤ |Ai|. Third
and finally, the winning action is determined as the action ai for which ni
|Ai |
is the lowest—in case of tie, the action with the lowest index in A is selected.
When computing ni, the rules-aware driver predicts the future variable values
assuming that: (i) the j-lane closest cars, if any, will maintain the same speeds
of step k; (ii) no other j-lane closest cars will appear; (iii) the driver’s car will
update consistently with the sequence of actions Ai. If a sequence Ai is such
that the future position p of the car changes, the sequence is truncated to the
last element before that change. For example, if a vehicle enters an intersection,
the prediction ends before exiting the road segment that is currently traveling.
The fourth index broken-rules-per-time is obtained as a counter for
each vehicle and it is incremented each time an action actually carried out by a
driver has caused the evasion of o rule. The number obtained is mediated on the
10 simulations considered and among all vehicles in circulation. This index has
to be minimized in order to get the highest respect of the traffic rules, but there
are cases in which any action performed causes the infringement of one or many
rules, or in a worst case it may even happen that two rules are contradictory
and the respect of one of them causes the evasion of the other. For these reasons,
recording this index is important for understanding the relationship between the
drivers and the rules inserted in the simulation.
As it can be seen from both road graphs in Figure 4.3 and Figure 4.4 by
introducing a handwritten set of rules, the average speed ratio index for both the
small road graph and the big road graphs is greatly reduced, for example drivers
are subjected to rules that force them to slow down under certain conditions
or maintain their speeds within a higher limit, which reduces the flow of traffic.
Conversely, by introducing hand written traffic rules, the collision-per-time index
decreases, hence the number of collisions is reduced considerably. The price to
19
pay for greater safety is therefore the speed with which vehicles are free to move,
but given the results worth it.
20
Chapter 3
Grammatical Evolution
Grammatical Evolution (GE) [13] is a form of grammar-based Genetic Program-
ming (GP) [8] which can evolve strings belonging to a language L(G) defined
by a context-free grammar G. In brief, GE operates on genotypes, which are
variable-length bit strings, maps them to phenotypes, which are strings of L(G),
and finally associates them with fitness values in R.
The genotype-phenotype mapping procedure is the distinguishing trait
of GE. In this procedure, the genotype is viewed as a variable-length integer
string where each i-th integer, called codon and denoted by gi, is obtained by
decoding bits from the (8(i − 1))-th to the (8i − 1)-th, included, in the genotype
g. The procedure is iterative and starts by setting the phenotype to p = s0,
s0 being the grammar starting symbol, a counter i to 0, and a counter w to 0.
Then, the following steps are iterated.
1. The leftmost non-terminal s in p is expanded using the j-th option (zero-
based indexing) in the production rule rs for s in G, with j being the
remainder of the division between the value gi of the i-th codon (zero-
based indexing) and the number |rs| of options in rs, i.e., j = gi mod |rs|.
2. The counter i is incremented by 1; if i exceeds the number of codons, i.e.,
if i > |g|
8 , then i is set to 0 and w is incremented by 1—the latter operation
is called wrapping and w represents the number of wraps performed during
the mapping.
3. If w exceeds a predefined threshold nw, the mapping is aborted, i.e., a
null phenotype is returned which will be associated to the worst possible
fitness.
4. If p contains at least one non-terminal to be expanded, return to step 1,
otherwise end.
21
The search engine of GE, i.e., the way in which the population of
individuals is updated across subsequent generations, is conventionally based
on Genetic Algorithms (GA). In Section 4.2 it is provided the evolutionary
parameters values which it has been used in the experimentation.
In order to adapt the general-purpose GE framework to a specific case,
one has to provide a grammar, which implicitly define the phenotype space, and
a fitness function f, which maps a phenotype to a number in R. In this case,
phenotypes are sets of rules and hence it has been modified the grammar of
Figure 2.4, which describes the language for defining a single rule r, by replacing
the first rule in order to make it defining a rule set R, as follows:
R ::= conditions | conditions ∧ conditions
Rules within a set or rules are separated by a conjunction ∧.
Concerning the fitness function, it has been aimed at defining a function
which captures two desired high-level objectives of a set R of road traffic rules:
(i) traffic flow regulated by R should allow car drivers to reach their destination
without taking too long time, i.e., with a large average speed, and (ii) traffic
flow regulated by R should result in no or few collisions. It can be noted that,
in principle, the two objectives are conflicting: for instance (and simplifying), a
set R imposing a very low speed limit will likely prevent many collisions, but
will cause long traveling times for all drivers; on the other hand, a set R not
imposing any speed limit will allow drivers to quickly reach their destination,
but will likely result in many collisions.
It has been implemented these high-level objectives by means of two
indexes which can be measured for each single driver. The average speed ratio
(ASR) and the collision-per-time (CpT). For the former index, the greater, the
better; the opposite for the latter. Hence, instead of ASR, it has been considered
1 − ASR, i.e., 1 − dtot
ktot
1
vmax
. It is associated a rule set R with a fitness value
which is a linear combination of the two indexes averaged across all cars ncar
during a number nsim of simulations:
f(R) = αtime
1
nsim
1
ncar cars
1 −
dtot
ktot
1
vmax
+ αcollision
1
nsim
1
ncar cars
ncollision
ktot
(3.1)
where αtime and αcollision are the weights.
22
Chapter 4
Experiments
Two experimental campaigns has been performed. The first one aimed at
validating this road traffic model. The second one aimed at verifying the
effectiveness of this GE-based approach for the synthesis of road traffic rules.
4.1 Validation of the road traffic model
It has been performed a number of simulations in order to validate the proposed
model for the road traffic scenario. In particular with interest in: (i) finding
appropriate values for the model (dcollision, dview, d , vmax, v∆, kadvance, and
all the values concerning the road graph) and simulation (d(0)
, ncar, kdead, and
kmax) parameters; (ii) verifying if the model behaves consistently when varying
the number of cars in the road graph; (iii) verifying if a set of manually crafted
rules causes a sound modification of the model behavior w.r.t. the absence of
rules. To this end, after an exploratory experimentation, it is set the values of
the parameters as shown in Table 4.1. In order to simulate different drivers, it is
set different values, chosen randomly according to a uniform distribution, for
the driver-related parameter vmax.
Each simulation has been performed by maintaining constant the num-
ber ncar of cars in the graph during the whole simulation. To this end, during
the simulation, it has been removed a car and added a new one in a random
position whenever at least one of the two following conditions was met: (a) the
driver’s state variable d (i.e., the distance the driver still wants to travel) became
lower or equal to zero, or (b) exactly kdead time steps passed since the car state
s switched from alive to dead, i.e., since the step when the car was involved in a
collision. Concerning the former condition, it is recalled that drivers do not have
23
Figure 4.1: The values assumed by three arbitrary indexes as the traffic varies,
evaluated on the small road graph. Each point in the plot is obtained as the
average value of 10 simulations performed with the same number of vehicles in
circulation. The three indexes considered represent the efficiency, safety and
efficiency of traffic within the graph.
Table 4.1: Model and simulation parameters.
Param. Meaning Value
dcollision Minimum distance between cars without collision 1
kremoval Time steps before collided cars remotion 100
dview Driver’s view distance 30
d Driver’s safety distance 10
vmax Driver’s maximum speed ∼ U(1.5, 3.5)
v∆ Driver’s acceleration (deceleration) 0.1
kadvance Driver’s rules forethought time steps 10
d(0)
Driver’s distance to travel (i.e., initial d) 2000
|S| Number of road sections 5
|I| Number of road intersections 4
w(p), p ∈ S Number of lanes ∈ {2, 3, 4}
l(p), p ∈ S Section length ∈ {100, 100
√
2}
ncar Cars in the simulation ∈ {2, 5, 8, 11, 14, 17, 20}
kdead Dead car removal time steps 100
kmax Simulation time steps 5000
24
Figure 4.2: This plot represents the same three indexes as in the previous graph.
This time the simulations are performed on the big road graph, with the same
criteria defined above.
a specific destination; instead, their goal is to travel for a predefined distance.
Table 4.2 shows the set of 8 rules that has been manually crafted in
order to resemble a (simplified) typical road traffic regulation. The set contains
rules regulating the driver’s behavior w.r.t. lane to stay on (i.e., “stay on the
right”, rules 1 and 2), rules stating how the driver’s should approach intersection
(3, 4, and 5), rules imposing a safety distance (6 and 7), and a rule prohibiting
speeding (8). The numeric values has been adjusted in the rules by exploratory
experimentation, with the aim of reducing the number of collisions while not
heavily affecting ASR.
Figure 4.5 shows the results of the first experimentation (along with
the results of the rules inference experimentation, discussed in the next section).
The figure shows the value of the two indexes (1 − ASR, left, and CpT, right)
vs. the number ncar in the simulation, that is, vs. the injected traffic. There is
one curve for each of the three following sets of rules: an empty set (no rules),
the set of rules of Table 4.2 (hand-written rules), and a set of generated rules
(best GE rules)— the results has been discussed corresponding to the first two
curves. Each point of the curve is obtained by averaging the values of the index
collected in 10 simulations.
Observing the plots of Figure 4.5, it can be seen that the relation
between the amount of traffic (ncar) and the two indexes looks sound, i.e.,
25
Figure 4.3: The two curves for each index, where each index is calculated on
the small graph. The indexes considered are the same as in the previous plots
(average speed ratio, acceleration-per-time, collision-per-time), but this time it is
also considered as fourth index the one that defines the evasion of road rules,
called broken-rules-per-time. Each of the two curves for each index represents:
The case where the vehicles are not subjected to any rule, as in the previous plots
(since now the indexes are four the rule violation index broken-rules-per-time is
always zero). The case with a set of rules in the simulator, dictated by common
sense, which imitate with some degree approximation the current rules of the
road.
26
Figure 4.4: The trend of the same indexes but this time considering the big road
graph.
Table 4.2: Hand-written rules.
Rule Explanation
1 ˆy ≤ 0.0e0 ∨ ∆x−1 ≤ 2.0e1 Stay on the rightmost free lane.
2 ˆy ≤ 1.0e0 Stay on the first or second rightmost lane.
3 ¬ˆx ≤ 3.0e1 ∨ ˆvx ≤ 1.5e0 When close to end of (inter)section, proceed
slowly.
4 ¬ˆx ≤ 2.0e1 ∨ ˆvx ≤ 0.5e0 When closer to end of (inter)section, proceed
more slowly.
5 ¬ˆx ≤ 3.0e1 ∨ ˆy ≤ 0.0e0 When close to end of (inter)section, stay on
the rightmost lane.
6 ¬∆x0 ≤ 2.0e1 Do not travel too close to the preceding car.
7 ¬ˆvx ≤ 0 ∨ ∆x0 ≤ 2.0e1 When too close to the preceding car, stop.
8 ˆvx ≤ 2.4e0 Do not exceed a maximum speed.
27
5 10 15 20
0
0.2
0.4
0.6
0.8
ncar
1−ASR
5 10 15 20
0
2
4
6
·10−3
ncar
CpT
No rules Hand-written rules Best GE rules
Figure 4.5: Values of the two indexes vs. the number ncar of cars in the simulation,
obtained by performing 10 simulation for each value of ncar and each of the three
set of rules.
consistent with what happens in real world road traffic: the greater the number
of traveling cars, the lower the average speed (i.e., the longer the time to
destination) and the greater the overall number of collisions. From another point
of view, there is a trade-off between efficiency and safety of the road traffic, like
in the real world.
Moreover, by comparing the curves related to no rules and hand-written
rules, it can be seen that enforcing a road traffic regulation results in a different
point in the above-mentioned trade off: with the hand-written rules traffic is
in general less efficient but safer. This findings suggest that the models for the
road graph, the car, and the driver are sufficiently consistent with the real word
and hence adequate to investigate the feasibility of an automatic synthesis of
road traffic rules.
4.2 Synthesis of traffic rules
In the second experimental campaign, the feasibility of the automatic synthesis of
traffic rules has been investigated using GE. To this end, 30 different evolutionary
searches has been ran using the parameters shown in Table 4.3 and, concerning
the fitness function (see Equation 3.1), setting ncar = 10, nsim = 10, αtime = 1,
and αcollision = 100. For the weights αtime and αcollision, the values has been
chosen according to the results of the experimentation discussed in the previous
section and reflecting the intuition that minimizing collisions is more important
than maximizing the average speed.
The set of rules which obtained the best fitness among the final gen-
erations of the 30 runs has been first analyzed extensively, which is shown in
Table 4.4 and discussed later. It has been experimentally verified how this set of
best GE rules affected the traffic with different amounts of injected traffic by
28
Figure 4.6: The indexes (average speed ratio, acceleration-per-time, collision-per-
time, broken-rules-per-time) with respect to the variation of traffic injected on
the small graph used for evolution. Each of the three curves represents: the case
without rules in the simulation, the case of hand written rules, the case of the
evolved rules obtained with GE.
Table 4.3: GE parameters.
Population 100
Generations 100
Initial genotype size 512
Max wraps 10
Crossover rate 0.9
Crossover operator Two-points
Mutation operator Bit flip with pmut = 0.01
Selection Tournament with size 5
29
Figure 4.7: The trend of the 4 indexes (average speed ratio, acceleration-per-time,
collision-per-time, broken-rules-per-time) on the big road graph.
30
1 2 3 4 5 6
·104
0
200
400
Overall distance
Overallcollisions
No rules
Hand-written rules
Best GE rules
Figure 4.8: Overall number of collisions in the simulation against the overall
traveled distance in the simulation averaged across simulations with the same
ncar.
running 10 simulations for each value of ncar ∈ {2, 5, 8, 11, 14, 17, 20}. In other
words, since GE rules were generated with ncar = 10, the generalization ability
of the rules synthesis approach has been evaluated. The results are shown in
Figures 4.5 and 4.8.
Figure 4.5 shows the values of the two indexes (1 − ASR and CpT)
vs. ncar for the three set of rules: no rules, hand-written rules, and best GE
rules. It can be seen that the generated rules always obtain better index values
w.r.t. hand-written rules, for both 1−ASR and CpT—the difference being always
statistically significant (p < 0.001 with the Mann–Whitney U test) with the sole
exception of CpT for ncar = 2, for which p < 0.05. That is, GE rules allow to
reduce the number of collisions and increase the average speed.
Figure 4.8 shows the same results of Figure 4.5 from another point
of view, by plotting the overall number of collisions in the simulation (i.e.,
ncollision, on y-axis) against the overall traveled distance in the simulation
(i.e., dtot, on x-axis), averaged across simulations with the same ncar, one
curve for each set of rules. The figure allows to appreciate the trade-off between
traffic efficiency and safety: the larger the overall distance, the larger the overall
number of collisions. However, it can also be seen that the curve of GE rules
strictly dominates both the other two curves (no rules and hand-written rules),
hence suggesting that GE rules may be a better way of regulating road traffic
regardless of the amount of cars in the graph—i.e., not only for the ncar for
which the GE rules were generated. This latter finding seems to confirm the
good generalization ability of this approach.
Figure 4.8 also shows another interesting property of the traffic model,
namely it highlights the congestion condition. In facts, in both the cases where
the traffic is regulated (hand-written and GE rules), there is a maximum number
of cars in the graph (ncar = 17) after which no further increasing in the overall
distance can be obtained, while an increasing in overall number of collisions
occurs. Interestingly, despite the fact that the maximum injected traffic before
31
Table 4.4: Best GE rules.
Rule Possible explanation
1 ∆x−1 ≤ 4.8e0 Stay within some distance from the car on right
lane.
2 ¬ˆvx ≤ 1.1e1 Maintain at least a minimum speed.
3 ¬δv0 = opposite ∨ δv0 =
1∨ ¬p ∈ S ∨ ∆x0 ≤ 0.3e1
When in an section, stay close to a car coming
on the same lane.
4 ˆvx ≤ 1.2e0 Do not exceed a maximum speed.
congestion in the two cases is the same, with GE rules the resulting overall
distance is greater and the resulting overall number of collisions is smaller.
Table 4.4 shows in detail the best GE rules: it can be seen that the
set consists of four rules, one of which (the 2nd) is clearly always broken in the
simulations, since it tries to impose a minimum linear speed which cannot be
reached with the parameters shown in Table 4.1. Rule 4 is easily understandable
and its inclusion in best individual is not surprising. The role, if any, of rules
1 and 3 on the drivers’ behavior is not clear. Rule 3 is hard to understand,
i.e., hard to translate in natural language: the third disjunction says that the
remaining part of the rule applies only when the car is in a section (since if
p ∈ I ≡ p ∈ S, the rule is true); the first and second disjunctions can be
rewritten as δv0 ∈ {∅, −1, 0, 1}, hence resulting in the rule being writable as
(p ∈ S ∧ δv0 = opposite) =⇒ ∆x0 ≤ 3. However, due to the driver’s algorithm
(see Table 2.2) and the value of the parameter d (see Table 4.1), it is unlikely
that rule 3 plays an actual role in determining drivers’ behavior.
The analysis of the rules of Table 4.4 may suggest that some mechanism
for detecting and cleaning ineffective rules may be beneficial in order to (i) increase
the readability/understandability of the generated rules, and (ii) improve the
evolutionary search. While can’t be made any meaningful prediction in this
respect, it has been observe that, for the former goal, some automatic and
domain-specific heuristic applied after the evolution may suffice—indeed a similar
approach have been applied in [10] in the field of the automatic generation of
rules for security policies.
This experimental results has been evaluated by looking at how indi-
viduals evolved across the 30 runs. Figure 4.10 summarizes the results of the
evolutionary searches in terms of the fitness of the best individual in the popula-
tion. In particular, Figure 4.10a shows how the average (across all runs) best
individual fitness varies during the evolution; Figure 4.10b shows the histogram
of the best individual fitness at the end of the evolution.
It can be seen from Figure 4.10a that GE is in general able to decrease
the fitness of individuals during the evolution: however, after approximately
32
Figure 4.9: The fitness shape for the best individual of each of the 30 run of GE.
0 20 40 60 80 100
0.94
0.96
0.98
1
1.02
Generation
Fitnessf(R)
(a) Average best fitness during evolution.
0.7 0.8 0.9 1
0
10
20
Best fitness
Num.ofruns
(b) Best fitness histogram.
Figure 4.10: Fitness of the best individual: during the evolution, averaged across
the 30 runs, on the left; histogram w.r.t. the 30 runs at the end of the evolution,
on the right.
33
20 generations, fitness decreases much more slowly. Some improvement to
evolutionary search might be obtained by finely tuning the GE-related parameters,
or maybe by using a different variant of GE (e.g., [11, 9]). However, it has been
noted that this scenario is characterized by a remarkably high stochasticity
which could, at least, slow down the search of a good solution and, from a more
practical point of view, makes experimentation and parameter tuning costly
due to the long time needed to compute the fitness. In this case, running a
single simulation took ≈ 10 s on commodity hardware and computing the fitness
of a single individual (i.e., a set of rules) consisted in running 10 simulations,
precisely to mitigate the impact of the high stochasticity in the simulations.
Figure 4.10b shows the histogram of the best individual fitness at the
end of the evolution across the 30 runs. It can be seen that most of the runs
resulted in fitness values close to 1, i.e., the distribution is skewed toward bad
values. The details of the runs has been analyzed and found that in some of
those cases the search got stuck in a local minimum corresponding to a set of
rules including one or more rules which, in practice, enforce drivers to stand still.
Under those rules, no collision occurs (CpT = 0) and no one moves (ASR = 0),
which is, clearly, one extreme of the trade-off between traffic efficiency and safety.
34
Chapter 5
Concluding remarks and
future work
It has been proposed and assessed experimentally, by an extensive set of sim-
ulations, a method for synthesizing automatically a set of road traffic rules
with the aim of maximizing such global indexes as road efficiency (high average
speed) and safety (low number of collisions). The motivation for this work is
a future scenario in which human and machine-based drivers will coexist on
the roads, making current road regulation possibly unsuitable or inefficient. No
other similar proposal exist, to the best of our knowledge.
The method proposed is based on GE: individuals are sets of rules
written according to a context-free grammar that has been designed ad hoc to
express quite expressive concepts such as, e.g., “stay on the rightmost free lane”
or “slow down when approaching an intersection”. The fitness of a candidate set
of rules is given by a weighted sum of the traffic efficiency and safety resulting
from the application of the rules set in a number of simulations, which makes
this GE application highly stochastic.
Results of the experimental evaluation are promising, since generated
rules result in simulated road traffic which is more efficient and safer than that
regulated by hand-written rules or not regulated at all.
This work may be extended in different ways, such as: (i) including
a more fine-grained model (e.g., concerning intersections); (ii) considering a
different way for expressing rules (e.g., with Linear Temporal Logic); (iii) better
exploring GE parameters and/or variants.
35
Bibliography
[1] road Automated Vehicle Standards Committee, O., et al.: Sae j3016: Tax-
onomy and definitions for terms related to on-road motor vehicle automated
driving systems. SAE International
[2] Bartoli, A., De Lorenzo, A., Medvet, E., Tarlao, F.: Syntactical similar-
ity learning by means of grammatical evolution. In: Handl, J., Hart, E.,
Lewis, P.R., L´opez-Ib´a˜nez, M., Ochoa, G., Paechter, B. (eds.) Parallel
Problem Solving from Nature – PPSN XIV: 14th International Confer-
ence, Edinburgh, UK, September 17-21, 2016, Proceedings. pp. 260–269.
Springer International Publishing, Cham (2016), http://dx.doi.org/10.
1007/978-3-319-45823-6_24
[3] Brabazon, A., O’Neill, M.: Evolving technical trading rules for spot foreign-
exchange markets using grammatical evolution. Computational Management
Science 1(3-4), 311–327 (2004)
[4] Drake, J.H., Kililis, N., ¨Ozcan, E.: Generation of vns components with
grammatical evolution for vehicle routing. In: European Conference on
Genetic Programming. pp. 25–36. Springer (2013)
[5] Gipps, P.G.: A behavioural car-following model for computer simulation.
Transportation Research Part B: Methodological 15(2), 105–111 (1981)
[6] Greene, J.D.: Our driverless dilemma. Science 352(6293), 1514–1515 (2016)
[7] Kirkpatrick, K.: The moral challenges of driverless cars. Commun. ACM
58(8), 19–20 (Jul 2015), http://doi.acm.org/10.1145/2788477
[8] Koza, J.R.: Genetic programming: on the programming of computers by
means of natural selection, vol. 1. MIT press (1992)
[9] Louren¸co, N., Pereira, F.B., Costa, E.: Sge: a structured representation for
grammatical evolution. In: International Conference on Artificial Evolution
(Evolution Artificielle). pp. 136–148. Springer (2015)
[10] Medvet, E., Bartoli, A., Carminati, B., Ferrari, E.: Evolutionary infer-
ence of attribute-based access control policies. In: Gaspar-Cunha, A.,
36
Henggeler Antunes, C., Coello, C.C. (eds.) Evolutionary Multi-Criterion
Optimization: 8th International Conference, EMO 2015, Guimar˜aes, Portu-
gal, March 29 –April 1, 2015. Proceedings, Part I. pp. 351–365. Springer
International Publishing, Cham (2015), http://dx.doi.org/10.1007/
978-3-319-15934-8_24
[11] O’Neill, M., Brabazon, A., Nicolau, M., Mc Garraghy, S., Keenan, P.:
πgrammatical evolution. In: Genetic and Evolutionary Computation Con-
ference. pp. 617–629. Springer (2004)
[12] Rizaldi, A., Althoff, M.: Formalising traffic rules for accountability of
autonomous vehicles. In: 2015 IEEE 18th International Conference on
Intelligent Transportation Systems. pp. 1658–1665. IEEE (2015)
[13] Ryan, C., Collins, J., O’Neill, M.: Grammatical evolution: Evolving pro-
grams for an arbitrary language. In: European Conference on Genetic
Programming. pp. 83–96. Springer (1998)
[14] Sanchez, J.J., Galan, M., Rubio, E.: Applying a traffic lights evolutionary
optimization technique to a real case: “las ramblas” area in santa cruz de
tenerife. IEEE Transactions on Evolutionary Computation 12(1), 25–40
(Feb 2008)
[15] Shepardson, D.: Study: Self-driving cars to jolt market by 2035. The Detroit
News (2013)
[16] Tachet, R., Santi, P., Sobolevsky, S., Reyes-Castro, L.I., Frazzoli, E., Helbing,
D., Ratti, C.: Revisiting street intersections using slot-based systems. PLoS
one 11(3), e0149607 (2016)
[17] Tumova, J., Hall, G.C., Karaman, S., Frazzoli, E., Rus, D.: Least-violating
control strategy synthesis with safety rules. In: Proceedings of the 16th
International Conference on Hybrid Systems: Computation and Control.
pp. 1–10. HSCC ’13, ACM, New York, NY, USA (2013), http://doi.acm.
org/10.1145/2461328.2461330
[18] Vanholme, B., Gruyer, D., Lusetti, B., Glaser, S., Mammar, S.: Highly
automated driving on highways based on legal safety. IEEE Transactions
on Intelligent Transportation Systems 14(1), 333–347 (2013)
[19] Wen, W.: A dynamic and automatic traffic light control expert system for
solving the road congestion problem. Expert Systems with Applications
34(4), 2370–2381 (2008)
37

More Related Content

Similar to Road traffic rules synthesis using ge

finalReport
finalReportfinalReport
finalReport
Samuel Mitchell
 
Ieeepro techno solutions ieee 2014 embedded project gps-copilot real-time ...
Ieeepro techno solutions    ieee 2014 embedded project gps-copilot real-time ...Ieeepro techno solutions    ieee 2014 embedded project gps-copilot real-time ...
Ieeepro techno solutions ieee 2014 embedded project gps-copilot real-time ...
srinivasanece7
 
Obstacle Detection and Collision Avoidance System
Obstacle Detection and Collision Avoidance SystemObstacle Detection and Collision Avoidance System
Obstacle Detection and Collision Avoidance System
IRJET Journal
 
Simulation of traffic engg.
Simulation of traffic engg.Simulation of traffic engg.
Simulation of traffic engg.
vijay reddy
 
virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...
virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...
virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...
Uvaiz2
 
Smart cars (1)
Smart cars (1)Smart cars (1)
Smart cars (1)
Itcs399
 
Left Turn Display Mechanism for Facilitating Left Hand Turns
Left Turn Display Mechanism for Facilitating Left Hand TurnsLeft Turn Display Mechanism for Facilitating Left Hand Turns
Left Turn Display Mechanism for Facilitating Left Hand Turns
Ali Vira
 
IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...
IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...
IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...
IRJET Journal
 
Development and testing of braking and acceleration features for vehicle adv...
Development and testing of braking and acceleration features  for vehicle adv...Development and testing of braking and acceleration features  for vehicle adv...
Development and testing of braking and acceleration features for vehicle adv...
IJECEIAES
 
Report_Jeremy_Berard
Report_Jeremy_BerardReport_Jeremy_Berard
Report_Jeremy_Berard
Jeremy Bernard
 
Aalto_Thesis_Ayman
Aalto_Thesis_AymanAalto_Thesis_Ayman
Aalto_Thesis_Ayman
Ayman Elkadi
 
Safe Driving Advisor and Evaluator.pptx
Safe Driving Advisor and Evaluator.pptxSafe Driving Advisor and Evaluator.pptx
Safe Driving Advisor and Evaluator.pptx
Hazem Fahmy
 
Driver-less cars by avaneesh shuka
Driver-less cars by avaneesh shuka Driver-less cars by avaneesh shuka
Driver-less cars by avaneesh shuka
avaneesh shukla
 
LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...
LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...
LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...
cscpconf
 
Robot cars
Robot carsRobot cars
Robot cars
Raghava Lagudu
 
Deep neural network for lateral control of self-driving cars in urban environ...
Deep neural network for lateral control of self-driving cars in urban environ...Deep neural network for lateral control of self-driving cars in urban environ...
Deep neural network for lateral control of self-driving cars in urban environ...
IAESIJAI
 
Telsa auto pilot
Telsa auto pilotTelsa auto pilot
Telsa auto pilot
KRoshni
 
Autonomous driving system (ads)
Autonomous driving system (ads)Autonomous driving system (ads)
Autonomous driving system (ads)
Justin Jacob
 
Ijett v5 n1p108
Ijett v5 n1p108Ijett v5 n1p108
Ijett v5 n1p108
Athulya MB
 
final_report
final_reportfinal_report
final_report
Devon Bates
 

Similar to Road traffic rules synthesis using ge (20)

finalReport
finalReportfinalReport
finalReport
 
Ieeepro techno solutions ieee 2014 embedded project gps-copilot real-time ...
Ieeepro techno solutions    ieee 2014 embedded project gps-copilot real-time ...Ieeepro techno solutions    ieee 2014 embedded project gps-copilot real-time ...
Ieeepro techno solutions ieee 2014 embedded project gps-copilot real-time ...
 
Obstacle Detection and Collision Avoidance System
Obstacle Detection and Collision Avoidance SystemObstacle Detection and Collision Avoidance System
Obstacle Detection and Collision Avoidance System
 
Simulation of traffic engg.
Simulation of traffic engg.Simulation of traffic engg.
Simulation of traffic engg.
 
virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...
virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...
virtual-system-integration-and-early-functional-validation-in-the-whole-vehic...
 
Smart cars (1)
Smart cars (1)Smart cars (1)
Smart cars (1)
 
Left Turn Display Mechanism for Facilitating Left Hand Turns
Left Turn Display Mechanism for Facilitating Left Hand TurnsLeft Turn Display Mechanism for Facilitating Left Hand Turns
Left Turn Display Mechanism for Facilitating Left Hand Turns
 
IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...
IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...
IRJET- Artificial Intelligence Based Smart Traffic Management System using Vi...
 
Development and testing of braking and acceleration features for vehicle adv...
Development and testing of braking and acceleration features  for vehicle adv...Development and testing of braking and acceleration features  for vehicle adv...
Development and testing of braking and acceleration features for vehicle adv...
 
Report_Jeremy_Berard
Report_Jeremy_BerardReport_Jeremy_Berard
Report_Jeremy_Berard
 
Aalto_Thesis_Ayman
Aalto_Thesis_AymanAalto_Thesis_Ayman
Aalto_Thesis_Ayman
 
Safe Driving Advisor and Evaluator.pptx
Safe Driving Advisor and Evaluator.pptxSafe Driving Advisor and Evaluator.pptx
Safe Driving Advisor and Evaluator.pptx
 
Driver-less cars by avaneesh shuka
Driver-less cars by avaneesh shuka Driver-less cars by avaneesh shuka
Driver-less cars by avaneesh shuka
 
LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...
LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...
LANE CHANGE DETECTION AND TRACKING FOR A SAFE-LANE APPROACH IN REAL TIME VISI...
 
Robot cars
Robot carsRobot cars
Robot cars
 
Deep neural network for lateral control of self-driving cars in urban environ...
Deep neural network for lateral control of self-driving cars in urban environ...Deep neural network for lateral control of self-driving cars in urban environ...
Deep neural network for lateral control of self-driving cars in urban environ...
 
Telsa auto pilot
Telsa auto pilotTelsa auto pilot
Telsa auto pilot
 
Autonomous driving system (ads)
Autonomous driving system (ads)Autonomous driving system (ads)
Autonomous driving system (ads)
 
Ijett v5 n1p108
Ijett v5 n1p108Ijett v5 n1p108
Ijett v5 n1p108
 
final_report
final_reportfinal_report
final_report
 

Recently uploaded

Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 

Recently uploaded (20)

Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 

Road traffic rules synthesis using ge

  • 1. Road Traffic Rules Synthesis using Grammatical Evolution Master Degree in Computer Engineering University of Trieste Italy 07-06-2017 Author: Jacopo Talamini Supervisor: prof. Eric Medvet Co-Supervisors: prof. Alberto Bartoli prof. Lorenzo Castelli
  • 2. Contents 1 Introduction and related work 1 1.1 Driverless Cars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 Classification of driverless cars . . . . . . . . . . . . . . . 2 1.1.2 Benefits and issues of driverless cars . . . . . . . . . . . . 2 1.1.3 Present scenario . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Solution proposed . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 Road traffic model 6 2.1 Road traffic simulator . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 The model proposed . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3 Roads and cars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3.1 The road graph . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3.2 The cars . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.3.3 Cars management in the simulator . . . . . . . . . . . . . 9 2.4 Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.4.1 The input variables . . . . . . . . . . . . . . . . . . . . . . 12 2.4.2 The state variables . . . . . . . . . . . . . . . . . . . . . . 13 2.4.3 The output of the driver’s algorithm . . . . . . . . . . . . 13 1
  • 3. 2.5 The performance indexes . . . . . . . . . . . . . . . . . . . . . . 14 2.6 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.7 Rules-aware driver . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.7.1 The prediction models . . . . . . . . . . . . . . . . . . . . 17 3 Grammatical Evolution 21 4 Experiments 23 4.1 Validation of the road traffic model . . . . . . . . . . . . . . . . . 23 4.2 Synthesis of traffic rules . . . . . . . . . . . . . . . . . . . . . . . 28 5 Concluding remarks and future work 35 2
  • 4. Abstract In questo lavoro `e stato considerato uno scenario futuro in cui i conducenti umani e artificiali coesisteranno sulle strade, e in cui le vigenti regole di cir- colazione risulteranno inadeguate o inefficienti. Per affrontare tale scenario `e stata considerata la sintesi automatica di regole del traffico stradale utilizzando Grammatical Evolution (GE). `E stato sviluppato quindi un simulatore di traffico stradale per validare le regole ottenute. Questo simulatore consente ai guidatori di eludere le regole del traffico nel caso in cui non vi siano alternative migliori. Ogni individuo di GE `e un insieme di regole e la sua fitness `e calcolata come una somma ponderata dell’efficienza e della sicurezza del traffico, risultante da una serie di simulazioni in cui tutti i conducenti sono soggetti alle stesse regole. I risultati sperimentali ottenuti mostrano che questo approccio genera regole che portano a un traffico pi`u sicuro e pi`u efficiente rispetto al caso in cui non si applicano delle regole. Inoltre, le regole ottenute sperimentalmente si sono dimostrate ancor pi`u idonee, rispetto ai parametri considerati, di altre regole simili a quelle attualmente utilizzate.
  • 5. Abstract In this work has been considered a future scenario in which human and machine- based driver will coexist on the roads, causing the current road rules to result unsuitable or inefficient. The automatic synthesis of road traffic rules has been considered in order to deal with such scenario using Grammatical Evolution (GE). A road traffic simulator has been developed to validate the rules obtained. This simulator allows drivers to evade traffic rules when there are no better alternatives. Each GE individual is a set of rules and its fitness is computed as a weighted sum of traffic efficiency and safety, as resulting from a number of simulations where all drivers are subjected to the same rules. Experimental results show that this approach indeed generates rules leading to a safer and more efficient traffic than enforcing no rules. Moreover this rules have been proved to be even more suitable, with respect to the considered parameters, than other ones similar to those currently used.
  • 6. Chapter 1 Introduction and related work Car driving is one of the tasks that in a not far away future will be carried out by machines, rather than by humans. 1.1 Driverless Cars Driverless car are vehicles that are able to navigate without the need of human intervention. In recent years many automotive companies like Tesla, Toyota, BMW, Ford, Nissan, Volvo, but also different companies like Google and Uber have invested resources in the driverless car development field and some relevant results have been obtained so far. Notwithstanding the numerous prototypes available, a scenario in which cars can drive in full autonomy is not yet feasible. Driverless cars, also called autonomous vehicles, are equipped with sensors such as radar and other devices aimed at measuring distances and speeds of other vehicles or obstacles on the track-way. They have also computer vision systems to recognize roadway lines on the asphalt in order to navigate into the lane but also to detect the grip of the terrain and handle properly the engine effort and performances. Finally driver-less cars use Global Positioning System (GPS) modules to track routes and calculate vehicle position. These and many more are the distinctive traits of driverless vehicles: more and more complex intelligence (software) on board, intended to replace the perception, view, and predictive behaviour of the human driver with the sensors inside the Engine Control Unit (ECU). These computers are way faster and 1
  • 7. more efficient than human brain, and nowadays some of their features are used in many commercial cars models in order to provide better driving experiences. At present time cars are equipped with many distinctive components of autonomous vehicles, but navigation is still the role of the human driver. 1.1.1 Classification of driverless cars SAE International has provided a description of the autonomous vehicles through the J3016 standard issued in 2014 [1]. This standard defines a classification based on various levels of vehicle autonomy. The classification is based on the assessment of the human intervention required: • Level 0 (No autonomy): the human driver must take care of all aspects of the ride, even when assisted by machine systems. • Level 1 (Driving assistance): the machine can accelerate or brake and steer itself in a number of situations, but the human driver must be ready to take control back at any time. • Level 2 (Partial Automation): accelerating, braking and steering are actions left entirely to the machine, but the human driver must take care of monitoring the surrounding environment in each case. • Level 3 (Conditioning Automation): accelerating, braking, steering, but also monitoring of the surrounding environment are tasks depending on the machine, but the human driver must be ready to intervene when requested by the system. • Level 4 (High Automation): the automatic system in the machine can han- dle any event, but it should not be activated in extreme driving situations such as bad weather conditions. • Level 5 (Complete Automation): the automatic system in the machine is capable of handling all the situations that a person can handle, so there is no need for human intervention of any kind. 1.1.2 Benefits and issues of driverless cars The benefits of introducing autonomous vehicles are a lot, and they range from enhanced safety both for the driver and for other vehicles, to the driving assistance provided to the driver, and eventually to an improvement of the traffic flow and thus reduction of vehicle emissions and less pollution produced by cars. 2
  • 8. Despite the various benefits to increased vehicle automation, some issues still persist, such as disputes concerning liability, or concerning the time needed to convert the existing stock of vehicles from traditional cars to autonomous ones. Another issue is that driverless car concept has to face the resistance of people that refuse to forfeit control of their cars. Then there is to deal with the concern about the real safety that the driverless cars would provide. One of the main issues is the implementation of a legal framework and establishment of government regulations for self-driving cars. Another obstacle is the ethical problems in situations where an autonomous car’s software is forced to choose between multiple harmful courses of action in a dangerous situation, and also possibly insufficient adaptation to gestures and non-verbal cues by police and pedestrians, to mention some examples. Possible technological obstacles for autonomous cars are: • Software reliability can not be ensured [15]. • Artificial Intelligence is not able to work properly in chaotic inner city environments where the variables to take in consideration are a lot. • A car computer could potentially have a fault, as could have a communica- tion system between cars. • The car’s sensing and navigation systems has susceptibility to different external conditions or to deliberate interference, including jamming and spoofing and thus could be hijacked. • Autonomous cars may require high-quality maps to navigate properly. Besides there has to be a default reasonable behaviour in the case these maps may be out of date. • The car need a radio frequency for communication leading to competition for the spectrum. • Driverless cars will require careful evaluation of product development and the component supply chain. • Current road infrastructure may be unsuitable or need changes for au- tonomous cars to function optimally. 1.1.3 Present scenario In a driverless car scenario a machine must be able to take a number of decisions in real time, with a limited and possibly noisy perception of the environment. Such decisions must take into account the need of abiding by the rules of the road and the presence of other moving, possibly hardly predictable, agents (pedestrian, bikers, other cars, either driverless or with a human driver). 3
  • 9. Current traffic rules have been written for a scenario in which humans drive cars and may hence be suboptimal in a driverless car scenario, or even in a scenario where both machines and humans drive cars. In this work, traffic rules has been taken a fresh look at and the possibility of devising a novel set of rules, that are amenable to automation and, at the same time, able to improve global indexes computed over the full population of vehicles, has been investigated. In particular, it has been focused on optimizing the global traffic efficiency and safety. It is thought that, broadly speaking, an approach of this kind could lead to significant advantages to the society as a whole and that the driverless car revolution could offer a unique opportunity in this respect. 1.2 Solution proposed It has been proposed a framework based on Grammatical Evolution (GE) and the contribution is as follows. First, it has been proposed and experimentally evaluated a model for road traffic including the road graph, the cars, and the rules-aware drivers who try to abide by, but can possibly evade, the rules; the model is detailed enough to include concepts such as lanes, collisions, and safety distance, which are significant to this study. Second, it has been proposed a language to define rules which can be enforced in the model: rules are predicates and the language is given in the form of a context-free grammar. Third and finally, it has been proposed and experimentally evaluate a method for the automatic synthesis of rules based on GE: individuals represent sets of rules (i.e., regulations) and their fitness capture the degree to which, according to the results of several simulations, traffic regulated by the set of rules is efficient and safe. The experimental evaluation shows that, using GE, it is possible to obtain sets of rules which result in safer (less collisions) and more efficient traffic, w.r.t. both unregulated traffic and a set of hand-written rules designed to resemble a (simplified) real world set of rules. It is thought that no other studies concerning the automatic synthesis of road traffic rules have been proposed before. Recent research has focused on how driverless cars should behave with respect to the existing rules: by proposing flexible control strategies which mini- mize the number of violated rules [17], by approaching the (highway) driverless algorithm design with rules complying as a first goal (legal safety) [18], or by formalizing rules for the sake of accountability after collisions involving driverless cars [12]. A much deeper problem in this area consists in determining which decision should be taken by a driverless car when facing a situation where only less-than-ideal outcomes are possible [7, 6]. In such a case, the decision may 4
  • 10. result in some sacrifice involving car users (passengers) or other people (e.g., pedestrians). This fundamental problem is orthogonal to this work. Traffic is regulated not only by rules but also by the infrastructure, e.g., road markings and signs. In this area, several proposals have been made to modify the working principle of traffic lights in order to avoid congestion (e.g., [19]), also resorting to evolutionary computation [14]. More recently, motivated by the emergence of more automated vehicles, Tachet et al. even proposed the replacement of traffic lights with a novel (for road traffic) flow regulation solution build upon slot-based systems [16]. From a more general point of view, automatic synthesis of rules is a task which fits particularly well GE, since the language of the rules can be described in terms of a grammar and candidate solutions may be evaluated by means of simulated application of the corresponding set of rules: for instance, in [3] GE has been used to generate trading rules for spot foreign-exchange markets. Moreover, recent works showed that GE is suitable for addressing real problems with complex grammars, such as learning of string similarity functions [2], or designing components of vehicle routing algorithms [4]. 5
  • 11. Chapter 2 Road traffic model 2.1 Road traffic simulator Traffic simulation or the simulation of transportation systems is the mathemati- cal modeling of transportation systems (e.g., freeway junctions, arterial routes, roundabouts, downtown grid systems, etc.) through the application of com- puter software to better help plan, design and operate transportation systems. Simulation of transportation systems started over forty years ago, and is an important area of discipline in traffic engineering and transportation planning today. Various national and local transportation agencies, academic institutions and consulting firms use simulation to aid in their management of transportation networks. The meaning of simulation in transportation is that through that it become possible to study models too complicated for analytical or numerical treatment. Also simulation can be used for experimental studies, can focus on detailed relations that might be lost in analytical or numerical treatment and can produce attractive visual demonstrations of present and future scenarios in the field of transportation. The concept of system state is the focus of the complete understanding of simulation. The system state is a set of variables that contains enough information to describe the evolution of the system over time. System state can be either discrete or continuous. Traffic simulation models are classified on the discrete or continuous values assumed by the variables: time, state, and space. Employing a numerical method with a car-following model (such as Gipps’ with Heun’s [5]) can generate important information for traffic conditions, such as system delays and identification of bottlenecks. A class of microscopic continuous-time models, known as car-following models, are models based on differential equations. Significant models include the pipes, intelligent driver 6
  • 12. model and Gipps’ model. They model the behavior of each individual vehicle (“microscopic”) in order to see its implications on the whole traffic system (“macroscopic”). 2.2 The model proposed It has been considered a scenario with continuous space and discrete time in which a number of cars move according to their driving algorithms. The model used is based according with the car-following definition. Every vehicle in the model has a fixed size in the sense of length because it is to be avoided to have a road being occupied by an infinite number of accented vehicles. As far as concerns the traffic simulator, there was to choose between two possible ways: • Using an existing customizable model that was suitable for the task, and then perform just the needed changes. • Create a new road traffic simulator from scratch, with the chance to define exactly all the desired features as well as keeping its structure as simple as possible. Some microscopic Open Source road traffic simulators has been developed for transportation planning or traffic engineering. These models are available along with their source code. However the simulators that matched most of the specifications required for this study turned out to be the most complex. Some of them have been analyzed to be used in this work, but in order to obtain the desired features it has been considered a better solution to develop a tailor-made model aimed to meet the specifications of the project, both in terms of detail considered, but almost as far as concerns the driver algorithm subject to road rules and vehicle collisions. Also starting from scratch, it was easier to make a model that would fit as much as desired. 2.3 Roads and cars 2.3.1 The road graph A road graph is a directed graph G = (S, I) in which edges represent road sections, vertices represent road intersections, and where each vertex is connected to at least two edges. A road section p ∈ S is characterized by a length l(p) ∈ R, l(p) > 0 and a width w(p) ∈ N, w(p) > 0: the former represents the length of the section 7
  • 13. Figure 2.1: the small road graph used to estimate the goodness of the rules generated during the evolution process. Blue dots represent the vehicles in the simulation, and the red dots represent the collided vehicles that have not yet been removed from the road graph. The road segments are defined by gray rectangles delimited by black segments indicating lanes, dark gray balls indicate the intersections road. between two intersections and the latter represents the number of lanes in the section. A road intersection p ∈ I is characterized by a size w(p) ∈ N, w(p) > 0: without loss of generality, it is assumed that the size of an intersection is equal to the largest width among the sections connecting the intersection. 2.3.2 The cars A car is an agent which moves on the road graph. At a given time step, the car is positioned somewhere on the road graph, i.e., its position can be determined in terms of the section/intersection, lane and distance from the section/intersection origin. The car movement is determined in terms of two speeds, i.e., along the section and along the lanes—see Figure 2.3. In detail, a car is a tuple (p, x, y, vx, vy, s) where p, x, y constitute the position, vx ∈ R is the linear speed, vy ∈ {−1, 0, 1} is the lane-changing speed, and s ∈ {alive, dead} is the status. Within the position, p ∈ S ∪ I is the section or intersection where the car is. If p ∈ S, x ∈ [0, l(p)] and y ∈ {1, . . . , w(p)} are the linear and lane coordinates of the car within the road section p—it is assumed that x = 0 refers to the starting side of p. If p ∈ I, x ∈ [0, w(p)] is the 8
  • 14. Figure 2.2: The big road graph used to estimate the ability of generalization of an individual, that is, a set of rules obtained through GE, used on the small road graph and then evaluated on the big road graph with more vehicles. coordinate of the car within the intersection and y is not relevant. It has been chosen to define a range of values for the maximum vehicles speed in order to view the different behaviour of both faster and less fast vehicles in the same simulation, subjected to the same algorithm, and also to differentiate vehicles and thus introduce greater variability in the model. Cars acceleration value has been kept the same for all vehicles and is equivalent to the speed of braking. 2.3.3 Cars management in the simulator At the initial time step of the simulation, the selected number of cars is positioned in the road graph. The algorithm according to which the vehicles are settled in the model will randomly select three road segments between all those in the road graph and for the three selected segments it measure the maximum distance between each pair of vehicles in it and place the new vehicle in the road segment among them with more empty space. Each vehicle that is inserted in the simulator starts with zero speed. In all the following time steps, vehicles are inserted into the simulator whenever a condition occurs to remove a car and replace it with a new one. 9
  • 15. At each time step, if the status of a car is s = dead, the position is not updated. To provide a situation similar to reality, each collided vehicle is kept inside the simulator for an arbitrary number of time steps of the simulation, in the position where it has collided. In this way, the stopped vehicle represents an obstacle to the traffic flow, which all the other vehicles have to deal with. At the end of the expected time steps the collided vehicle is removed from the simulation. At each time step the simulator introduces in the simulation a number of new vehicles equal to the number of collided ones that have been removed. Otherwise, if the status is s = alive, the position (p, x, y) of a car is updated as follows. If p ∈ S and 0 ≤ x + vx ≤ l(p), then its position at the next step is (p, x + vx, min(max(y + vy, 0), w(p))). Otherwise, if p ∈ S and x + vx < 0 or x + vx > l(p), then its position at the next step is (p , 0, 0), where p ∈ I is the appropriate intersection between the two connected by p. Otherwise, if p ∈ I and x + |vx| ≤ w(p) then its position at the next step is (p, x + |vx| , 0). Otherwise and finally, if p ∈ I and x + |vx| > w(p), then its position at the next step is (p , x0, y0), where p ∈ S is one of the sections connecting p and x0 = 0, y0 = 0 or x0 = l(p ), y0 = w(p ) depending on whether p starts or ends in p, respectively—in the latter case, if vx > 0, then at the next step it is set to −vx. Concerning the choice of p , let {p1, . . . , pn} ⊆ S be the set of sections connecting p, then p is set to pj, where j is chosen randomly in {1, . . . , n}. In other words, a car moves on a section according to its speeds; whenever it reaches the end (or the beginning) of the section, it enters the connected intersection. While in an intersection, the car remains inside according to its linear speed and the intersection size. When exiting an intersection, it enters a connecting section. At each time step, a collision may occur between a pair of cars. A collision occurs if two cars meet on the same intersection or if two cars meet on the same lane of the same road section. If a collision occurs, the status of the two cars is set to dead. In detail, let (p (k) 1 , x (k) 1 , y (k) 1 ) and (p (k) 2 , x (k) 2 , y (k) 2 ) be the positions of the two cars at time step k, a collision occurs at k if at least one of the following conditions is met: • p (k) 1 = p (k) 2 ∈ I and x (k) 1 − x (k) 2 < dcollision; • p (k) 1 = p (k) 2 ∈ S and y (k) 1 = y (k) 2 and x (k) 1 − x (k) 2 < dcollision; • p (k) 1 = p (k−1) 1 = p (k) 2 = p (k−1) 2 ∈ I and sign(x (k) 1 − x (k) 2 ) = sign(x (k−1) 1 − x (k−1) 2 ); • p (k) 1 = p (k−1) 1 = p (k) 2 = p (k−1) 2 ∈ S and y (k) 1 = y (k) 2 and sign(x (k) 1 − x (k) 2 ) = sign(x (k−1) 1 − x (k−1) 2 ); 10
  • 16. A vx vy B C D E dcollision d dview y 0 1 2 3 x0 l(p) Figure 2.3: A visualization of some of this model definitions. A car A is traveling with a positive linear speed vx and a negative lane speed vy = −1 on a road section on which there are other 4 cars. With respect to A, car C is the 1- lane closest car, because it is on yC = 2 = yA + 1 and its distance from A is ∆x ≤ dview; moreover, δv1 = opposite, since C is traveling in the opposite direction w.r.t. A, and 1 = T, since C is closer than depsilon to A. There are no other j-lane closest cars for A: in facts B is behind (not ahead) A, D is two lanes away from A, and E distance to A is larger than dview. • p (k−1) 1 = p (k−1) 2 ∈ I and p (k) 2 = p (k−1) 2 and p (k) 1 = p (k−1) 1 and x (k−1) 1 ≤ x (k−1) 2 ; • p (k−1) 1 = p (k−1) 2 ∈ S and p (k) 2 = p (k−1) 2 and p (k) 1 = p (k−1) 1 and y (k−1) 1 = y (k−1) 2 and v (k) x,1 > 0 and x (k−1) 1 ≤ x (k−1) 2 ; • p (k−1) 1 = p (k−1) 2 ∈ S and p (k) 2 = p (k−1) 2 and p (k) 1 = p (k−1) 1 and y (k−1) 1 = y (k−1) 2 and v (k) x,1 < 0 and x (k−1) 1 ≥ x (k−1) 2 ; where dcollision is a parameter which represents the minimal distance between two cars—note that with any dcollision > 0 the capacity of the road graph is limited. 2.4 Driver A driver is an algorithm according to which the linear and lane-changing speeds of a car are updated. In particular, at each time step, the algorithm execution is based on the processing of (a) a set of input variables, (b) a set of state variables, (c) the driver’s car tuple, (d) a set of unmodifiable parameters and results in (a) the output of a non-empty sequence of actions and (b) the modification of the state variables. 11
  • 17. 2.4.1 The input variables The input variables are based on the concept of j-lane closest car, with j ∈ {−1, 0, 1}. Each driver has a reference to the vehicles in the same lane and the two adjacent lanes that are in front of it’s vehicle (referring to the vehicle’s orientation along the road segment). The vehicles considered are at most 3 (the closest ones), but if the driver’s vehicle is in one of the side lanes, the vehicles detected are then at most 2 (the one in the same lane as the driver’s and the one in the inner lane with respect to the driver’s lane). The vehicles behind the driver’s car are not considered in this model (with respect to the driver’s car orientation). In the case where the driver is crossing an intersection, each vehicle present in the intersection with a position greater than the one of the driver’s vehicle are considered ahead of the driver. The j-lane closest car is the closest car ahead of the driver’s car on the y + j lane such that its linear distance is ∆x < dview, where y is the lane of the driver’s car and dview is a driver’s parameter. For the sake of brevity, it is omitted a more formal definition, which covers also the case in which the driver’s car is in (or close to) an intersection. The cases analyzed only cover some of the real situations: in this model a driver in a road segment sees the vehicles that are in front of him (regardless of the direction of travel of these vehicles); A driver in a road segment near an intersection sees vehicles within the intersection; A driver that is crossing an intersection sees the vehicles in front of him that are crossing the same intersection; A driver that is occupying an intersection sees vehicles located in the road segments that start from the same intersection and all vehicles that are traveling along adjacent road segments starting from the intersection considered. A driver located in a road segment near an intersection has no way of seeing any other vehicles traveling on other road segments in the same direction (even in the other direction, but this second case is not of interest), with the risk that more vehicles (possibly each one with a different speed) are approaching the same intersection without being able to prevent a situation that, without further measurements, may be the cause of collisions, as the braking space may not be enough to stop. Note that the j-lane closest car could not exist for some j, if no cars are closer than dview or there is no y + j-th lane. The input variables are the following—see Figure 2.3 for a visual interpretation of the variables. • Three relative movement variables δv−1, δv0, and δv1. The value of δvj is defined in {∅, opposite, −1, 0, 1} and is determined as follows. If there is no j-lane closest car, then δvj = ∅. Otherwise, let (p , x , y , vx, vy, s ) the j-lane closest car: if sign vx = sign vx, then δvj = opposite, otherwise δvj = sign (|vx| − |vx|). In other words, δvj says if there is a j-lane closest 12
  • 18. car and, if any, if it moves in the opposite direction or, otherwise, is becoming closer (δvj = −1), farther (δvj = 1), or has the same linear speed, w.r.t. the driver’s car. • Three closeness variables −1, 0, 1. The value of j is a boolean which is true if and only if there is a j-lane closest car and its distance ∆x from the driver’s car is ∆x ≤ d , where d < dview is a driver’s parameter. In other words, j is set if the j-lane closest car, if any, is closer than a threshold. If the vehicle is at a distance below the threshold then the driver must act according to this information. 2.4.2 The state variables The state variables include a single variable d ∈ R, d ≥ 0, which represents the distance the driver still wants to go and which is updated at each time step as d(k+1) = d(k) − |v (k) x |. Each driver in the road graph has to cover an amount of distance during the simulation. At each step, the remaining distance is updated according with the speed of the vehicle and the distance covered in that time step. There is no route for drivers to navigate, but once the amount of distance is covered, the driver stops the vehicle and once it is stopped it is then removed from the simulation and replaced with a new one. If a vehicle is involved in an accident and the driver has not covered the total distance yet, the car will be removed regardless of the fact that the travel has not been completed. The parameters include dview, d (whose meaning was described above), a value vmax ∈ R, vmax ≥ 0, and a value v∆ ∈ R, 0 < v∆ < vmax: vmax is the maximum linear speed the driver’s car can reach and v∆ represents the acceleration/deceleration of the driver’s car. 2.4.3 The output of the driver’s algorithm The output of the driver’s algorithm is a non-empty sequence A of actions, i.e., an ordered subset of the set A of possible driver’s action, with A = {↑, , → , ↓, , ←, , ∅}. An action determines how vx and vy are updated, as shown in Table 2.1. In other words, an up arrow corresponds to accelerating and a down arrow corresponds to braking; a right arrow corresponds to moving on the right lane and a left arrow corresponds to moving on the left lane, and so on. The driver executes only one of the actions in A. At each time step of the simulation, the driver must perform exactly one of the possible actions. The action which is 13
  • 19. Table 2.1: Driver’s actions. a ∈ A v (k+1) x v (k+1) y ↑ sign (v (k) x + v∆) min(|vmax| , v (k) x + v∆) 0 sign (v (k) x + v∆) min( v (k) x , v (k) x + v∆) − sign v (k) x → v (k) x − sign v (k) x sign (v (k) x + v∆) max(0, v (k) x − v∆) − sign v (k) x ↓ sign (v (k) x + v∆) max(0, v (k) x − v∆) 0 sign (v (k) x + v∆) max(0, v (k) x − v∆) sign v (k) x ← v (k) x sign v (k) x sign (v (k) x + v∆) min( v (k) x , v (k) x + v∆) sign v (k) x ∅ v (k) x 0 actually performed is chosen after processing A according to a procedure that is detailed in Section 2.7 which takes traffic rules into account. The driver’s algorithm is presented in the form of a multiway branch control in Table 2.2. The rationale for the proposed algorithm is to resemble the behavior of a “reasonable” driver who aims at traveling a distance d while avoiding trivial collisions: that goal is pursued by—in essence—trying to travel at the max linear speed while avoiding hitting other cars on the same lane. In detail, each row of Table 2.2 represents a proposition and the corresponding output A. The proposition is composed of the conjunction of membership checks on input variables and on the result of the comparison of the state variable d against xstop, which is defined as xstop = kstopvx + 1 2 k2 stop − kstop v∆ where kstop = vx v∆ ; xstop represents the distance the driver’s car would run if it constantly decrease its speed until stopping. For instance, row 4 proposition is δv0 ∈ {−1, 0} ∧ 0 ∈ {F}, row 5 proposition is δv1 ∈ {∅, 1} ∧ δv0 ∈ {−1, 0} ∧ 1 ∈ {F} ∧ 0 ∈ {T}. The output is determined as follows: if the row 1 proposition is true, then the output is the row 1 A; otherwise, if the row 2 proposition is true, then the output is the row 2 A, and so on—note that the last row proposition is always true, hence it is guaranteed that a non empty sequence is always output. 2.5 The performance indexes • The first index is called average speed ratio (ASR) is the ratio between the actual average speed dtot ktot a driver traveled at and the maximum theoretical average speed vmax. The index average speed ratio is computed on all vehicles in the simulator, and is calculated as the average value on 10 simulations for the same amount of traffic injected. A greater ratio is 14
  • 20. Table 2.2: The driver’s algorithm. δv1 δv0 δv−1 1 0 −1 d ≤ xstop A 1 ∀ ∀ ∀ ∀ ∀ ∀ {T} {↓, , } 2 {∅, 1} {∅, 1} {∅, 1} ∀ ∀ ∀ ∀ {↑, , , ∅, ↓} 3 ∀ {∅, 1} ∀ ∀ ∀ ∀ ∀ {↑, ∅, ↓} 4 ∀ {−1, 0} ∀ ∀ {F} ∀ ∀ {↑, ∅, ↓} 5 {∅, 1} {−1, 0} ∀ {F} {T} ∀ ∀ { , ∅, ↓} 6 ∀ {−1, 0} {∅, 1} ∀ {T} {F} ∀ { , ∅, ↓} 7 ∀ {0} ∀ ∀ {T} ∀ ∀ {∅, ↓} 8 ∀ {−1} ∀ ∀ {T} ∀ ∀ {↓} 9 ∀ {opposite} ∀ ∀ ∀ {F} ∀ {→, , ↓} 10 ∀ {opposite} ∀ {F} ∀ ∀ ∀ {←, , ↓} 11 ∀ {opposite} ∀ ∀ {T} ∀ ∀ { , , ↓} 12 ∀ ∀ ∀ ∀ ∀ ∀ ∀ {↓, , } significant for greater traffic flow. Conversely, if you register a low index it means the traffic is slow. • The acceleration-per-time (ApT) is the ratio between the number nacceleration of accelerations a car had during its travel and ktot, where nacceleration ∈ N. It is computed as a counter for each vehicle, incremented each time a driver performs an action that increase it’s vehicle speed, and it’s mediated between all the cars in circulation, for each of the 10 simulations with the same quantity of traffic injected. This index is indicative of the amount of pollution produced by cars. For simplicity it is assumed that pollution is greater when vehicles accelerate (and brake) often. In this respect, this index should be kept as low as possible in order to reduce the pollution. It is also possible to find a relationship between the first two indexes, the average speed ratio and the acceleration-per-time, in fact in general: the more the traffic flow is slow, the more vehicle accelerates (and brake) and thus product more pollution. • The collision-per-time (CpT) is the ratio between the number ncollision of collisions a car had during its travel and ktot, where ncollision ∈ {0, 1}. it is 0 if the vehicle considered was not involved in any collision during the time required for the total distance traveled (the vehicle lifetime), otherwise it is worth 1 if the vehicle has collided. This value is mediated by all the vehicles in circulation in the 10 simulations in which the same number of vehicles is injected. The collision-per-time index is significant to represent the safety of drivers who are in the simulator. The more this index is low and the more the safety and the absence of collisions between vehicles are guaranteed. There is a relationship between the index average speed ratio and the collision-per-time since it is easier to prevent collisions if the vehicles move slower. In other words if vehicles move slower, drivers can 15
  • 21. handle in better ways dangerous situations. From the two Figure 4.1 and Figure 4.2 it can be seen that an increase of the number of vehicles in a simulation leads to a decrease to the average speed ratio index that defines the traffic flow. The greater is the number of vehicles in circulation and the more it is reasonable that a vehicle’s journey is hampered by vehicles near this on the same lane, which force it to reduce speed. Conversely, if the number of vehicles is low, each vehicle is free to cover the graph at maximum speed. Regarding the index acceleration-per-time, however, it has an opposite curve with respect to the average speed ratio but with the same interpretation: as the traffic increases, the vehicles are slower. Cars are forced to brake and accelerate very often, as it occurs in real-time traffic in the most crowded cities with higher pollution scores. In particular, the curve of the acceleration-per-time index defines a behavior that seems to reverse the tendency to increase the number of accelerations in accordance with the increase in the number of vehicles in the simulator. At a given traffic value the curve comes down and this trend can be explained by the fact that the number of vehicles is so high that the number of collisions that occur will lower the average vehicle life and thus will also decrease the time when they accelerate. The collision-per-time index has a similar explanation with respect to to the index acceleration-per-time. As the number of cars increases, it is likely that collisions occur. On the contrary, if the graph is crossed by a few vehicles, it is unlikely that two or more of them will collide. The curve of this index has a monotonous trend and it is natural to imagine that the number of accidents is mainly due to the amount of vehicles. The trend for all three indexes above is the same in the two road graphs. 2.6 Rules A traffic rule is a predicate defined on a set of variables concerning a car and its driver, its j-lane closest cars, and the road graph. A car breaks a rule at a given time step if the corresponding predicate is false. The variables on which a traffic rule can be defined include: (a) variables concerning the car and the corresponding driver: ˆvx, vmax, v∆, dview, d , p, ˆx, and ˆy, where ˆvx = |vx|, ˆx = l(p) − x and ˆy = y, if vx ≥ 0, and ˆx = x and ˆy = w(p) − y, otherwise; (b) variables concerning the car j-lane closest cars: δv−1, δv0, δv1, ∆x−1, ∆x0, and ∆x1, where ∆xj is defined as in Section 2.4 and is set to +∞ if the corresponding δvj = ∅; (c) variables concerning the road graph section or intersection in which the car is: l(p) and w(p). 16
  • 22. r ::= conditions conditions ::= condition | conditions ∨ condition condition ::= baseCondition | ¬ baseCondition baseCondition ::= numericCondition | deltaCondition | graphCondition numericCondition ::= numericVariable ≤ numericValue numericVariable ::= ˆvx | vmax | v∆ | dview | d | ˆx | ˆy | ∆x−1 | ∆x0 | ∆x1 | l(p) | w(p) numericValue ::= digit . digit e exp digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 exp ::= −1 | 0 | 1 deltaCondition ::= δv−1 = deltaValue | δv0 = deltaValue | δv1 = deltaValue deltaValue ::= ∅ | opposite | − 1 | 0 | 1 graphCondition ::= p ∈ S Figure 2.4: Backus-Naur Form of the context-free grammar for the traffic rules. The set of possible traffic rules is defined by a context-free grammar which it is presented with the Backus-Naur Form (r is the rule) in Figure 2.4. For example, the rule stating that “the maximum speed of a car is 20” is written as ˆvx ≤ 20. The rule stating that “the car should stay on the rightmost free lane” is written as ˆy ≤ 0∨∆x−1 ≤ 10, where 10 represents a distance within which a lane is not considered free. The rule stating that “the car should proceed slowly when approaching an intersection” is written as ¬ˆx ≤ 20 ∨ ˆvx ≤ 10. 2.7 Rules-aware driver A rules-aware driver is a driver that selects exactly one winning action out of a sequence A = (a1, a2, . . . ) of actions, given a set R of traffic rules. In brief, a rules-aware driver selects the action which, if repeated for the next steps, will cause the least number of broken rules. 2.7.1 The prediction models Four prediction models for the driver algorithm were proposed and developed. Each one of the algorithms that are now described has the purpose of electing one winning action from a list with priority of possible actions at any time steps, considering as the only factor of choice the number of infringements to the rules 17
  • 23. that will be caused in the future. In the process of choosing the winning action to be performed no account is taken of collisions with other vehicles. • The first model is called sameAction algorithm, and it performs a prediction of the rules that will be broken in the next simulation step taking into account that the driver will repeat the same action for each of the k future time steps. Then the algorithm repeats the same algorithm for each of the actions from the list provided to the driver at the first time step of the prediction. For example, if the driver is assessing the impact on the rules of the action ↑, then according to this model the driver will simulate to perform the action ↑ for k steps and calculate the total number of broken rules for that action. This kind of forecast seems reasonable especially when rules concerns speed limits for the vehicle in a road sections. • The second algorithm is called nullAction. This model assumes that the driver will performs an action in the first of the future time steps of the forecast and then simulate to execute the ∅ action for all the other future time steps left. This corresponds to a prediction model in which the driver maintains its parameters (speed, lane) unchanged during all the steps of the forecast. As in the previous case, the prediction is performed for all the actions in the list, and it choose the action that causes the lowest number of broken rules. This model is similar to the sameAction algorithm, in fact it’s strongly dependent on the k number of forecast steps. For instance an action that is imagined to be fair as to brake when a speed limit is encountered may not be a win if the number of forecast steps is not sufficient to have a speed that respects the limits at the last step of the prediction. All this is considered in the case of road rules dealing with speed limits (both upper speed limit as well as lower speed limit). In the case of handwritten rules these constraints on the cars speed have been well defined, and it is possible that similar rules may also be created in the case of rules obtained in another way. • The third model is called smartAction, and it’s an algorithm that choose at every step an action from the list of possible actions, and thus the winning is the action that breaks the least number of rules. This algorithm needs the evaluation of every possible sequence of actions that can be performed for the k steps of prediction and therefore its computational cost is high. The positive feature of this model, however, is that the driver can create a sequence of actions so as to best fit the rules. Despite the high performances regarding the number of broken rules, the computational performance of the smartAction algorithm are not good enough to make it emerge compared to other algorithm and thus it has been discarded in favor of simpler and more reasonable models that could represent the common sense and predictive behaviour of a human driver. 18
  • 24. • The fourth model is called lazySmartAction, an algorithm that plans to use the previous model of the smartAction with the difference that the action taken at the previous step is placed in the first place with maximum priority at the next step for each of the prediction steps. This algorithm simplifies the choice of actions and provides a less costly model from the computational point of view and performance similar to the smartAction model. In spite of this, the overall performance measured with the lazySmart in term of computation has led to the predominance of the sameAction model, which has been used in each prediction, both by hand-written rules and evolutionary processes. More in detail, the selection with the lazySmart algorithm is performed as follows. First, for each action ai in A, the sequence Ai of future actions consisting of ai repeated kadvance times is considered. Second, the number ni of future broken rules caused by Ai is computed as the sum of the number of rules that would be broken at each future step k + j, with 0 ≤ j ≤ |Ai|. Third and finally, the winning action is determined as the action ai for which ni |Ai | is the lowest—in case of tie, the action with the lowest index in A is selected. When computing ni, the rules-aware driver predicts the future variable values assuming that: (i) the j-lane closest cars, if any, will maintain the same speeds of step k; (ii) no other j-lane closest cars will appear; (iii) the driver’s car will update consistently with the sequence of actions Ai. If a sequence Ai is such that the future position p of the car changes, the sequence is truncated to the last element before that change. For example, if a vehicle enters an intersection, the prediction ends before exiting the road segment that is currently traveling. The fourth index broken-rules-per-time is obtained as a counter for each vehicle and it is incremented each time an action actually carried out by a driver has caused the evasion of o rule. The number obtained is mediated on the 10 simulations considered and among all vehicles in circulation. This index has to be minimized in order to get the highest respect of the traffic rules, but there are cases in which any action performed causes the infringement of one or many rules, or in a worst case it may even happen that two rules are contradictory and the respect of one of them causes the evasion of the other. For these reasons, recording this index is important for understanding the relationship between the drivers and the rules inserted in the simulation. As it can be seen from both road graphs in Figure 4.3 and Figure 4.4 by introducing a handwritten set of rules, the average speed ratio index for both the small road graph and the big road graphs is greatly reduced, for example drivers are subjected to rules that force them to slow down under certain conditions or maintain their speeds within a higher limit, which reduces the flow of traffic. Conversely, by introducing hand written traffic rules, the collision-per-time index decreases, hence the number of collisions is reduced considerably. The price to 19
  • 25. pay for greater safety is therefore the speed with which vehicles are free to move, but given the results worth it. 20
  • 26. Chapter 3 Grammatical Evolution Grammatical Evolution (GE) [13] is a form of grammar-based Genetic Program- ming (GP) [8] which can evolve strings belonging to a language L(G) defined by a context-free grammar G. In brief, GE operates on genotypes, which are variable-length bit strings, maps them to phenotypes, which are strings of L(G), and finally associates them with fitness values in R. The genotype-phenotype mapping procedure is the distinguishing trait of GE. In this procedure, the genotype is viewed as a variable-length integer string where each i-th integer, called codon and denoted by gi, is obtained by decoding bits from the (8(i − 1))-th to the (8i − 1)-th, included, in the genotype g. The procedure is iterative and starts by setting the phenotype to p = s0, s0 being the grammar starting symbol, a counter i to 0, and a counter w to 0. Then, the following steps are iterated. 1. The leftmost non-terminal s in p is expanded using the j-th option (zero- based indexing) in the production rule rs for s in G, with j being the remainder of the division between the value gi of the i-th codon (zero- based indexing) and the number |rs| of options in rs, i.e., j = gi mod |rs|. 2. The counter i is incremented by 1; if i exceeds the number of codons, i.e., if i > |g| 8 , then i is set to 0 and w is incremented by 1—the latter operation is called wrapping and w represents the number of wraps performed during the mapping. 3. If w exceeds a predefined threshold nw, the mapping is aborted, i.e., a null phenotype is returned which will be associated to the worst possible fitness. 4. If p contains at least one non-terminal to be expanded, return to step 1, otherwise end. 21
  • 27. The search engine of GE, i.e., the way in which the population of individuals is updated across subsequent generations, is conventionally based on Genetic Algorithms (GA). In Section 4.2 it is provided the evolutionary parameters values which it has been used in the experimentation. In order to adapt the general-purpose GE framework to a specific case, one has to provide a grammar, which implicitly define the phenotype space, and a fitness function f, which maps a phenotype to a number in R. In this case, phenotypes are sets of rules and hence it has been modified the grammar of Figure 2.4, which describes the language for defining a single rule r, by replacing the first rule in order to make it defining a rule set R, as follows: R ::= conditions | conditions ∧ conditions Rules within a set or rules are separated by a conjunction ∧. Concerning the fitness function, it has been aimed at defining a function which captures two desired high-level objectives of a set R of road traffic rules: (i) traffic flow regulated by R should allow car drivers to reach their destination without taking too long time, i.e., with a large average speed, and (ii) traffic flow regulated by R should result in no or few collisions. It can be noted that, in principle, the two objectives are conflicting: for instance (and simplifying), a set R imposing a very low speed limit will likely prevent many collisions, but will cause long traveling times for all drivers; on the other hand, a set R not imposing any speed limit will allow drivers to quickly reach their destination, but will likely result in many collisions. It has been implemented these high-level objectives by means of two indexes which can be measured for each single driver. The average speed ratio (ASR) and the collision-per-time (CpT). For the former index, the greater, the better; the opposite for the latter. Hence, instead of ASR, it has been considered 1 − ASR, i.e., 1 − dtot ktot 1 vmax . It is associated a rule set R with a fitness value which is a linear combination of the two indexes averaged across all cars ncar during a number nsim of simulations: f(R) = αtime 1 nsim 1 ncar cars 1 − dtot ktot 1 vmax + αcollision 1 nsim 1 ncar cars ncollision ktot (3.1) where αtime and αcollision are the weights. 22
  • 28. Chapter 4 Experiments Two experimental campaigns has been performed. The first one aimed at validating this road traffic model. The second one aimed at verifying the effectiveness of this GE-based approach for the synthesis of road traffic rules. 4.1 Validation of the road traffic model It has been performed a number of simulations in order to validate the proposed model for the road traffic scenario. In particular with interest in: (i) finding appropriate values for the model (dcollision, dview, d , vmax, v∆, kadvance, and all the values concerning the road graph) and simulation (d(0) , ncar, kdead, and kmax) parameters; (ii) verifying if the model behaves consistently when varying the number of cars in the road graph; (iii) verifying if a set of manually crafted rules causes a sound modification of the model behavior w.r.t. the absence of rules. To this end, after an exploratory experimentation, it is set the values of the parameters as shown in Table 4.1. In order to simulate different drivers, it is set different values, chosen randomly according to a uniform distribution, for the driver-related parameter vmax. Each simulation has been performed by maintaining constant the num- ber ncar of cars in the graph during the whole simulation. To this end, during the simulation, it has been removed a car and added a new one in a random position whenever at least one of the two following conditions was met: (a) the driver’s state variable d (i.e., the distance the driver still wants to travel) became lower or equal to zero, or (b) exactly kdead time steps passed since the car state s switched from alive to dead, i.e., since the step when the car was involved in a collision. Concerning the former condition, it is recalled that drivers do not have 23
  • 29. Figure 4.1: The values assumed by three arbitrary indexes as the traffic varies, evaluated on the small road graph. Each point in the plot is obtained as the average value of 10 simulations performed with the same number of vehicles in circulation. The three indexes considered represent the efficiency, safety and efficiency of traffic within the graph. Table 4.1: Model and simulation parameters. Param. Meaning Value dcollision Minimum distance between cars without collision 1 kremoval Time steps before collided cars remotion 100 dview Driver’s view distance 30 d Driver’s safety distance 10 vmax Driver’s maximum speed ∼ U(1.5, 3.5) v∆ Driver’s acceleration (deceleration) 0.1 kadvance Driver’s rules forethought time steps 10 d(0) Driver’s distance to travel (i.e., initial d) 2000 |S| Number of road sections 5 |I| Number of road intersections 4 w(p), p ∈ S Number of lanes ∈ {2, 3, 4} l(p), p ∈ S Section length ∈ {100, 100 √ 2} ncar Cars in the simulation ∈ {2, 5, 8, 11, 14, 17, 20} kdead Dead car removal time steps 100 kmax Simulation time steps 5000 24
  • 30. Figure 4.2: This plot represents the same three indexes as in the previous graph. This time the simulations are performed on the big road graph, with the same criteria defined above. a specific destination; instead, their goal is to travel for a predefined distance. Table 4.2 shows the set of 8 rules that has been manually crafted in order to resemble a (simplified) typical road traffic regulation. The set contains rules regulating the driver’s behavior w.r.t. lane to stay on (i.e., “stay on the right”, rules 1 and 2), rules stating how the driver’s should approach intersection (3, 4, and 5), rules imposing a safety distance (6 and 7), and a rule prohibiting speeding (8). The numeric values has been adjusted in the rules by exploratory experimentation, with the aim of reducing the number of collisions while not heavily affecting ASR. Figure 4.5 shows the results of the first experimentation (along with the results of the rules inference experimentation, discussed in the next section). The figure shows the value of the two indexes (1 − ASR, left, and CpT, right) vs. the number ncar in the simulation, that is, vs. the injected traffic. There is one curve for each of the three following sets of rules: an empty set (no rules), the set of rules of Table 4.2 (hand-written rules), and a set of generated rules (best GE rules)— the results has been discussed corresponding to the first two curves. Each point of the curve is obtained by averaging the values of the index collected in 10 simulations. Observing the plots of Figure 4.5, it can be seen that the relation between the amount of traffic (ncar) and the two indexes looks sound, i.e., 25
  • 31. Figure 4.3: The two curves for each index, where each index is calculated on the small graph. The indexes considered are the same as in the previous plots (average speed ratio, acceleration-per-time, collision-per-time), but this time it is also considered as fourth index the one that defines the evasion of road rules, called broken-rules-per-time. Each of the two curves for each index represents: The case where the vehicles are not subjected to any rule, as in the previous plots (since now the indexes are four the rule violation index broken-rules-per-time is always zero). The case with a set of rules in the simulator, dictated by common sense, which imitate with some degree approximation the current rules of the road. 26
  • 32. Figure 4.4: The trend of the same indexes but this time considering the big road graph. Table 4.2: Hand-written rules. Rule Explanation 1 ˆy ≤ 0.0e0 ∨ ∆x−1 ≤ 2.0e1 Stay on the rightmost free lane. 2 ˆy ≤ 1.0e0 Stay on the first or second rightmost lane. 3 ¬ˆx ≤ 3.0e1 ∨ ˆvx ≤ 1.5e0 When close to end of (inter)section, proceed slowly. 4 ¬ˆx ≤ 2.0e1 ∨ ˆvx ≤ 0.5e0 When closer to end of (inter)section, proceed more slowly. 5 ¬ˆx ≤ 3.0e1 ∨ ˆy ≤ 0.0e0 When close to end of (inter)section, stay on the rightmost lane. 6 ¬∆x0 ≤ 2.0e1 Do not travel too close to the preceding car. 7 ¬ˆvx ≤ 0 ∨ ∆x0 ≤ 2.0e1 When too close to the preceding car, stop. 8 ˆvx ≤ 2.4e0 Do not exceed a maximum speed. 27
  • 33. 5 10 15 20 0 0.2 0.4 0.6 0.8 ncar 1−ASR 5 10 15 20 0 2 4 6 ·10−3 ncar CpT No rules Hand-written rules Best GE rules Figure 4.5: Values of the two indexes vs. the number ncar of cars in the simulation, obtained by performing 10 simulation for each value of ncar and each of the three set of rules. consistent with what happens in real world road traffic: the greater the number of traveling cars, the lower the average speed (i.e., the longer the time to destination) and the greater the overall number of collisions. From another point of view, there is a trade-off between efficiency and safety of the road traffic, like in the real world. Moreover, by comparing the curves related to no rules and hand-written rules, it can be seen that enforcing a road traffic regulation results in a different point in the above-mentioned trade off: with the hand-written rules traffic is in general less efficient but safer. This findings suggest that the models for the road graph, the car, and the driver are sufficiently consistent with the real word and hence adequate to investigate the feasibility of an automatic synthesis of road traffic rules. 4.2 Synthesis of traffic rules In the second experimental campaign, the feasibility of the automatic synthesis of traffic rules has been investigated using GE. To this end, 30 different evolutionary searches has been ran using the parameters shown in Table 4.3 and, concerning the fitness function (see Equation 3.1), setting ncar = 10, nsim = 10, αtime = 1, and αcollision = 100. For the weights αtime and αcollision, the values has been chosen according to the results of the experimentation discussed in the previous section and reflecting the intuition that minimizing collisions is more important than maximizing the average speed. The set of rules which obtained the best fitness among the final gen- erations of the 30 runs has been first analyzed extensively, which is shown in Table 4.4 and discussed later. It has been experimentally verified how this set of best GE rules affected the traffic with different amounts of injected traffic by 28
  • 34. Figure 4.6: The indexes (average speed ratio, acceleration-per-time, collision-per- time, broken-rules-per-time) with respect to the variation of traffic injected on the small graph used for evolution. Each of the three curves represents: the case without rules in the simulation, the case of hand written rules, the case of the evolved rules obtained with GE. Table 4.3: GE parameters. Population 100 Generations 100 Initial genotype size 512 Max wraps 10 Crossover rate 0.9 Crossover operator Two-points Mutation operator Bit flip with pmut = 0.01 Selection Tournament with size 5 29
  • 35. Figure 4.7: The trend of the 4 indexes (average speed ratio, acceleration-per-time, collision-per-time, broken-rules-per-time) on the big road graph. 30
  • 36. 1 2 3 4 5 6 ·104 0 200 400 Overall distance Overallcollisions No rules Hand-written rules Best GE rules Figure 4.8: Overall number of collisions in the simulation against the overall traveled distance in the simulation averaged across simulations with the same ncar. running 10 simulations for each value of ncar ∈ {2, 5, 8, 11, 14, 17, 20}. In other words, since GE rules were generated with ncar = 10, the generalization ability of the rules synthesis approach has been evaluated. The results are shown in Figures 4.5 and 4.8. Figure 4.5 shows the values of the two indexes (1 − ASR and CpT) vs. ncar for the three set of rules: no rules, hand-written rules, and best GE rules. It can be seen that the generated rules always obtain better index values w.r.t. hand-written rules, for both 1−ASR and CpT—the difference being always statistically significant (p < 0.001 with the Mann–Whitney U test) with the sole exception of CpT for ncar = 2, for which p < 0.05. That is, GE rules allow to reduce the number of collisions and increase the average speed. Figure 4.8 shows the same results of Figure 4.5 from another point of view, by plotting the overall number of collisions in the simulation (i.e., ncollision, on y-axis) against the overall traveled distance in the simulation (i.e., dtot, on x-axis), averaged across simulations with the same ncar, one curve for each set of rules. The figure allows to appreciate the trade-off between traffic efficiency and safety: the larger the overall distance, the larger the overall number of collisions. However, it can also be seen that the curve of GE rules strictly dominates both the other two curves (no rules and hand-written rules), hence suggesting that GE rules may be a better way of regulating road traffic regardless of the amount of cars in the graph—i.e., not only for the ncar for which the GE rules were generated. This latter finding seems to confirm the good generalization ability of this approach. Figure 4.8 also shows another interesting property of the traffic model, namely it highlights the congestion condition. In facts, in both the cases where the traffic is regulated (hand-written and GE rules), there is a maximum number of cars in the graph (ncar = 17) after which no further increasing in the overall distance can be obtained, while an increasing in overall number of collisions occurs. Interestingly, despite the fact that the maximum injected traffic before 31
  • 37. Table 4.4: Best GE rules. Rule Possible explanation 1 ∆x−1 ≤ 4.8e0 Stay within some distance from the car on right lane. 2 ¬ˆvx ≤ 1.1e1 Maintain at least a minimum speed. 3 ¬δv0 = opposite ∨ δv0 = 1∨ ¬p ∈ S ∨ ∆x0 ≤ 0.3e1 When in an section, stay close to a car coming on the same lane. 4 ˆvx ≤ 1.2e0 Do not exceed a maximum speed. congestion in the two cases is the same, with GE rules the resulting overall distance is greater and the resulting overall number of collisions is smaller. Table 4.4 shows in detail the best GE rules: it can be seen that the set consists of four rules, one of which (the 2nd) is clearly always broken in the simulations, since it tries to impose a minimum linear speed which cannot be reached with the parameters shown in Table 4.1. Rule 4 is easily understandable and its inclusion in best individual is not surprising. The role, if any, of rules 1 and 3 on the drivers’ behavior is not clear. Rule 3 is hard to understand, i.e., hard to translate in natural language: the third disjunction says that the remaining part of the rule applies only when the car is in a section (since if p ∈ I ≡ p ∈ S, the rule is true); the first and second disjunctions can be rewritten as δv0 ∈ {∅, −1, 0, 1}, hence resulting in the rule being writable as (p ∈ S ∧ δv0 = opposite) =⇒ ∆x0 ≤ 3. However, due to the driver’s algorithm (see Table 2.2) and the value of the parameter d (see Table 4.1), it is unlikely that rule 3 plays an actual role in determining drivers’ behavior. The analysis of the rules of Table 4.4 may suggest that some mechanism for detecting and cleaning ineffective rules may be beneficial in order to (i) increase the readability/understandability of the generated rules, and (ii) improve the evolutionary search. While can’t be made any meaningful prediction in this respect, it has been observe that, for the former goal, some automatic and domain-specific heuristic applied after the evolution may suffice—indeed a similar approach have been applied in [10] in the field of the automatic generation of rules for security policies. This experimental results has been evaluated by looking at how indi- viduals evolved across the 30 runs. Figure 4.10 summarizes the results of the evolutionary searches in terms of the fitness of the best individual in the popula- tion. In particular, Figure 4.10a shows how the average (across all runs) best individual fitness varies during the evolution; Figure 4.10b shows the histogram of the best individual fitness at the end of the evolution. It can be seen from Figure 4.10a that GE is in general able to decrease the fitness of individuals during the evolution: however, after approximately 32
  • 38. Figure 4.9: The fitness shape for the best individual of each of the 30 run of GE. 0 20 40 60 80 100 0.94 0.96 0.98 1 1.02 Generation Fitnessf(R) (a) Average best fitness during evolution. 0.7 0.8 0.9 1 0 10 20 Best fitness Num.ofruns (b) Best fitness histogram. Figure 4.10: Fitness of the best individual: during the evolution, averaged across the 30 runs, on the left; histogram w.r.t. the 30 runs at the end of the evolution, on the right. 33
  • 39. 20 generations, fitness decreases much more slowly. Some improvement to evolutionary search might be obtained by finely tuning the GE-related parameters, or maybe by using a different variant of GE (e.g., [11, 9]). However, it has been noted that this scenario is characterized by a remarkably high stochasticity which could, at least, slow down the search of a good solution and, from a more practical point of view, makes experimentation and parameter tuning costly due to the long time needed to compute the fitness. In this case, running a single simulation took ≈ 10 s on commodity hardware and computing the fitness of a single individual (i.e., a set of rules) consisted in running 10 simulations, precisely to mitigate the impact of the high stochasticity in the simulations. Figure 4.10b shows the histogram of the best individual fitness at the end of the evolution across the 30 runs. It can be seen that most of the runs resulted in fitness values close to 1, i.e., the distribution is skewed toward bad values. The details of the runs has been analyzed and found that in some of those cases the search got stuck in a local minimum corresponding to a set of rules including one or more rules which, in practice, enforce drivers to stand still. Under those rules, no collision occurs (CpT = 0) and no one moves (ASR = 0), which is, clearly, one extreme of the trade-off between traffic efficiency and safety. 34
  • 40. Chapter 5 Concluding remarks and future work It has been proposed and assessed experimentally, by an extensive set of sim- ulations, a method for synthesizing automatically a set of road traffic rules with the aim of maximizing such global indexes as road efficiency (high average speed) and safety (low number of collisions). The motivation for this work is a future scenario in which human and machine-based drivers will coexist on the roads, making current road regulation possibly unsuitable or inefficient. No other similar proposal exist, to the best of our knowledge. The method proposed is based on GE: individuals are sets of rules written according to a context-free grammar that has been designed ad hoc to express quite expressive concepts such as, e.g., “stay on the rightmost free lane” or “slow down when approaching an intersection”. The fitness of a candidate set of rules is given by a weighted sum of the traffic efficiency and safety resulting from the application of the rules set in a number of simulations, which makes this GE application highly stochastic. Results of the experimental evaluation are promising, since generated rules result in simulated road traffic which is more efficient and safer than that regulated by hand-written rules or not regulated at all. This work may be extended in different ways, such as: (i) including a more fine-grained model (e.g., concerning intersections); (ii) considering a different way for expressing rules (e.g., with Linear Temporal Logic); (iii) better exploring GE parameters and/or variants. 35
  • 41. Bibliography [1] road Automated Vehicle Standards Committee, O., et al.: Sae j3016: Tax- onomy and definitions for terms related to on-road motor vehicle automated driving systems. SAE International [2] Bartoli, A., De Lorenzo, A., Medvet, E., Tarlao, F.: Syntactical similar- ity learning by means of grammatical evolution. In: Handl, J., Hart, E., Lewis, P.R., L´opez-Ib´a˜nez, M., Ochoa, G., Paechter, B. (eds.) Parallel Problem Solving from Nature – PPSN XIV: 14th International Confer- ence, Edinburgh, UK, September 17-21, 2016, Proceedings. pp. 260–269. Springer International Publishing, Cham (2016), http://dx.doi.org/10. 1007/978-3-319-45823-6_24 [3] Brabazon, A., O’Neill, M.: Evolving technical trading rules for spot foreign- exchange markets using grammatical evolution. Computational Management Science 1(3-4), 311–327 (2004) [4] Drake, J.H., Kililis, N., ¨Ozcan, E.: Generation of vns components with grammatical evolution for vehicle routing. In: European Conference on Genetic Programming. pp. 25–36. Springer (2013) [5] Gipps, P.G.: A behavioural car-following model for computer simulation. Transportation Research Part B: Methodological 15(2), 105–111 (1981) [6] Greene, J.D.: Our driverless dilemma. Science 352(6293), 1514–1515 (2016) [7] Kirkpatrick, K.: The moral challenges of driverless cars. Commun. ACM 58(8), 19–20 (Jul 2015), http://doi.acm.org/10.1145/2788477 [8] Koza, J.R.: Genetic programming: on the programming of computers by means of natural selection, vol. 1. MIT press (1992) [9] Louren¸co, N., Pereira, F.B., Costa, E.: Sge: a structured representation for grammatical evolution. In: International Conference on Artificial Evolution (Evolution Artificielle). pp. 136–148. Springer (2015) [10] Medvet, E., Bartoli, A., Carminati, B., Ferrari, E.: Evolutionary infer- ence of attribute-based access control policies. In: Gaspar-Cunha, A., 36
  • 42. Henggeler Antunes, C., Coello, C.C. (eds.) Evolutionary Multi-Criterion Optimization: 8th International Conference, EMO 2015, Guimar˜aes, Portu- gal, March 29 –April 1, 2015. Proceedings, Part I. pp. 351–365. Springer International Publishing, Cham (2015), http://dx.doi.org/10.1007/ 978-3-319-15934-8_24 [11] O’Neill, M., Brabazon, A., Nicolau, M., Mc Garraghy, S., Keenan, P.: πgrammatical evolution. In: Genetic and Evolutionary Computation Con- ference. pp. 617–629. Springer (2004) [12] Rizaldi, A., Althoff, M.: Formalising traffic rules for accountability of autonomous vehicles. In: 2015 IEEE 18th International Conference on Intelligent Transportation Systems. pp. 1658–1665. IEEE (2015) [13] Ryan, C., Collins, J., O’Neill, M.: Grammatical evolution: Evolving pro- grams for an arbitrary language. In: European Conference on Genetic Programming. pp. 83–96. Springer (1998) [14] Sanchez, J.J., Galan, M., Rubio, E.: Applying a traffic lights evolutionary optimization technique to a real case: “las ramblas” area in santa cruz de tenerife. IEEE Transactions on Evolutionary Computation 12(1), 25–40 (Feb 2008) [15] Shepardson, D.: Study: Self-driving cars to jolt market by 2035. The Detroit News (2013) [16] Tachet, R., Santi, P., Sobolevsky, S., Reyes-Castro, L.I., Frazzoli, E., Helbing, D., Ratti, C.: Revisiting street intersections using slot-based systems. PLoS one 11(3), e0149607 (2016) [17] Tumova, J., Hall, G.C., Karaman, S., Frazzoli, E., Rus, D.: Least-violating control strategy synthesis with safety rules. In: Proceedings of the 16th International Conference on Hybrid Systems: Computation and Control. pp. 1–10. HSCC ’13, ACM, New York, NY, USA (2013), http://doi.acm. org/10.1145/2461328.2461330 [18] Vanholme, B., Gruyer, D., Lusetti, B., Glaser, S., Mammar, S.: Highly automated driving on highways based on legal safety. IEEE Transactions on Intelligent Transportation Systems 14(1), 333–347 (2013) [19] Wen, W.: A dynamic and automatic traffic light control expert system for solving the road congestion problem. Expert Systems with Applications 34(4), 2370–2381 (2008) 37