Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def assign_inspectors(bridge_data: List[list], inspectors: List[List[float]], max_bridges: int) -> List[List[int]]: Return a list of bridge IDs to be assigned to each inspector in inspectors. inspectors is

def assign_inspectors(bridge_data: List[list], inspectors: List[List[float]],

max_bridges: int) -> List[List[int]]: """Return a list of bridge IDs to be assigned to each inspector in inspectors. inspectors is a list containing (latitude, longitude) pairs representing each inspector's location. At most max_bridges bridges should be assigned to an inspector, and each bridge should only be assigned once (to the first inspector that can inspect that bridge). See the "Assigning Inspectors" section of the handout for more details. >>> assign_inspectors(THREE_BRIDGES, [[43.10, -80.15]], 1) [[1]] >>> assign_inspectors(THREE_BRIDGES, [[43.10, -80.15]], 2) [[1, 2]] >>> assign_inspectors(THREE_BRIDGES, [[43.10, -80.15]], 3) [[1, 2]] >>> assign_inspectors(THREE_BRIDGES, [[43.20, -80.35], [43.10, -80.15]], 1) [[1], [2]] >>> assign_inspectors(THREE_BRIDGES, [[43.20, -80.35], [43.10, -80.15]], 2) [[1, 2], []] >>> assign_inspectors(THREE_BRIDGES, [[43.20, -80.35], [45.0368, -81.34]], 2) [[1, 2], [3]] >>> assign_inspectors(THREE_BRIDGES, [[38.691, -80.85], [43.20, -80.35]], 2) [[], [1, 2]] """ #

Assigning Inspectors (function assign_inspectors)

Bridge condition indexes (BCI) represent the condition of a bridge on a past inspection, and we use the most recent BCI to prioritize certain bridges. There are three levels of priorities, with their upper limits represented by the constants HIGH_PRIORITY_BCI, MEDIUM_PRIORITY_BCI, LOW_PRIORITY_BCI, constrained by HIGH_PRIORITY_BCI < MEDIUM_PRIORITY_BCI < LOW_PRIORITY_BCI.

For example, if HIGH_PRIORITY_BCI is 60, then all bridges with their most recent BCI less than or equal to 60 are considered 'high priority'. Similarly, ifMEDIUM_PRIORITY_BCI is 70, then all bridges with a BCI less than or equal to 70 (but > 60) are considered 'medium priority'.

When assigning bridges to inspectors, we want to prioritize nearby high priority bridges within a large radius of the inspector over medium priority bridges that are closer, and both of those are prioritized over low priority bridges in an even smaller radius.

The radiuses are specified by the constants HIGH_PRIORITY_RADIUS, MEDIUM_PRIORITY_RADIUS, and LOW_PRIORITY_RADIUS.

You are told the maximum number of bridges to assign per inspector. The way we want to assign bridges to inspectors is as follows:

High priority bridges with a distance <= HIGH_PRIORITY_RADIUS from the inspector.

If (1) assigned fewer than the maximum number of bridges, then we go on to assign medium priority bridges with a distance <= MEDIUM_PRIORITY_RADIUS from the inspector.

If (1) and (2) still assigned fewer than the given maximum number of bridges, then we go on to assign low priority bridges with a distance <= LOW_PRIORITY_RADIUS from the inspector.

One inspector at a time, we assign the maximum number of bridges to each inspector (or fewer than the maxiumum number of bridges, if all bridges have already been assigned). Inspectors should be assigned bridges based on the order they appear in the list (e.g., the first inspector in the list should be assigned up to the maximum number of bridges first, the second inspector should be assigned up to the maximum number of bridges next, and so on).

Bridges are assigned to an inspector using as many bridges that fulfill (1) as possible, followed by (2), and then (3) if there are still fewer than the maximum number of bridges assigned to that inspector. If there are multiple bridges with the same priority and radius, we choose the bridge with the lowest ID (e.g., if there are two low priority bridges with IDs 3 and 4, we would assign the bridge with ID 3 first). Each bridge should be assigned to at most one inspector.

You may want to use the find_bridges_in_radius and get_bridges_with_bci_below functions to help you with assigning inspectors.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions