IS 2470 Interactive System Design Java Servlet Project

IS 2470 Interactive System Design Java Servlet Project
Implementation of Geographic Information Systems Algorithm
Corey Jackson, Haihua Li, Tom Scanlon
Customer: Dr. Hassan Karimi, Professor - University of Pittsburgh
Users: Students in INFSCI 2720 and INFSCI 1068 courses in Geographic Information Systems
Purpose: To demonstrate how different algorithms execute a shortest route search over a
network.
Project Description:
We developed a servlet that calculates a shortest route path between two points. The servlet
implements 3 algorithms (A*, Dijkstra’s, brute force) for calculating shortest route. When the
user requests a shortest route, he will be shown the results of each algorithm, along with
information about how each algorithm reached this answer (attempted paths, nodes visited, etc).
Obviously, the goal of this project is to demonstrate and compare different algorithms, along
with providing insight into how they actually find a result. This will make it a useful learning
tool for students, which is a goal for the project.
Our application works as follows: The user will go to a web site that shows a map of the US with
15 major cities marked and connections between them. Some cities will have direct connections
between them, while others will only be connected by passing through 1 or more other cities.
There will be two cost functions for the network. One will be distance (miles) and the other will
be dollars (as if buying an airline ticket). The user will select his begin city, end city and cost
function (dollars or miles) and then hit Submit. The servlet will return the results side-by-side for
each algorithm (i.e. the best route that each found, how long each took to execute, the number of
nodes visited to find correct path, etc.)
The application will demonstrate the various methods used to achieve the results. The execution
times and the number of nodes visited will vary. The importance of each will vary depending on
the application the algorithm will be used for.
The connections have two different weight functions, distance and cost. Sometimes, the shortest
route is not necessarily the best way if cost is your primary concern (as in a person on a limited
budget). This is an important concept for students to understand.
Application Tour
First, the user is presented with a brief description of the page, the scope of the project,
and the intended audience. This will give the user the ability to determine if this is the
proper application and if he is the intended audience. There is also a description of each
algorithm used in the application, so the user can estimate the results and have a full
understanding of what is going on.
Next, the user will be presented with a map of the 15 possible cities and the connections between
them. The map will allow the user to visualize the best possible route should be. He will be
presented with options for a starting point and a destination point and a choice of mileage/cost
function.
Choose cities
And weight
function
Finally, the user will be presented with the results. A matrix of the data will be displayed and the
results of the three algorithms. The algorithms can be compared and contrasted. The side-byside layout makes the comparisons easier.
Results of each
Algorithm
Matrix of the data:
Path that each algorithm used.
Each algorithm will use a different method to achieve the ultimate goal (the shortest route). The
path(s) tried are listed below each algorithm.
Design Process
The group first came up with a possible topic and a possible user. Dr. Karimi and his GIS
students were chosen. We brainstormed for an initial topic to present to Dr. Karimi. He liked
some of our ideas and offered some new suggestions and some resources to research our topic
further. We individually looked for other similar projects for design ideas. We met again to
discuss our findings, refine our proposal and present a mock-up to him. Our proposal was met,
pending minor modifications, with approval and the formal design process began. Testing was
done throughout the design process.
Project Timeline:
4/3/02
Initial Brainstorming  Project for Karimi and GIS students
4/5/02
Present topic to Karimi
Discuss improvements.
Research (plagiarize) other similar applications
4/6/02
Discuss Karimi’s suggestions
Formalize our proposal
Choose algorithms
Identify tasks to be completed
Design mockup to present to Karimi
4/8/02
Meet with Karimi again
Refine 3rd algorithm
Proposal approved
4/10/02
Code HTML pages
Begin coding algorithms
4/13/02
Gather and design map
Design Map
4/14/02
Test and modify the design.
4/15/02
Finish HTML
Proof text and layout
4/22/02
Coding complete
Test project
4/23/02
Project documentation finalized
4/24/02
Submit and present project to class
4/25/02
Present Final Project present to user
Most of the design process was done during weekly meetings on Saturday afternoons. Major
decisions were openly discussed and decided on as a group. After each meeting, a member was
typically assigned a task. Between meetings, email was the primary means of communication.
Questions and comments were posted to the group and encouraged open discussion. Each
interaction was posted to CourseWeb so the others can download it and install it themselves.
This also allowed us to track our progress and helped us coordinate future additions.
The attached are documents from some of our meetings (as a group and with Dr. Karimi) and
from individual work. The notes illustrate the design process. Each major iteration of the
design was discussed and mockups were developed on paper. The algorithms were also sketched
to determine the best way to illustrate them to the users.
Project Implementation:
Three methods were chosen for searching our city network for the shortest route
between cities. While we loosely refer to each method in this project as an
algorithm, only one truly qualifies as an algorithm, Dijkstra’s Algorithm. The
other choices for searching the network are the A* heuristic and a brute force
computation of all paths. GIS Students should be familiar with all these methods
from classroom discussion and this will give them a chance to see a simple
implementation of each. Each algorithm also uses an adjacency matrix as a data
structure for representing nodes and segments. GIS students should also be vary
familiar with this concept, and the actual adjacency matrix used by the
computations is provided with the output to aid in student learning and
reinforcement of classroom concepts. Some notes on the actual implementation of
our methods (“algorithms”) follow.
Brute force computation: In this method, every possible path to search the
network is traversed, including paths that sometimes cycle back to previously
visited nodes. The procedure then finds all such path the meet the begin and
endpoint requirements, calculate their distances, and selects the shortest one. This
method is very ‘dumb’ when it come to searching a network and would be of
limited use in a large, real-world network. However, it is provided for educational
purposes as it sets the baseline standards for which all algorithms can be
measured against.
Dijsktra’s Algorithm: This is a very famous algorithm for finding the shortest
path between nodes in a network. It is similar to brute force in that does an
exhaustive search also. However, it uses nested, iterative loops to search the
network more efficiently and it does not consider cyclical paths the way brute
force does. This algorithm is viewed as an improvement on brute force
computations both in terms or processing time and number of paths considered,
but both methods will return similar results.
A* Heuristic: The A* heuristic is also a famous method for searching a state
space, often used in artificial intelligence and in neural networks. It is not truly an
algorithm, but rather a ‘greedy’ heuristic that always considers the next closest
node to be the path to take, without considering the others. There are a lot of
improvements that can be added to this method to make it work in an ideal
manner (including combining it with Dijkstra’s Algorithm). However, for
educational purposes, we implemented only the simplest form of this heuristic.
This method, then, will start at the begin city and always choose the next closest
city in an iterative fashion until the destination is reached. The only restriction we
applied was that a city may not be visited twice in the same route. However, we
did not apply backtracking which is commonly done with A* to back-up and try
one of the ‘more expensive’ prior nodes if the current route costs exceeds some
threshold. This is done intentionally for educational purposes. Thus, our A*
implementation will return the shortest route it finds by following its rule of
always picking the next closest node when constructing a route. In most cases,
this is truly the shortest route. In some cases, there is a better route found by the
other two methods. However, A* always outperforms these other methods when it
comes to processing time and number of paths searched, always returning a quick
result that is usually the best route too.
Students can play around with these different algorithms and compare the results.
They can then consider situations when the exact shortest route is needed
(Dijsktra’s Algorithm) and situations where sometimes getting a slight longer
route is acceptable as long as the answer is always returned quickly. Students
should consider factors such as the size of the network, the amount of connecting
nodes (i.e. density of the adjacency matrix), computing capabilities and time
restrictions.