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...
-
On January 1, 2016, Uncle Company purchased 80 percent of Nephew Company's capital stock for $500,000 in cash and other assets. Nephew had a book value of $600,000, and the 20 percent noncontrolling...
-
How are financial strategy and financial plans linked together?
-
Make a list of the advantages and disadvantages of using and not using a project management software tool for this phase of APF. Discuss your findings. Does either approach win out over the other? In...
-
Infosys Technologies, introduced in Chapter 1, regularly provides investors with a performance measure called economic value-added (EVA). Originally pioneered by GE, EVA measures the profitability of...
-
Ross Company, a manufacturer of pharmaceuticals, has pretax ordinary income of $502,000 and has just sold an asset purchased two years with a realized capital gain of $15,000. Using this table
-
Here is a simplified diagram of a RF front end (power and control signals are not shown). 1. What kind of a system is it? What are the RF measurements you would use to characterize it and compare it...
-
Required information [The following information applies to the questions displayed below.] Volunteer Corporation reported taxable income of $515,000 from operations this year. The company paid...
-
Explain how cryptocurrency mining works.
-
Describe the principles used in SysTrust to evaluate a system as reliable.
-
What problems does blockchain sharding solve?
-
What are the top five blockchain applications or types of use cases?
-
What are the top five accounting organizations successfully leveraging blockchain technology and how are they using it?
-
3 2 -2-1 1 2 3 4 -2 -3 Suppose that f(x) = ln(x + 1) + 1. The graph of the function g(x) is shown above (in bl together with its tangent line at x = 0 (in red). If h(x) = f(x)g(x), determine the...
-
Suppose the S&P 500 futures price is 1000, = 30%, r = 5%, = 5%, T = 1, and n = 3. a. What are the prices of European calls and puts for K = $1000? Why do you find the prices to be equal? b. What...
-
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...
-
On December 31, 20x7, the stockholders equity section of Tsang Companys balance sheet appeared as follows: The following are selected transactions involving stockholders equity in 20x8: On January 4,...
-
Recording Purchase and Sales Transactions} Raymond Company and Geeslin Company both use a perpetual inventory system. The following transactions occurred during the month of January: Jan. 1 Raymond...
-
Inventory Costing Methods} Refer to the information for Tyler Company above and assume the company uses a perpetual inventory system. \section*{Required:} Calculate ending inventory and cost of goods...
Study smarter with the SolutionInn App