# Intractable Problems — Part One: Set Problems

My professor and advisor Dr. Alice McRae provided a list of intractable problems for us to ponder in our genetic algorithms class, and I thought I would expand on some of them here for reference. All of these problems are intractable, which means that they are very, very difficult to solve precisely with a computer.

Most of the problems on this list are what is known as NP-Complete problems. If the complexity classes P and NP are not equal (as is widely believed by many researchers, but not proven), then NP-Complete problems cannot be solved by a computer in a reasonable time frame. In theory, with an infinite amount of time we could produce answers to these problems but time and computing power is finite, no matter how many technological advances we make.

We have seen some of these difficult problems before in previous posts: Genetic Algorithms for Ramsey Theory and The Travelling Santa Problem, as well as Introduction to Genetic Algorithms all have good examples of these types of problems.

I will be presenting these problems in multiple parts, with my comments and references on each one.

Part One — Set Problems

Maximum 3-Dimensional Matching — given a set $S$ of ordered triples of the form $(x,y,z)$, find the largest possible subset of the triples, such that no two elements in the triple share the same $x$, $y$, or $z$ coordinate.

Here is a small example: Consider the set $\{(1,4,5),(3,4,9),(6,7,8),(1,2,5)\}$. We need to find the largest subset of these we can, and the $x,y,z$ values cannot be repeated. In this example, the set $\{(3,4,9),(6,7,8),(1,2,5)\}$ would be a solution. It contains 3 triples and none of the numbers are repeated. As you can imagine, once the sets gets larger, this problem becomes much more difficult.

In layman’s terms, consider a group of boys, girls, and pets. We want to make happy “triplets” of girls, boys, and pets, but no girl, boy or pet can be in more than one group. What is the best way to match these people and pets up so that we have the largest number of groups?

Class: 3-Dimensional Matching (finding any subset that satisfies the conditions) is NP-Complete. The optimization problem (finding the largest subset) is NP-Hard. [1]

References:

More NP-Completeness Results (pdf) lecture notes from CMU, good explanation of 3DM as well as some other problems, proof of the class of 3DM.

NP-Complete Problems (pdf, pg 267)

$============================$

Subset Sum/Subset Product — given a set $S$ of integers and a goal sum/product $P$, find a subset of $S$ that sums/multiplies as close as possible to the goal of $P$.

This one doesn’t sound as hard, but at larger quantities, this can become very difficult.

Example: Consider the set $S = \{ n |1\leq n \leq 100 \}$ and a goal sum $G = 531$. Now we need to find a set of numbers between 1 and 100 that we can add together to get 531.

