Starting from:

$25

CSCI5260- Project 1 – Simple and Heuristic Searches Solved

Project 1 – Simple and Heuristic Searches

Part 1 – The Buc Mobile
Background
The BucMobile is an ETSU-created autonomous vehicle that has access to Open Street GPS data from

OpenStreetMap.org. BucMobile needs your help in using its data to navigate around the city of Johnson City. The BucMobile’s starting location will always be the stop sign next to Reece Museum on ETSU’s campus. The BucMobile would like you to test several routes using four algorithms. You will need to present your results in a series of figures with explanations. Preparation

Necessary Libraries

Probably needed from pip install—osmnx – A library that allows you to pull data from the Open Street GPS and store it as an undirected graph of GPS coordinates.https://osmnx.readthedocs.io/en/stable/
graph_objects – plotly is a data visualization library, and the graph_objects class represents parts of a figure.https://plotly.com/python/
networkx
Built-in Python libraries—collections – allows you to use python’s double-ended and other queue structures.
numpy – the Python Scientific Computing package
pyplot (optional) – for providing additional data plot functionality.
Provided Functions

I have provided the following two functions in the project1_mapper.py file on D2L.

node_list_to_path(gr, node_list)
Given a networkx graph (gr) and an ordered list of nodes (node_list) in the format [osmid, osmid, osmid, …], return the list of edges (given as a list of location pairs) that follows the path defined by the nodes

plot_path(lat, long, origin_point, destination_point)
Given (1) a path-ordered list of latitudes, (2) a path-ordered list of longitudes, (3) an origin point as a tuple in the format (osmid, {"y": latitude, "x": longitude, "osmid": long_integer}), and (4) a destination point as a tuple in the format (osmid, {"y": latitude, "x": longitude, "osmid": long_integer}), open a browser and display a map of the route.

Requirements
Create a driver program that traverses six given routes (listed below), using three different uninformed search algorithms. You must use breadth-first search and depth-first search. You may choose any other uninformed search algorithm for the other one.

Create a graph based on Open Street data from the address ‘1276 Gilbreath Drive, Johnson City, TN, USA’ at a distance of 4000 meters, and a network_type of 'drive'. Example code is provided for the 1 km area around the White House in Washington, DC.
Create the origin point at 36.30321114344463 latitude and -83.36710826765649 longitude. Use the osmx library’s get_nearest_node function to locate the node in the graph closest to that point.
Use the following routes in your program [You can look up the GPS coordinates yourselves]:Route 1: ETSU to Walmart (West Market Street)
Route 2: ETSU to Target (North Roan Street)
Route 3: ETSU to the Tweetsie Trail entrance (Legion Street at Alabama Street)
Route 4: ETSU to Frieberg’s German Restaurant (Main Street at Tipton Street)
Route 5: ETSU to Food City (South Roan Street)
Route 6: ETSU to Best Buy (Peoples Street)
Create the following algorithms, placing each in its own function, to test each route: a. Breadth-First SearchDepth-First Search
Developer’s Choice of an uninformed search algorithm
Hint: In each function, make sure you track the nodes you visit—but also track the node you came from for that particular visit. Doing so will allow you to recreate the path after reaching the destination.

Suggested algorithm: create a backtrack function that accepts your visited list and your destination. It then works backwards to the origin so you know exactly which path you took to locate the destination. You should return a list of osmids in the order of the path (forward or backward; it doesn’t matter).
Hint: It might also be helpful to return a list of latitudes and a list of longitudes in the same order as your route list. This can be passed into the plot_path function provided.

Use the information you have collected, and present it in a written report. You must include the following:An analysis of the search space. You may need to explore the graph a bit to do this effectively. b. For each route, for each algorithm, analyzeThe algorithm’s efficiency based on runtime [use Lab 2 code as an example for collecting this data], and
The algorithm’s efficiency based on steps taken. You can count a “step” however you wish, but you need to explain how you’re counting in the writeup.
An overall analysis of which search is best for this situation. To receive full credit, you must explain each search algorithm and why it is or is not suited for this problem.
It would be nice to see tables and/or charts here, with brief explanations rather than wordy paragraph formats. You should incorporate images of each of your map routes.

Part 2 – Bucky’s Treasure Hunt
ETSU’s mascot, Bucky the Bucanneer is looking for his treasure. Bucky wants to locate it quickly to ensure that the other

Bucanneers out there don’t steal it before he retrieves it. Since he knows that ETSU has the most awesome Computer Science program on the Seven Seas, he wants you to simulate his treasure hunt in a computer program. Bucky will be glad to give you his two existing navigation charts, although, he also expects you to create a third navigation chart so he knows that you’ve tested your program thoroughly.

