Problem Solving with Programming (Part 2)

October 16, 2019

Into a Forest of Suggestions

When you are making something, you wonder, will this help solve the problem? So you ask other people for their suggestions and their thoughts.

Old School Tech vs New Tech

record player and drone

I have a friend who is never afraid to tell me his opinions, even if they are in total disagreement with mine. I think it’s good to have a variety of opinions, so I welcomed his opinion.

Our conversation was an interesting one. He asked me why I had opted to go so “old school” with the solution to finding missing pets. He suggested that I use drones and artificial intelligence to find pets. He said, “We’re going to have self-driving automobiles in the future. Why don’t you have 10 drones with artificial intelligence fly around, looking for the pet?”

I said that while that may work, the current technology that people readily have to work with is their smartphone, their car, their minds, and other people. So when someone loses their pet, their first instinct is either randomly go searching for their pet or search in nearby places they’ve taken their pets to. They don’t have $400 for renting a group of drones to go looking for their lost pet. I’m not against using drones or artificial intelligence to find a missing pet, but the solution that I’m working on is one that I think augments how people currently look for missing pets.

I had asked for suggestions on how to improve the app through an online survey. People gave me good suggestions. People suggested that I have a bulletin or show on the map where they put up flyers. Their suggestions were in line with how people have searched for pets in the past and how they currently search for them today. What has worked in the past: plastering the neighborhood with flyers, searching in your neighborhood and nearby neighborhoods, and going to the animal shelters. These are not radically sophisticated tech, but they work.

I will say though, there is an app called “Finding Rover”, which uses artificial intelligence to help you find your pet at shelters. You submit a photo of your pet through the app. Using facial recognition software, it will search databases at pet shelters looking for your pet. I think it’s a great and ingenious example of using AI technology to solve a problem.

Money and Tech Doesn't Solve Everything

If you throw enough money at a problem, yes, you are more likely to solve a problem. But even money and technology have their limits. One instance comes to mind. A group of Thai boys and their teacher who played soccer were trapped in a cave because water had filled the cave. The boys were at least a mile deep into this cave.

There were many suggested solutions in trying to rescue the boys from the cave. Among the suggested solutions were “drilling down into the cave from above (difficult to do since no one has a very accurate map of the inside), and trying to find a back entrance (nearly impossible given the dense vegetation in the jungle outside of the cave)," [said Emma Stefansky from Vanity Fair]. Elon Musk sent a group of engineers that built a small submarine. All of these solutions were rejected. The solution that was used was to have a group of very specialized, trained scuba divers get them out with the support of Navy Seals. Many of these scuba divers were hobbyist divers, who regularly dived in very extreme conditions. So in the end, the crucial factor wasn’t necessarily money or engineering technology, but human skill and knowledge that got those boys out (which I guess one could argue is a form of technology.)

Diagram of scuba divers rescuing Thai soccer player

The Challenges of Finding a Missing Pet

How do you look for something that is constantly moving? How do you hit a moving target? As one survey taker pointed out, there is an aspect of time one must account for. Just because you searched for an object in a particular time at a particular place, it doesn't mean you can rule out searching there the next day. Another survey taker suggested listing the frequency of how often searches occur in a particular place.

I was thinking how this would translate to my app. One way to show frequency is through a heat map. Also, it would be nice to filter or show searches within a particular time frame. Or another way to account for time is to have different search sessions. You could show yesterday's session. And then today, you start with a clean slate and track only today’s path.

Things I've Learned So Far

You'll go through a lot of possible solutions before you find what you’re looking for. Here are some examples of where I started out with one solution and had to change course.

• Switching from interviewing people to using a survey

My initial plan to interview people over Google Hangouts did not work out. When that occurred, I opted to change course and created an online survey for people to fill out. This worked out much better and was more convenient for everyone. (Thanks to those that filled out surveys and gave excellent advice. And thanks to Ray for introducing me to several people at Project Night, some of whom eventually filled out surveys.) If this online survey didn’t work out, my next step was to go to a dog park and try to find people who’d lost pets. Well thankfully, I didn’t have to do that because people filled out the survey.

• Switching from Google Cloud to AWS

In order to practice creating a Django app and deploying it, I chose to create my personal website as a Django site with a Postgres database. Initially, I hosted this site on Google Cloud. Google Cloud had offered a trial run which gave you $300 credit or one year worth of cloud services for free (whichever ran out faster). After one month of hosting, I’d used up about $100 worth of credit, which really surprised me. Part of the reason was that unless you specify in the configuration file that you want only one instance of a server deployed, the number of instances that gets deployed by default is two in Google Cloud’s flexible environment. I hadn’t realized this until later on that this was happening.

(You can read more about another person’s experience whose bill with Google Cloud came out to $500 for 1.5 months here. In my case, each time I used “gcloud app deploy” to deploy, it did not create totally new instances as he states there. But I did experience, as I said before, two instances being deployed by default the first time I deployed.) In any case, I have decided to migrate to AWS, which offers a one free year trial. So I started out at one hosting company and had to switch due to costs.

• PubNub vs Rolling out my own solution

My mentor Austin had suggested that I look at HERE Technologies, Google Maps Platform, Mapbox, and Open Street Map for the map portion of my app. After looking at those options, the two strongest contenders were Google Maps Platform and Mapbox. I chose to go with Mapbox because it was cheaper than Google Maps Platform. Mapbox would provide the map visualization for my project.

I found a company called PubNub, which is a Data Stream Network and real-time infrastructure-as-a-service company. Using PubNub’s product, I’d be able to broadcast the coordinates from a user’s browser to PubNub’s servers and also receive data from its servers back in real time. In other words, using Mapbox and PubNub together, it would be able to track and show a user’s path on a map in real time—just the thing I needed.

I started out by working with two of PubNub's tutorials: Realtime Google Maps Geolocation Tracking with JavaScript (1/4) and Realtime Google Maps Geolocation Tracking with JavaScript (2/4)

These were the most up-to-date tutorials of real-time tracking on a map using PubNub, but it dealt with Google Maps Platform and PubNub. Since I needed Mapbox and PubNub to work together, I converted those tutorials to work with Mapbox. After getting it to work with Mapbox, I read the terms and pricing policy for PubNub. It seemed that the pricing costs were going to be high in the long run to use PubNub.

So I decided to change course. I will be building my own solution using Mapbox, Django, Postgres, PostGIS, and probably websockets.

Here’s some preliminary pseudocode I wrote. It gets GPS coordinates from the user and displays it on a map:

Closing Thoughts

I’m surprised at the variety of things I’ve had to do, such as researching software solutions and configuring servers. Software is not created in a vacuum. Factors such as whether this software would be practical and useful to someone will be important. Limiting factors such as monetary costs in server hosting costs (e.g. Google Cloud) and other software product costs (e.g. PubNub) come into play.

small potted plant

Throughout all of this, the most important lessons I've learned from my mentor Austin has been about patience and confidence. Austin has not worked with geolocation data before. And as I was trying to configure the web server Gunicorn on AWS, I learned he hadn’t worked with Gunicorn before. I have not worked with geolocation data or Gunicorn either. We both lacked experience and knowledge in these areas. But I could tell that this didn’t faze him. With patience, you can keep going until you can find a solution. Confidence is the belief that you will eventually find a solution.

Read the next post:
Problem Solving with Programming (Part 3)