21
PROBLEM: Finding the optimal building to place a police car

Finding the optimal building to place a police car

Embed Size (px)

Citation preview

PROBLEM:

Finding the optimal building to place a police car

In the city there are some buildings.

Some of them needs protection.

The problem is that we have only one police car.

So it’s important to choose the optimal building to place the car near it.

We neglect the values such as

• the amount of goods that can be taken from building

• the probability that a crime will be performed in the building

So by “optimal building” we mean that by choosing this building we will maximize the number of caught criminals.

Plan1) Development environment

2) Dijkstra's algorithm

3) Solution for the main problem

ShiVa3D is the developers’ tool for easily creating 3D applications. ShiVa is a WYSIWYG 3D Editor.

The ShiVa3D is a true multi-platform 3D game engine, which handles advanced shading systems, physics engine, HUD rendering and the sound library.

Game Scripting

ShiVa scripting is based upon an optimized version of Lua. You can also code directly in C, C++ and Objective-C 

ShiVa Authoring Tool compiles projects generated by ShiVa Editor into executable applications for all the supported devices : Windows, Mac, Linux, iPhone, iPad, Android, BlackBerry QNX WebOS, Airplay SDK and Wii.

Dijkstra's algorithmThe algorithm finds the shortest path from one vertex to all other vertices.

Cubes are buildings.

Lines between cubes are roads.

Buildings that need protection are green.

Building where we’ll place car near is red.

To set the city in the memory we will use graph.

• Buildings are vertices of graph.

• Roads from one building to another are edges of graph.

To find the optimal building we’ll have to traverse all buildings.

For each building:

• we will use Dijkstra's algorithm to calculate the shortest distance to other buildings.• Then, based on distances, we will getthe amount of buildings we can reach from the current building.

By reaching the building we mean that a police car will get to the building before a crime is committed

In result we’ll get a list of buildings from which we can reach maximum amount of protected buildings.

Example: The list is {1,2}

Now we need to choose one building from this list. We will choose the building with minimal sum of distances to the protected buildings.

Example: The list is {1,2} Selected building: 2

Another example

Example: The list is {1,2,3,4,5} Selected building: 2

Running time• For V vertices Dijkstra's algorithm has worst running time of O(V * logV)

• Running time of finding maximum element from the list is in worst case O(V)

• Above steps are done for V vertices so

the worst running time of the algorithm is

O( V (V*logV + V) )

Thank you for your attention