Provided Files
py – a graphics library that simplifies graphical programming in Python.
py – a required file that informs Python to look for included files in the current directory.
py – the skeleton program, which contains the following structures: a. class Field
Attributes:points – The is the set of all points you could visit
path – This is the list of Point() objects that constitute the path from start to end
polygons – This is the list of obstacles within the field
extras – This is a Python list that holds extra stuff that you want to erase
width – The width of the field on the screen
height – The height of the field on the screen
start – The staring location, a Point() object
end – The ending location, a Point() object
win – The window to display the field ii. Functions:
setCoords – sets the coordinates of the window (i.e., the “viewport”)
set_background – sets the background color
add_polygon – adds the permanent polygon to the field and adds its points to points
add_start – adds the start location to the field
add_end – adds the end location to the field
get_neighbors – for a giving Point, returns a list of Points—polygon vertexes—within the Point’s line of sight.
wait – pauses the window to await a click.
close – closes the window
reset – resets the window by undrawing all extras (adds new start/end points if passed)
backtrack – recreates the path located. Uses a came_from dictionary that holds the parents of each node
straight_line_distance – calculates the Euclidean distance between two points
depth_first_search – the uninformed search algorithm that locates the treasure
breadth_first_search – the uninformed search algorithm that locates the treasure
best_first_search – the heuristic function that locates the treasure
astar_search – the A* algorithm that locates the tresure
setup_game_map(f) Adds the polygon that represents Bucanneer Island.
setup_logo_map(f) Adds the polygons that represent the ETSU Logo
setup_polygon_field(f) Adds a number of polygons that you generate
mainSets up the Field and the search algorithms using different start and end points.
Requirements
Complete the following search algorithms in the Field class:depth_first_search
breadth_first_search
best_first_search
astar_search
Run each of the four algorithms against the two maps that Bucky has provided, and one that you create. a. The ETSU Logo MapThe Bucanneer Island Map
A new map of polygons that you create, and that contains at least 10 polygons of random sizes.
Create a report of your findings, that includes:Collected Data:Screenshots of each search/map
The runtime for each algorithm [Use the Lab2 code as an example here]
The total path cost (in Euclidean Distance) for each search/map iv. The total number of steps for each search/map
A conclusion that gives the advantages and disadvantages of using each of the four search algorithms for Bucky’s Treasure Hunt.
It would be nice to see tables and/or charts, with brief explanations rather than wordy paragraph formats.

Project 1 – Simple and Heuristic Searches

Part 1 – The Buc Mobile
Background
The BucMobile is an ETSU-created autonomous vehicle that has access to Open Street GPS data from

OpenStreetMap.org. BucMobile needs your help in using its data to navigate around the city of Johnson City. The BucMobile’s starting location will always be the stop sign next to Reece Museum on ETSU’s campus. The BucMobile would like you to test several routes using four algorithms. You will need to present your results in a series of figures with explanations. Preparation

Necessary Libraries

Probably needed from pip install—osmnx – A library that allows you to pull data from the Open Street GPS and store it as an undirected graph of GPS coordinates.https://osmnx.readthedocs.io/en/stable/
graph_objects – plotly is a data visualization library, and the graph_objects class represents parts of a figure.https://plotly.com/python/
networkx
Built-in Python libraries—collections – allows you to use python’s double-ended and other queue structures.
numpy – the Python Scientific Computing package
pyplot (optional) – for providing additional data plot functionality.
Provided Functions

I have provided the following two functions in the project1_mapper.py file on D2L.

node_list_to_path(gr, node_list)
Given a networkx graph (gr) and an ordered list of nodes (node_list) in the format [osmid, osmid, osmid, …], return the list of edges (given as a list of location pairs) that follows the path defined by the nodes

plot_path(lat, long, origin_point, destination_point)
Given (1) a path-ordered list of latitudes, (2) a path-ordered list of longitudes, (3) an origin point as a tuple in the format (osmid, {"y": latitude, "x": longitude, "osmid": long_integer}), and (4) a destination point as a tuple in the format (osmid, {"y": latitude, "x": longitude, "osmid": long_integer}), open a browser and display a map of the route.

Requirements
Create a driver program that traverses six given routes (listed below), using three different uninformed search algorithms. You must use breadth-first search and depth-first search. You may choose any other uninformed search algorithm for the other one.

