Weighting for Shortest Distance
I assigned a distance value to each edge of the graph (which represent roads in the network). This distance value is then used as a weight for the graph algorithm to use to pick the fastest path.
I assigned a distance value to each edge of the graph (which represent roads in the network). This distance value is then used as a weight for the graph algorithm to use to pick the fastest path.
I have chosen to base my ethical decisions on utilitarianism. This ethical framework works on the “greatest happiness principle” which is the idea that you should prioritise happiness for the largest possible group of people, rather than focussing on the individual.
In the context of self-driving cars, this means that we should assign weights to prioritise the safety of pedestrians and other road users (likely to be found more often in higher activity areas), over the convenience of the car's passengers.
Assigning edge weightings for ethics and safety requires information about the risk level colours of the areas on either side of the road the number of buildings.
First, I associated each colour with a numeric risk value (red was 3.96, blue was 2.74 and green was 1.56). For each edge, I found the risk value of the zones at both sides of the road and calculated the average of these values. This average was then used as the first component of the weighting.
I chose to use the average risk value from both sides of the road because risks do not only come from the left of the vehicle. For example, if a child or animal runs out into the road there's a significant threat posed to them regardless of which side of the road they run from. Additionally, it is not uncommon for cars to be parked on one or both sides of the road so there is no guarantee that the vehicle will be driving on the left side of the road for the majority of their time in the busier areas.
Next, I added up the number of buildings on each side of the road. This number was then multiplied by a constant which determines the importance of buildings to the algorithm.
| Activity Level | Buildings | Activity Weight | Buildings Weight | Total Safety Weight | |
|---|---|---|---|---|---|
| A → B | Red | 2 | 3.96 | 0.36 | 4.32 |
| U → V | Blue/Green | 4 | 2.15 | 0.72 | 2.87 |
| L → S | Green | 0 | 1.56 | 0 | 1.56 |
Once I had created an algorithm for the shortest route and an algorithm for the safest route, I unified the two into a single algorithm which calculates the best route considering both speed and safety. This was done by adding the ethics & safety weightings to the distance weighting, and multiplying the distance weighting by a constant to allow for more control. I did not add a multiplier for ethics & safety because all of its components can individually be controlled.
To find routes within the city, we will first transform the physical road layout into a graph. A graph is comprised of nodes connected together with edges, and each edge is assigned a value called a weight which encourages the network to avoid certain areas.
In the city network, the weight is comprised of the length of the road, the activity level of the areas either side of the road, and the number of buildings either side of the road. A higher number of buildings, higher activity level, or longer distance will result in the algorithm trying to avoid travelling down this road.
I used Dijkstra's algorithm for finding the best route through the city. This is a simple to implement algorithm which checks every possible route from the source node to any other destination node. This ensures it always finds the optimal path for the vehicle to take, at the expense of some efficiency. Dijkstra's algorithm is also able to be used in cities which contain one-way roads by using directed graphs.
