It’s often hard to motivate ourselves to learn new tech – whether a new coding language or algorithm – when it’s not essential to our job. Tech not only moves fast, but it’s easy to get overwhelmed by the plethora of documentation, tutorials, and videos. But what if your motivation was to hack your own life? Mey Beisaron did just that, coding a genetic algorithm from scratch and using it to generate a weekly schedule and to create a smart diet planner.
Mey is a Backend Developer at Appsflyer and also a mentor for helping junior devs land their first job, as well as support women to become conference speakers. I spoke to her about her life hacking algorithm aspiring speakers, aspiring women speakers, or also I’m also a mentor for junior developers to land their first job. I spoke to her prior to her presentation at Codemotion’s online conference: The Spanish edition.
The motivation for the life hacking algorithm
According to Mey, using her own life was a great way to teach herself about genetic algorithms. She notes:
“I figured out that the best way to focus on the algorithm is by actually taking a very simple problem, because if you take a very complicated problem, then you have two things that you need to focus on: you need to understand the solution to the problem, and you need to understand the problem itself. And the whole definition of the problem may take some time until you get to actually implement the solution and the algorithm. So by taking on simple problems, like arranging your timetable, or arranging your diet, that enabled me to focus on the algorithm.”
Specifically, Mey focused on the problem of nutrition: “ You have a few things in your fridge, and they have nutritional values. And what I wanted was to know how much I should eat of each one of them per day in order to maintain my diet. And so this meant that I answered to the algorithm, the products that I have in the fridge. And then I also insert the constraints, which are like how many carbs and how much fat and how much protein I want to eat per day. And then I got results detailing the amounts that I should eat of each product per day.
What is a genetic algorithm?
A genetic algorithm is a heuristic search method used in artificial intelligence and computing. As we discussed in a previous article, genetic algorithms are used for finding optimized solutions to search for problems based on the theory of natural selection and evolutionary biology. Mey asserts:
“What I love about genetic algorithms is that it’s easy to explain, but not that easy to implement. There are a few steps that need to be taken. And it means that you have a set of solutions that you take, and each time you have a function that checks if these sets of solutions are good enough. To determine if the solution is good enough, you establish a pre-determined grade. And then, if these solutions are not good enough, then you shuffle the solutions between themselves and you create new solutions out of the existing ones.
It’s like evolutionary computation in that it takes the principle of natural selection to create a new solution out of what already existed. I love the idea of taking stuff from nature and implementing it. It’s not the first or only algorithm that does this, it was just the easiest one for me to start with.”
What tools did you use?
Mey didn’t use any specific tools or libraries, “because I implemented everything from scratch. So it involved a lot of reading. And there’s a lot of material on that topic out there. So it was fairly easy to find information on how to do things.”
How to begin learning about genetic algorithms?
Mey asserts that this is a great project for everyone, especially beginners.
“ It doesn’t matter your level of expertise. Even If you’ve never done anything with algorithms, it’s really easy to understand the concept. And once you understand a concept, you can start asking yourself questions as to how you would implement it.
Just like if I’ll tell you that there is a PacMan game, you understand that there is the Pac Ma the eats the pellets, So then, if you know that, then you can start asking questions that will help you implement the algorithm. So you should start by reading about this algorithm, understanding the genetic algorithm, and try to understand the different steps of the algorithm, and the purpose of each step. From there it becomes fairly easy to go and start implementing, beginning with trial and error.”
Mey notes that genetic algorithms are also used in gaming, particularly with the evolution of game characters. “So using genetic algorithm in games, it means that you try to stretch the personal attributes and capabilities of a game character. Imagine a player in a game that starts to do the things that it’s supposed to do in the game. And you see how this player depending on whether it’s good or not can evolve into a whole different player until it gets to the point where it’s a very good fit. You didn’t even have to do anything, you just sit there and you watch how your player is getting better and better at doing whatever it is that you wanted to do in the game. I don’t know why it’s fun, but it’s really fun.”
Mey’s talk will include code examples and she’ll go through the different stages of the algorithm and understand how they affect the algorithm’s solutions. You’ll discover a new way to solve your everyday problems.