A practical application of this: Say you’re a kid and your parents gave you $10 of allowance for the week. Naturally, you want to get as much good out of that$10 as you can. What is the best combination of things you can buy to add up to as close to $10 all together? Class: Subset sum and subset product are NP-Complete. Proof can be found at [2] References: Subset Sum NP-Completeness (pdf) Scroll down a bit to see the proof that subset sum is in NP-Complete Dynamic Programming Subset Sum — A description of a dynamic programming technique for this problem SubsetSum@Home — A distributed crowdsourced BOINC-type initiative to solve subset sum problems An Improved Low-Desnity Subset Sum Algorithm — a paper concerning algorithms to solve this problem $============================$ Minimum Set Covering — given a set $S$ and a collection $C$ of subsets over $S$, find the fewest number of subsets of $C$ such that all elements of $S$ are represented. Okay so lets break this down. We have a set $S$, lets say for example $S=\{1,2,3,4,5\}$. Now we have a collection $C$ of subsets over $S$. For our example, $C = \{\{1\},\{2,5\},\{3,4\},\{2,3,4\},\{5\}\}$. In this case, the smallest collection we can make that includes all the elements in $S$ is $\{\{1\},\{2,3,4\},\{5\}\}$ which contains 3 elements. Practical example: You’re a kid again, and looking at a group of video games that are on sale. They are all in combo packs, however. How can you get all the games you want and spend as little money as possible? In other words, what is the smallest amount of combo packs you need to buy in order to get all of the games you want? Class: the decision problem (does this set contain all the elements we’re looking for?) is NP-Complete. The optimization problem (is this set the smallest set we can make?) is NP-Hard. See [3]. References: A Probabilistic Heuristic for a Computationally Difficult Set Covering Problem – (pdf) Journal article on this topic detailing a heuristic for finding set coverings A Genetic Algorithm for the Set Covering Problem – (pdf) Journal article about a genetic programming approach to set cover A Greedy Heuristic for the Set-Covering Problem – (pdf) Yet another approach Set Cover Problem — Wikipedia An Example: Set Cover – (pdf) Scroll down to see a proof of set cover in NP-Complete $============================$ These are only a few intractable set problems, but there are many more variations of these out there. Stay tuned for the next segment in this series, problems about Data Storage (Bin Packing and Knapsack). Advertisements # Beeminder and Self-Tracking: Five Months In So back in January, I started using a little service called Beeminder to track my goals and encourage me to do more things I’ve been putting off. I also experimented with several other Quantified Self tools, and learned a lot about how simply tracking what we do day to day can open our eyes to things we need to improve at and things we perhaps do too much of (for me, its instant messaging with my friends). It’s been five months since I started this journey of learning about myself, and I thought I’d give an update about how its been going. My findings: I couldn’t be happier with the results. I know its easy to get started on a new diet or workout program and feel all motivated and enthusiastic at first. That’s how New Year’s resolutions start, after all. We get all excited about changing our lives and then a few days or weeks later, its back to the same old same old. When I started tracking myself and using Beeminder for my goals, I was afraid a similar thing would happen. It’s just a fad, I thought. My newest obsession. It will subside in a few weeks. I’m happy to say that five months later, I am still going strong and I have made a lot of progress. Wait, what is all this Beeminder/Quantified Self stuff? What are you talking about? Glad you asked. I did a post on all this stuff a few months ago called Quantifying the Self and discussed the nuts and bolts of all this, but here’s a quick review: Beeminder is a web service that allows you to track your goals by plotting progress points on a graph each day. You try to stay on “the yellow brick road” (that is, the goal you set for yourself — say, doing 20 pushups a day) and if you fall off the road, in order to recommit and get back on the road you pledge money (you’re basically “betting” that you will be able to keep up with your goal). If you fall off the road again, you pay up. Here’s a picture: As you can see, the data points are staying above the yellow line, meaning I am on track for my goal. This screenshot was taken back in February, after I had been tracking my reading habits for only a month. Let’s take a look at my graph now: There are a lot more data points, and I’ve racked up over 2000 minutes read (that’s 9 books) since January! There are a few flat parts (in March I did a lot of traveling and didn’t find a lot of time to read), and because of this I actually derailed once. But I pledged my$5 and so far I’ve been doing well once again. I really enjoy seeing the graph and the data points grow, and the Android App has been absolutely essential to my success. It doesn’t get much easier than entering in a few numbers into the app every day.

Of course, this is just my most successful graph. I have others that I have utterly failed at, like flossing my teeth:

This one…has a lot more flatlining. A product of good old akrasia. As you can see, I’ve derailed on this one and have been for quite some time…I think I’m about ready to pony up the cash and try again though (for real this time!) Some people have told me that paying the service money when you fail your goals seems cruel or manipulative on their part, but I don’t see it that way at all. This is something want to do, and if I don’t follow through with it, then there has to be some sort of pain associated with that to deter me from failing again. And besides, this company has done so much for me and I use the service so much I am happy to give them a few bucks here and there. The staff is great and responsive and the website is always getting updates. They deserve it.

In addition, I’ve found from my pedometer app on my phone that I’ve walked over 600,000 steps this year! That’s over 300 miles. The day to day walking may not seem like much, but adding it all up like that certainly has a big impact on me and motivates me to keep going and do more.

