Parking Lot Search Algorithm
by aurahack
A friend of mine posted this on her Facebook page as a note. It's kind of really great, so much so that I feel I had to share it with the public world. So here: Parking Lot Search Algorithm I have spent a fair amount of time this semester thinking about the optimization of search algorithms, as well as a fair amount of time traveling to and from campus. As I frequently get insufficient sleep, I...
A friend of mine posted this on her Facebook page as a note. It's kind of really great, so much so that I feel I had to share it with the public world. So here:
Parking Lot Search Algorithm
I have spent a fair amount of time this semester thinking about the optimization of search algorithms, as well as a fair amount of time traveling to and from campus. As I frequently get insufficient sleep, I find myself rushing to class and have to minimize the amount of time spent searching for a parking spot and, ultimately, getting there on time.
Located north of science 4 are a number of parallel arrays of object "parking spot", which contains a boolean value "empty". The search is completed once I reach an object in the array with empty = true. Due to hardware limitations, performing the array search too quickly can cause the user to crash, so it is better to optimize which arrays are searched by performing car.searchsafe() and not car.searchunsafe(). car.searchunsafe() has improved best case running time but has an edge case which can cause huge amounts of slowdown if a parking spot object contains a car object of type university police.
The arrays are contained within data servers called lots, with some lots being more proximal to my destination than others. This seems inefficient to me due to added time spent changing lots, but different lots appear to have different access privileges for users, which is likely the reason for this design. The complex nature of the search algorithm is due to the fact that many users perform it concurrently and my search completion time can increase depending on the number of users performing search and the number of completed searches, as these will change array values. Because of this, algorithm complexity can become even worse than O(n), though this is a rare occurrance. The trick is in knowing where in this unsorted array to begin the search - if many users are performing search in a lot (especially more proximal lots), I will assume that that lot has no or very few parking space objects with empty = true values and I will start my search at a more distal lot. This most frequently occurs during peak user hours of 11:00am-2:00pm.
In ethological animals models of food searching, animals will often search high-risk areas if the potential reward is high and necessary for survival. However, death is a binary quality and being late for class has levels of magnitude, so I will often only search high-risk/high-reward proximal lots when I am not already late. Travel time via bipedal movement will only decrease at a logarithmic rate with increasing linear time spent performing array searches. The competitive nature of the parking spot search algorithm increases amygdala activity in some users - I prefer a dove strategy when challenged by another user, as I do not have the money to replace slashed tires.
There are other extraneous factors to consider when performing an optimized search - Binghamton is renowned for being an undesirable location to spend extended time outside of buildings. The amount of time I will spend searching the more proximal arrays maintains an inverse relationship with the external temperature.
Uhm, I am a nerd and just spent 30 minutes writing this instead of finishing my data structures project :< bai