Create a graph based on Open Street data from the address ‘1276 Gilbreath Drive, Johnson City, TN, USA’ at a distance of 4000 meters, and a network_type of 'drive'. Example code is provided for the 1 km area around the White House in Washington, DC.
Create the origin point at 36.30321114344463 latitude and -83.36710826765649 longitude. Use the osmx library’s get_nearest_node function to locate the node in the graph closest to that point.
Use the following routes in your program [You can look up the GPS coordinates yourselves]:Route 1: ETSU to Walmart (West Market Street)
Route 2: ETSU to Target (North Roan Street)
Route 3: ETSU to the Tweetsie Trail entrance (Legion Street at Alabama Street)
Route 4: ETSU to Frieberg’s German Restaurant (Main Street at Tipton Street)
Route 5: ETSU to Food City (South Roan Street)
Route 6: ETSU to Best Buy (Peoples Street)
Create the following algorithms, placing each in its own function, to test each route: a. Breadth-First SearchDepth-First Search
Developer’s Choice of an uninformed search algorithm
Hint: In each function, make sure you track the nodes you visit—but also track the node you came from for that particular visit. Doing so will allow you to recreate the path after reaching the destination.

Suggested algorithm: create a backtrack function that accepts your visited list and your destination. It then works backwards to the origin so you know exactly which path you took to locate the destination. You should return a list of osmids in the order of the path (forward or backward; it doesn’t matter).
Hint: It might also be helpful to return a list of latitudes and a list of longitudes in the same order as your route list. This can be passed into the plot_path function provided.

Use the information you have collected, and present it in a written report. You must include the following:An analysis of the search space. You may need to explore the graph a bit to do this effectively. b. For each route, for each algorithm, analyzeThe algorithm’s efficiency based on runtime [use Lab 2 code as an example for collecting this data], and
The algorithm’s efficiency based on steps taken. You can count a “step” however you wish, but you need to explain how you’re counting in the writeup.
An overall analysis of which search is best for this situation. To receive full credit, you must explain each search algorithm and why it is or is not suited for this problem.
It would be nice to see tables and/or charts here, with brief explanations rather than wordy paragraph formats. You should incorporate images of each of your map routes.

Part 2 – Bucky’s Treasure Hunt
ETSU’s mascot, Bucky the Bucanneer is looking for his treasure. Bucky wants to locate it quickly to ensure that the other

Bucanneers out there don’t steal it before he retrieves it. Since he knows that ETSU has the most awesome Computer Science program on the Seven Seas, he wants you to simulate his treasure hunt in a computer program. Bucky will be glad to give you his two existing navigation charts, although, he also expects you to create a third navigation chart so he knows that you’ve tested your program thoroughly.

Provided Files
py – a graphics library that simplifies graphical programming in Python.
py – a required file that informs Python to look for included files in the current directory.
py – the skeleton program, which contains the following structures: a. class Field
Attributes:points – The is the set of all points you could visit
path – This is the list of Point() objects that constitute the path from start to end
polygons – This is the list of obstacles within the field
extras – This is a Python list that holds extra stuff that you want to erase
width – The width of the field on the screen
height – The height of the field on the screen
start – The staring location, a Point() object
end – The ending location, a Point() object
win – The window to display the field ii. Functions:
setCoords – sets the coordinates of the window (i.e., the “viewport”)
set_background – sets the background color
add_polygon – adds the permanent polygon to the field and adds its points to points
add_start – adds the start location to the field
add_end – adds the end location to the field
get_neighbors – for a giving Point, returns a list of Points—polygon vertexes—within the Point’s line of sight.
wait – pauses the window to await a click.
close – closes the window
reset – resets the window by undrawing all extras (adds new start/end points if passed)
backtrack – recreates the path located. Uses a came_from dictionary that holds the parents of each node
straight_line_distance – calculates the Euclidean distance between two points
depth_first_search – the uninformed search algorithm that locates the treasure
breadth_first_search – the uninformed search algorithm that locates the treasure
best_first_search – the heuristic function that locates the treasure
astar_search – the A* algorithm that locates the tresure
setup_game_map(f) Adds the polygon that represents Bucanneer Island.
setup_logo_map(f) Adds the polygons that represent the ETSU Logo
setup_polygon_field(f) Adds a number of polygons that you generate
mainSets up the Field and the search algorithms using different start and end points.
Requirements
Complete the following search algorithms in the Field class:depth_first_search
breadth_first_search
best_first_search
astar_search
Run each of the four algorithms against the two maps that Bucky has provided, and one that you create. a. The ETSU Logo MapThe Bucanneer Island Map
A new map of polygons that you create, and that contains at least 10 polygons of random sizes.
Create a report of your findings, that includes:Collected Data:Screenshots of each search/map
The runtime for each algorithm [Use the Lab2 code as an example here]
The total path cost (in Euclidean Distance) for each search/map iv. The total number of steps for each search/map
A conclusion that gives the advantages and disadvantages of using each of the four search algorithms for Bucky’s Treasure Hunt.
It would be nice to see tables and/or charts, with brief explanations rather than wordy paragraph formats.v

More products