My most recent project involves taming the beast that is my email inbox. I’ll admit it: I’m an email hoarder. While other people keep their inboxes neat, tidy, and organized, I have a giant deluge of thousands of emails just sitting there, taking up space and making it impossible to find anything. Usually, if I don’t find an email interesting (such as an advertisement or a newsletter) I won’t even click on it. Thus, there are hundreds of unread emails as well. This is a product of my laziness over time, and it just keeps getting worse. I’ve decided its finally time to do something about it. I set up a Beeminder goal to track my inbox size, and I’m going to either file away or delete 500 emails per week until my inbox reaches the fabled Inbox Zero. Once I reach that milestone, the challenge will be to keep it there, and keep my email inbox manageable and not overflowing like it was before. This leads to less stress, easier location of important emails, and if something is in the inbox, it means I need to deal with it right away. I feel like this will give great gains in productivity and overall happiness.

And just in the interest of transparency, my goals are all publicly viewable on my beeminder page, and that makes me not accountable to just one person, but the internet at large when you display your successes and failures in this way. There’s something strangely motivational about that.

What have I learned?

As for some of the other services, they didn’t stick quite as well. But the trial period of testing out these new things definitely taught me a lot about how my mind works and how we can battle this beast of distraction and bad judgement that rears its ugly head daily. Humans aren’t necessarily rational creatures by nature, but we can learn what mistakes we make and how our minds try to trick us. Then we can trick it right back. I just bought the book Thinking, Fast and Slow by Daniel Kahneman, and it discusses at length these “cognitive biases” and ways to get around them. The result? A happier, healthier, more productive life.

Final Thoughts

If you’re curious about what self-tracking can do for you, I urge you to try tracking a simple thing in your life, something you already do, for just a week. It becomes like a game to try to “beat your best score” and its really fulfilling to see your progress over time. I really recommend trying this to anyone that is interested in achieving their goals and improving their life. It’s surely changed mine.

# Introduction to Genetic Algorithms

In response to my previous article about genetic algorithms for Ramsey theory, a few readers asked me to give a bit more of an introduction about genetic algorithms. Here you will find a beginner’s look at what a genetic algorithm is, what it is useful for, and how you can use one in your own work.

What is a genetic algorithm (GA)?

To begin with, let’s talk about what a genetic algorithm is, on its most basic level. The word genetic suggests something to do with biology. If you can reach way back to your high school science classes you might remember the basic genetic process: plants and animals are born, mate with one another, and create new generations. Over time, these generations tend to emphasize certain traits essential to survival while downplaying the weaker (recessive) traits. A genetic algorithm works much the same way. We come up with a population of possible solutions to a problem, “mate” them together, and look at our new solutions to see if they are any better. Over time, we can create solutions that converge to better and better values. This is useful when a problem is too complex to search all possibilities. Below you will see an image describing how a simple GA works.

Crossovers, fitness, mutation, oh my!

Before moving on, it would be useful to define some of the terms used above.

• chromosome:  a proposed “solution” to the problem at hand. This is usually represented by a bitstring, that is to say, a list of 0’s and 1’s. It can also hold any other information that is crucial to our problem.
• population: a collection of these “chromosomes” that we use to combine together and make new generations. The population represents the set of all the ideas that we have about this problem at the moment
• fitness: the fitness of a chromosome is a number representing how good it is. That is, the fitness represents how good this solution is at solving our problem. An example of this is if you were trying to find the shortest route to get somewhere. Fitness for a problem like this would be a number representing the distance it takes for each path you could choose. In the end, you want to find the path with the shortest distance. Ultimately, the fitness function is defined by the programmer, and it can measure whatever you want.
• mutation: mutation is the random entering of new data into the gene pool. Just like in biology, sometimes mutations occur and create things that were never intended. However, sometimes this inadvertent change can be to our advantage if we’re getting stuck. A common example of a mutation is to just change a small part of the chromosome, and move on.
• crossover: the “crossover function” represents the operations that we do in order to “mate” two (or sometimes more) of our chromosomes. There are many different types of crossover techniques, some better for certain situations than others, but at the heart of it a crossover just represents a way to combine the “traits” of two or more chromosomes into a new “baby” chromosome to be inserted into our population. This is the bulk of a genetic algorithms’ work. As the population evolves and new generations of solutions are created, the goal is to keep around the solutions with “good” fitness, and get rid of the chromosomes that aren’t doing so well. The crossover is also user-defined, and tweaking it to optimize results is common.
• termination condition: all good things must come to an end. While we in theory could just leave our algorithm running forever, that would not be very helpful because as I will discuss later in this post, solutions can’t keep getting better forever. In addition, sometimes you won’t actually get to the “best solution” and instead will converge on what’s called a “local minima/maxima”. When this happens, it means you’ve found an “okay” solution, but the population got flooded with many similar chromosomes and couldn’t improve itself after that point. Think of it this way: if everyone in the world were exactly the same, would you expect any different from their children? The termination condition you choose depends on the problem, but some common terminating conditions are:
• a) finding the best solution (ideal)
• b) running a preset number of generations and using that as a cutoff point
• c) quitting after every member of the population falls within a certain similarity range (this means that no new/better solutions are likely to be produced)

