System Init
0%
LOADING_ASSETSv2.0.26
blogs/gradient-descent-dalam-mencari-tempat-nongkrong
//Khay
Baca Bahasa Indonesia

Gradient Descent in Finding a Hangout Spot

MathCoffeeAlgorithm

Have you ever driven around for hours looking for a place to hang out, from downtown all the way up the hills, just to end up back at the cheap coffee stand near your dorm?

I see my friends do this all the time. They have this huge list of aesthetic cafes in their head, but when it's time to execute, they get caught in an infinite loop of confusion. Then they complain about being tired. Well no shit you are tired, you are trying to find the absolute optimum in a search space that changes every hour due to traffic and weather.

This is a classic optimization problem. If you ever took calculus or at least heard of machine learning, you know about Gradient Descent. The idea of this algorithm is super simple: you are at the top of a mountain, you want to go down to the valley (the lowest point aka your minimum cost or disappointment), but it is pitch black. What do you do? You feel the ground around you, find the steepest downward slope, and take a small step in that direction.

So why is it so hard for people to apply this when looking for a cafe?

Because the human brain loves searching for the global minimum. You want the best tasting coffee, the cheapest price, the fastest wifi, power outlets at every table, and a parking lot the size of an airport. Your expectations are way too high bro. The more constraints you add, the harder it is to find a feasible region. In the end you get a NullPointerException because a place like that only exists in your imagination.

Here is how you apply gradient descent to find a hangout spot:

First, random initialization. This is important. Do not spend too much time thinking in your room. Just pick a random direction, like whatever let us just drive towards the north side first.

Second, calculate the gradient of disappointment. While on the road, evaluate your surroundings. Is the traffic bad? If it is gridlocked, it means your cost function is going up, you need to change direction to a quieter street.

Third, update your position with an appropriate learning rate. This is crucial. If your learning rate is too big, you will overshoot. For example, you see a cafe that is slightly crowded, you immediately bail and drive to another city. That is too far man. You are just wasting gas and time. But if your learning rate is too small, you will get stuck looking for parking in one narrow alley for half an hour. Move a bit, evaluate, move again.

Fourth, accept the local minimum. This is the hardest part for perfectionists. Once you find a cafe where the coffee is decent, there is an empty outlet, and the wifi is fast enough to open stackoverflow, just stop there. Do not think that maybe there is a better one up ahead. Local minimum is perfectly fine. It is better than chasing the global minimum but ending up dehydrated in the middle of a traffic jam.

One thing that often makes this algorithm fail in group settings is the number of parameters. If you are looking for a cafe alone, it is easy, only one neural network is working. Try doing it with five people. Person A wants matcha, person B wants satay, person C wants live music. This is called a multi-objective optimization problem and I swear trying to solve it will make your hair fall out. That is why I prefer hanging out alone or with a maximum of three people. Reduce the dimensions of the problem so your brain computation is not so heavy.

In conclusion, stop romanticizing the process of looking for a hangout spot with the label of a spontaneous adventure. That is just an alibi for bad planning. Use calculus, your life will be easier.