For each POI record, determine which city is closest to it. The closest city must be...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
For each POI record, determine which city is closest to it. The closest city must be in the same country (the "country_code' values must match). To measure distance, use the squared Euclidean distance. That is, if a POI record has the lat-long coordinates (h. v,), and a city record has the lat-long coordinates (he, v), then their squared Euclidean distance is (hp - h₂)² + (vp - v,)². Outputs: Your function should return a new Python dictionary of dictionaries. The outer dictionary's keys should be the same POI IDs. The inner dictionary should have exactly two keys: 'type', which is the POI type (not the city type), and city', which is the name of the closest city. See the demo below. Notes and hints: 1. Recall that the IEEE floating-point standard defines a special value that corresponds with infinity. This value is available in Python as math. inf, and it m be a helpful initializer as you search for the closest city to a given POI. 2. We have provided a function, dd_distance_squared, that will compute the squared Euclidean distance given the attributes of a POI and the attributes of a city. 11 DEMO INPUTS ### demo pois_ex2 - ('abe': {'country_code': 'US', 'lat's -5.2, 'long's 2.0, 'type': 'Restaurant'), 'def's ('country_code': 'US', 'lat's -2.3, 'long' 6.8, 'type's Golf Course'). "ghi's ('country_code's 'PL', lat': 1.0, 'long': 6.5, 'type': 'Apartment'), jkl's ('country_code's 'VN", "lat's 11.0, 'long': 1.5, "type': 'Post Office')) demo_cities_ex2 - \ (Seattle, United States': {"country_code': 'US', 'lat': -5.0, "long': 3.0, 'type': 'Other'), Richmond, United States': {'country_code': 'US', 'lat': -2.0, 'long': 7.0, 'type': 'other'), 'Hanoi, Vietnam': {"country_code': 'V', 'lat': 10.0, 'long': 2.0, 'type': 'National and provincial capital') "Curitiba, Brazil': {'country_code': 'BR', 'lat': 0.0, 'long': 6.0, type': 'Provincial capital'}} The demo included in the solution cell below should display the following output: ('abe': {'type': 'Restaurant', 'city': 'Seattle, United States"}, 'def': ('type': 'Golf Course', 'city': 'Richmond, United States"}, jkl's ('type': 'Post Office', 'city': 'Hanoi, Vietnam')} Observe that the POI 'ghi' does not appear in the output. That's because its country code, "PL", does not match any country code of any o 3 For each POI record, determine which city is closest to it. The closest city must be in the same country (the "country_code' values must match). To measure distance, use the squared Euclidean distance. That is, if a POI record has the lat-long coordinates (h. v,), and a city record has the lat-long coordinates (he, v), then their squared Euclidean distance is (hp - h₂)² + (vp - v,)². Outputs: Your function should return a new Python dictionary of dictionaries. The outer dictionary's keys should be the same POI IDs. The inner dictionary should have exactly two keys: 'type', which is the POI type (not the city type), and city', which is the name of the closest city. See the demo below. Notes and hints: 1. Recall that the IEEE floating-point standard defines a special value that corresponds with infinity. This value is available in Python as math. inf, and it m be a helpful initializer as you search for the closest city to a given POI. 2. We have provided a function, dd_distance_squared, that will compute the squared Euclidean distance given the attributes of a POI and the attributes of a city. 11 DEMO INPUTS ### demo pois_ex2 - ('abe': {'country_code': 'US', 'lat's -5.2, 'long's 2.0, 'type': 'Restaurant'), 'def's ('country_code': 'US', 'lat's -2.3, 'long' 6.8, 'type's Golf Course'). "ghi's ('country_code's 'PL', lat': 1.0, 'long': 6.5, 'type': 'Apartment'), jkl's ('country_code's 'VN", "lat's 11.0, 'long': 1.5, "type': 'Post Office')) demo_cities_ex2 - \ (Seattle, United States': {"country_code': 'US', 'lat': -5.0, "long': 3.0, 'type': 'Other'), Richmond, United States': {'country_code': 'US', 'lat': -2.0, 'long': 7.0, 'type': 'other'), 'Hanoi, Vietnam': {"country_code': 'V', 'lat': 10.0, 'long': 2.0, 'type': 'National and provincial capital') "Curitiba, Brazil': {'country_code': 'BR', 'lat': 0.0, 'long': 6.0, type': 'Provincial capital'}} The demo included in the solution cell below should display the following output: ('abe': {'type': 'Restaurant', 'city': 'Seattle, United States"}, 'def': ('type': 'Golf Course', 'city': 'Richmond, United States"}, jkl's ('type': 'Post Office', 'city': 'Hanoi, Vietnam')} Observe that the POI 'ghi' does not appear in the output. That's because its country code, "PL", does not match any country code of any o 3
Expert Answer:
Answer rating: 100% (QA)
import math def dddistancesquaredpoi city return poilat citylat2 poilong citylong2 def findclosestci... View the full answer
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these programming questions
-
A Drug Identification Number (DIN) is: 1) An 8-digit number given by Service Canada that confirms the disinfectant or sanitizer product is approved and safe for use in Canada 2) A 10-digit number...
-
Your task: You are asked to write a function that applies Simulated Annealing to a Traveling Salesman Problem. That is, your function will run simulated annealing as discussed in class and report...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant chain. The companys EBIT was $120 million last year and is not expected to grow. PizzaPalace is in...
-
Three plane mirrors intersect at right angles. A beam of laser light strikes the first of them at an angle ? with respect to the normal (Fig. 33.39).(a) Show that when this ray is reflected off of...
-
Jefferson Countys General Fund began the year 2020 with the following account balances: During 2020, Jefferson experienced the following transactions: 1. The budget was passed by the County...
-
Social Jetlag Social jetlag refers to the difference between circadian and social clocks, and is measured as the difference in sleep and wake times between work days and free days. For example, if...
-
Gerken Fabrication Inc. uses the job order cost system of accounting. The following information was taken from the companys books after all posting had been completed at the end of March: a. Compute...
-
Combine the following expressions into a single logarithm: log40 (7) + log40 (3) = log40 (1) log43 (5) log43 (7) = log43 ( log35 (9) (log35 (5) + log35 (2)) = log35( = 2 log25 (3) log25( 2 log39(x)+2...
-
(a) For the circuit of Problem 5.1, sketch load lines in the I c - V ce plane for R L = 2 k¦ and R L = 10 k¦. (b) Calculate the maximum average sinusoidal output power that can be...
-
A drag racer accelerates from a dead stop and crosses the finish line (0.250 miles down the track) 3.90 seconds later. What was the racer's average acceleration in that mile? Make your answer in...
-
define a robot and name the most commonly used robot configuration system?
-
Define the concatenation operator of finite displacements. Illustrate with an example.?
-
Presented below is pension information related to Lucan Inc. for the calendar year Y8. The corporation uses ASPE. Current service costs $50,000 Contributions to the plan 55,000 Actual return on plan...
-
What are two resources that may be useful in disassembling a laptop computer?
-
Sports Performance Increased (BPI) Ltd. is a relatively new company that created various sports apps designed for athletes. These apps can be downloaded onto a mobile device and assist users in...
-
A pt. presents to the ER with a new onset of dizziness and fatugue. Onexamination, the pt's heart rate is 35 beats/min, BP is 70/50, resp. rate is 22 per min, 02 sat is 95%. What is the appropriate...
-
The time to assemble the first unit on a production line is 10 hours. The learning rate is 0.94. Approximately how long will it take for the seventh unit to be assembled? The number of hours needed...
-
Dwight is an elementary school teacher who also raises pigs for supplemental income. He is trying to decide what to feed his pigs. He is considering using a combination of pig feeds available from...
-
a. Formulate and solve a binary integer programming problem to maximize the total number of kitchen sets (and thus the number of customer orders) Furniture City stocks in the local warehouse. Assume...
-
a. Given the bids, you need to assign one senior scientist to each of the five projects to maximize the preferences of the scientists. What are the assignments? b. Dr. Rollins is being courted by...
-
Why is the bar chart not an adequate planning and scheduling tool?
-
Since the bar chart is ineffective as a planning and scheduling tool, why is it still widely used in the construction industry?
-
For the CPM Calculation Exercise found on the companion website, determine the ES, EF, LS, LF, FF, and TF for each activity. Identify the activities through which the critical path runs. How many...
Study smarter with the SolutionInn App