But why would I want to do all this?

I know this seems like a pretty complicated process. Why not just use a computer to figure out the real solution instead of dancing around it in this complicated manner? Well, it turns out that’s not always possible…

Enter the Traveling Salesman Problem (TSP). While there are many problems that are still very hard for us to solve with computers, this is one of the best known and most studied. It turns out that using a genetic algorithm is actually a pretty good approach and is much quicker than running an exhaustive search of all paths possible. Remember when I used the example of finding the shortest distance to go somewhere? That’s pretty much what this is. I’ve done a blog post on this before (see here). In the traveling salesman problem, there is a man that needs to visit a list of different cities, but he wants to get there and back as quickly as possible. Therefore, you need to find the shortest route to hit all the cities and return home. This isn’t always as easy as it sounds, and as the number of cities grows, so too does the time it takes to find the right one. Very quickly it becomes implausible to check every possible path, so we use a genetic algorithm to help us weed out the bad ones.

Another example of how we would use a genetic algorithm is for graph theory problems that also have a huge number of possible solutions. You can see how I applied a genetic algorithm to the problem of Ramsey numbers here.

Okay, so how do I use this in my project?

It’s pretty simple. I know it looks complicated, but once you get everything apportioned out correctly it’s not that bad. Things to think about when applying a GA to a hard problem (we will use the Traveling Salesman Problem as an example here):

• First decide what your “chromosomes” will look like. These are the meat of your population, and these are what will be mutated and crossovered in order to create better solutions. For the TSP, we will use a a sequence of numbers denoting what cities to visit and in what order. (For example, “1 5 4 2 3 1” describes a way you could make a circuit through 5 cities).
• Decide on how fitness will be evaluated. This is important because members with better fitness will be the ones that stick around in your population and (hopefully) make your solutions better. In our problem, fitness refers to how far our chosen path takes us. The lower the fitness score, the shorter our travel is. We want to minimize this number with our algorithm.
• Next we need to figure out what our crossover will be. This is very important to consider, because we want something that will take parts of both of our “parents” and combine them together in some way to make a “baby”. For traveling salesman, we can’t just grab some from one parent and some from the other, because we run the risk of duplicates. (we don’t want a path to look like “1 2 2 3 4 1”, city 2 is visited twice and we never get to city 5). Therefore, we have to use more sophisticated methods. I won’t go into them here but if you’re interested check out this wikipedia page for more info on crossover techniques.

What are the downsides?

“Every rose has its thorn,” as they say, and genetic algorithms are no different. What seems like a cure-all has its hindrances as well. As I mentioned before, GAs have a problem of converging too early on a value that’s not quite ideal. Often this takes many repetitions of running the program and fine tuning things such as population size and mutation rate. Sometimes happening upon the “best” solution is a product of randomness. But in a GA, we use this randomness to our advantage as much as we can. Another inherent problem is the fact that we have to program this framework around it. Using a GA is only viable if its an extremely complex problem that cannot be solved more efficiently. For example, using a GA to solve a 5 city TSP would be foolish. We can run through all those possibilities very quickly. On the other hand, bumping that up to 50 or 500 cities proves a much harder challenge.

