Written by Brandon C. Kesselly (@bckesso) — August 2, 2017

This piece in no way represents the views of Rising Young Minds as a publication or otherwise. All views and suggestions presented are products of the operating author.

Photo courtesy of Flickr.

For centuries, algorithms were created to solve problems in mathematics, economics, and eventually, computer science. Despite the association with those fields, however, algorithms are actually extremely common. In fact, we use them in nearly everything we do.

Merriam-Webster defines an algorithm as “a step-by-step procedure for solving a problem or accomplishing some end.” This includes tying our shoes, making coffee or tea, even brushing our teeth. This also ties into how we approach social interactions, such as making friends, interviewing for jobs, or dating. Today, I wish to focus on the third item in that list.

If we view them as “problems” to be solved, dating and relationships can be tackled with algorithms. I believe the two can be described in terms of the “stable roommate” and “knapsack” problems respectively — both of which have existing algorithms with optimal solutions.

The former involves people ranking each other, making “proposals,” and accepting or rejecting them. The latter involves packing as much as you can into an imaginary “knapsack” without going over the weight limit. Below are examples of how these two common “problems” represent social interactions which, in turn, have algorithms we tend to follow as human beings.

Getting a Date: The Stable Roommate Problem

In the “stable roommate problem”, a single set of people are attempting to find someone with whom to share a living space. The goal of this problem is to find if a “stable matching” exists, one in which everyone is paired and no two parties prefer one another to their current match. (Basically, everyone’s matched, but also out of better options).

Irving’s algorithm is a common solution to this problem. In this algorithm, the prospective roommates rank one another in a preference list, and proceed to ask each other if they would like to be roommates. If someone has not yet been asked, they accept and hold onto the proposal. If they have, they reject the proposal of the lower-ranked person, and both are removed from each other’s list. (Watch this video for the full breakdown).

Ranking table for the stable matching problem.

For the above example, the algorithm would start as follows:

Alicia asks Bobbi, who holds her proposal

Bobbi asks Erin, who holds her proposal

Chris asks Bobbi, who holds his proposal and rejects Alicia’s.

Alicia asks David, who holds her proposal.

David asks Chris, who holds his proposal

Erin asks Bobbi, who accepts her proposal and rejects Chris’s.

Chris asks Felix, who holds his proposal

Felix asks Alicia, who holds his proposal

In the interest of time, I’ll cut to the chase: Alicia and Felix, Bobbi and Erin, and Chris and David all end up together by the end of the algorithm.

The stable roommate problem and Irving’s algorithm represent our dating culture. The preference lists represent our personal attractions; the proposals, asking someone out on a date (without an immediate answer); and a “stable matching” only exists if everyone succeeds in finding a date. Of course, that’s only the first step. The outcome of this date affects the possibility of more in the future, and, in turn, an eventual relationship.

Building Relationships: The 0–1 Knapsack Problem

Photo courtesy of Wikimedia Commons.

For the “knapsack problem,” the aforementioned knapsack has a set weight. There is also a set of items each with their own weights and assigned values. The goal is to maximize the value of the items within the knapsack without going over capacity. (This video covers the full breakdown.)

This problem has a few algorithms, but dynamic programming is a common solution. The dynamic programming approach usually involves breaking the problem into subproblems in order to assess the various combinations of items in the knapsack; the values and weights are stored in a table over time. By the end, there is a matrix of values that will visually show the optimal solution.

Let’s take the above example:

The set of items I = {a, b, c, d, e}.

The set of item weights W = {12, 2, 1, 4, 1}.

The set of item values V = {4, 2, 1, 10, 2}

The knapsack’s total capacity C = 15

Using the dynamic programming algorithm, we would learn that the optimal combination is the subset {b,c,d,e}, with a total weight of 8 and a value of 15. The beauty of this approach is that it allows you to see what your options are, clearly displaying the best combination of items to go into the knapsack. The knapsack may not always be filled to capacity, but you will always get the best value possible.

To me, the knapsack represents our ideal partner. The items are the traits, qualities, and values we look for in a partner; both parties have their own knapsack. Upon dating and getting to know one another, a third, shared knapsack is built. That shared knapsack represents the actual relationship.

Let’s take Bobbi and Erin from the above example. Perhaps Bobbi is a hiker, a rock climber, loves reading, and enjoys electronic dance music. She is also active in her church and community, being a frequent volunteer at local women’s shelters and soup kitchens. She feels like she wants someone who shares her interests, but is always willing to keep an open mind.

In turn, Erin is a jogger, a hip-hop enthusiast, frequently goes clubbing, enjoys stand-up comedy, and goes to church twice a month. She also keeps up with the news and is politically active, having previously worked for a local campaign. She feels that opposites attract, and while she wouldn’t mind dating someone with similar interests, she doesn’t want to essentially date herself.

While the two differ in their interests and daily activities, they both seem to value religion, an active lifestyle, and some form of political engagement. These would go in their shared knapsack and as time goes on, they would both discover what they truly valued and wanted out of a relationship. That would determine whether they continue their relationship, and in what capacity.

In a world where dating apps reign supreme, we’ve become increasingly lenient upon technology to implement algorithms for us to find partners — long-term or otherwise. We tend to overlook the fact that we already do the same things that Tinder or Bumble seemingly consolidate. No matter how you do it, though, we all follow algorithms every day — and dating is no different.

Want to keep up with Rising Young Minds? Like us on Facebook or Follow us on Twitter!