In addition, using a genetic algorithm means you have to find a type of chromosome, fitness function, population size, and crossover that works for you. Pick the wrong values for these, and the program will behave less than optimally. Experimentation and continually tweaking the parameters of your model is necessary. In some genetic algorithms, the fitness function for even one chromosome can take quite a while to compute. This makes some genetic algorithms very slow to apply.

I hope this has covered the basics of genetic algorithms and interested you in learning more. If you would like to see a project I have done involving GAs you can read A Genetic Algorithm Approach to Ramsey Theory, and for a broader range of discussion about the theory and applications of GAs check out the book An Introduction To Genetic Algorithms by Melanie Mitchell.

Hope you enjoyed this introduction to the wide world of genetic programming; if you have questions or suggestions please leave them in the comments below!

# Kinect Face Tracking — Results: Thesis Update #4

For background, see my three previous posts in this series:

My thesis has been successfully completed and defended now, and I am currently on break for the summer. I thought I would make a post to wrap up some loose ends and talk about some things I didn’t have a chance to talk about before. In my last post, I discussed the significance of animation units to my facial tracking algorithm. Now the way I use these units is pretty simple, but can lead to some complex classifications. The first thing to do is to consider what the desired face would look like. Picture it in the mind’s eye. Say for example we wanted to recognized a surprised face. How would this look? Chances are, when thinking of a surprised face, the mind visualizes raised eyebrows, wide open eyes, and a gaping mouth. The next task (and the bulk of my algorithm) asks: How do we translate these facial movements into the points tracked on our facial mesh?

We use animation units as “wrappers” for sets of points on the face plane. Instead of having to track and check multiple different places on the eyebrows or mouth for example, the animation units allow us to track the movements of those features as a whole. Since the animation unit values lie between -1 and 1, we must assign “bounds” for each expression to where if the user’s features fall within that range, we can assume the user is creating that expression. These values at present are determined by extensive testing and seeing what values are frequently displayed when creating a certain expression. It would not be difficult to build a classifier for these expression bounds, and use it to train the program over multiple different faces and expressions in order to get the best and most accurate data for each type of face.

In my application, we track six different types of expressions.

surprised

kissing

smiling

In addition, we look for two different types of angry faces: angry with a closed mouth (glaring at someone) or angry with an open mouth (as in yelling).

angry – closed mouth

angry – open mouth

To see a simple flowchart detailing some preliminary bounds for each expression (not exhaustive), check out the chart here (click for larger view).

There is a bit of a “lag” in my application on recognizing these expressions, because the live video stream captures many frames each second, and there is a tiny bit of delay in figuring out what expression that frame’s data fits into. As such, the output of my program is a bit inaccurate still. Because it prints off what the expression every frame, there can be a bit of a buildup and after a while it will start showing expressions at a bit of a delay. For example, if the user acts surprised sometimes the program will not actually print “surprised” for a fraction of a second afterwards, because its busy trying to run through the frames as they come in. A simple remedy to this would be to create a “buffer” of tracked points and use the average of the data over a few seconds in order to determine the facial expression. Because the camera is very sensitive, we are prone to having the data change at the slightest movement of the face. Indeed, even trying to sit as still as possible still results in some small changes in the data. Another thing I noticed that creating a buffer of data could help solve is when the camera loses track of the face for only a moment, it begins to spit out garbage data as it attempts to relocate the face.

Overall we can see a good proof of concept of the capabilities of the Kinect Face Tracking API and there is a lot of room for improvement in the future. Possible future additions/enhancements include:

• tracking a wider range of expressions
• wider range of accessibility (glasses/hats, children, elderly people)
• more specific bounds for facial expressions, use neural networks or something
• more interactive application
• use facial expression recognition to interface with other environments (i.e., call a command by smiling)

# A Genetic Algorithm Approach to Ramsey Theory

Background and Introduction

Ramsey Theory is the study of combinatorial problems proposed by Frank Ramsey in 1930. The version of his problem as applied to graphs asks, “what is the smallest complete graph such that there is at least one clique of a given size and color?” This can be represented by $R(x,y)$ where x and y are the sizes of the cliques to find for red and blue, respectively.

$R(3,3)$ means to find the smallest graph such that we are guaranteed either a red 3-clique (3 vertices connected together at every point, or a complete graph on 3 vertices) or a blue 3-clique. This has been shown to be 6. We can show this by providing an example that a complete graph on 5 vertices ($K_5$) can be colored such that it contains no red or blue 3-cliques. Then, we show that for every coloring of $K_6$, there must necessarily be a red triangle or a blue triangle in the graph. This can be verified computationally or combinatorially. (See the nice example here: Theorem on friends and strangers)

While the problem is relatively easy to solve for a small value like $R(3,3)$, the complexity of the problem increases greatly when considering larger clique sizes. For instance, $R(4,4)$ is 18, and we only know that the value of $R(5,5)$ is somewhere between 43 and 49 inclusive. Because the number of cases one must check increases exponentially with each increase in clique size, it becomes impractical for traditional computing very quickly.

Therefore, we will utilize a genetic algorithm in an attempt to verify and perhaps improve the lower bound of $R(5,5)$. To do this, the program must complete the following:

• Use the genetic algorithm to test for graphs that have low numbers of cliques

• Perform exhaustive testing on these graphs, and if we can find even one coloring where a clique does not exist, we will have shown that $R(5,5) > 43$.

Implementation

My algorithm is implemented using Java. Graphs are represented using an adjacency matrix, and a coloring of the graph (ColorMatrix) are 2D boolean arrays. In this scheme, coloring[x][y]==0 represents a blue edge from x to y and coloring[x][y]==1 represents a red edge. The colorings are symmetric; that is, coloring[x][y] == coloring[y][x]. These colorings form a base for my Chromosome class, which is used in the genetic algorithm to represent a “piece” of information that can be mated with other chromosomes, mutated, and scored based on the number of cliques found. A population stores multiple chromosomes.

My basic algorithm works as follows:

1. Create a population of random colorings of $K_{43}$
2. Check a set of edges for 5-cliques (how these sets are determined will be discussed later). Assign a fitness score based on the number of cliques found

3. Crossover/mutate the chromosomes

4. Run this many times until every member of the population has fitness 0 (no cliques found in that set of edges)

5. Take these “possible zeroes” and begin to test more edges to find cliques

1. if we find any new cliques, this coloring is no longer any good to us (we are looking ultimately for a coloring with no cliques whatsoever)

2. pare down the population to a set of graphs that have no cliques in set 1 and set 2

3. eventually this leads to an exhaustive search but by that point there will be only a few “likely” candidates that passed every test set (this saves computation time rather than checking every clique right off the bat)

Calculating Fitness

The fitness function for our genetic algorithm checks a set of edges in the graph to see if there are any cliques. We test from “test sets” instead of checking every clique every time. The reasoning behind this is that if a clique is found on the first test, we need not go any farther. The multiple-stage fitness testing allows us to prune out “bad” data and get more likely solutions to our problem. The first test set data is computed as follows (each 5-tuple represents a set of five edges to check for a clique — that is, all the same color)

$(0,1,2,3,4), (0,2,3,4,5), (0,3,4,5,6),$

$\dots (0,39,40,41,42), (1,2,3,4,5), (1,3,4,5,6),$

$\dots, (38,39,40,41,42)$

We use a simple method of counting up iteratively the first two items in the list, then using increasing consecutive numbers for the rest of the clique. This way, lots of cliques are tested, but this test set leaves out cliques that are not formed from consecutive edges (e.g., $(0,2,4,6,8)$ would not be tested in this list). Once the list of edges to check is generated, we simply test the edges on each node in the set. If the colors are all the same, then we have a clique and add to our fitness.

The second test set would be applied after the population has converged for the first time to zeroes, and this time counts up by multiples of 2 (so $(0, 2, 4, 6, 8)$ would be a viable choice in this set).

An alternative fitness function was considered that involves inserting vertices into a binary search tree based on their coloring values. To do this, first one creates a random permutation of edges (values 0-42). Then using the colorings (0 and 1 instead of positive and negative) we can insert the nodes either left or right in a binary search tree with the first node in the list as the root. By looking at the output of this tree, we can get a visual representation of color patterns. The idea is that by finding a long “path” in one of these trees we know that it has seen the same color many times, thus suggesting a clique exists.

In the below example, the set $(0,1,2,3,4)$ forms a long “path”, meaning that each edge is the same color.

Unfortunately, this implementation is not currently functional in my program.

Parent Selection and Crossover

The backbone of any genetic algorithm is the crossover. This models the mating process in traditional biology and is used to make the Chromosomes (solutions) improve themselves over many generations by keeping successful traits and discarding others. Parents are selected in my model randomly from the population, but there is a small chance (about 5%) that the best member of the population would be chosen as a parent instead. This provides a slight bias toward better traits but still allows for plenty of randomness and new data.

The crossover is a simple one. Using two Chromosomes (colorings of the graph) we use a random value for each x, y in the colorMatrix to determine whether the “mom” or the “pop” will contribute their genes (coloring[x][y]). There is a 50-50 chance of inserting mom(x,y) into the baby as opposed to pop(x,y). The “baby” Chromosome results in a mixture of data from both parents, and if the new Chromosome’s fitness (number of cliques) is lower than the current worst value in the population, we replace that value with our new baby. This allows the population to improve over time.

Our mutation method simply flips a bit in the coloring based on a random value. The mutation rate was 0.08, or 8%.

Problems and Solutions

One of the things I quickly noticed when building this project was that the fitness function, although it does not brute force every possible clique check, can still take a prohibitively long time at higher population sizes. The getFitness() function is called a bit too liberally, and saving the fitness value to retrieve later would improve the efficiency in this area.

Another downfall is that since we are only testing a limited set of cliques each time, it is possible (although desirable, given the current approach) to “learn the data”, and evolve a solution that contains no cliques in the tested area, but may have cliques elsewhere. While this seems like a problem at first glance, we can use this to our advantage because having the algorithm “learn” each test data set is what allows us to prune the search space and find possible colorings that do not contain cliques. If we decided this was an undesirable behavior however, we could change the fitness function to include x random permutations of edges each time. The problem with this method is that we could never be sure that a clique certainly did not exist in a certain area over multiple rounds, as the sets tested would be randomized each time. Finally, it is possible to go with the old-fashioned approach and simply check every clique after all.

Future Work

While this program currently provides a proof of concept and implementation up to the first round of test data, there is much room for expanding this project. First of all, multiple rounds need to be completed within the algorithm, so that we can generate colorings that are more likely to have no cliques. Other things that would be useful are outputting data to a text file for further reading/analysis, and performing general optimizations throughout my code for performance.

In addition, I would really like to get a working implementation of the Alternate Fitness function implemented and working. I feel like this is an interesting direction to take the project and it would be helpful to have a more visual representation of where cliques are occurring.

While the population initialization currently creates a population of random colorings, it would be interesting to see what happens when we change the ratios of red edges to blue edges in the chromosomes, starting at initialization. What if each coloring was required to be within a certain amount red and a certain amount blue? This is definitely something to check into as well.

Conclusion

Currently, we are able to generate lists of colorings that do not have cliques within the first test set of edges. As we add on more edge sets to test, we will create more constrained lists. Further testing will reveal if any of these “possible” solutions truly do not contain such cliques. For this, an exhaustive search is the only way. Although it is on the order of 900,000 edge combinations (${43 \choose 5} = 962598$) to check, this is time consuming but doable, especially if we have a relatively small set of graphs to check.

Finally, the code is available on https://github.com/nelsonam/ramsey if anyone is interested. Share your comments in the box below and if you have any questions feel free to ask!