Understanding Genetic Algorithms and Genetic Programming

Artificial intelligence is everywhere these days. This course teaches you how to implement two types of AI using simple C#. You'll use concepts from biology to evolve solutions to complex problems like optimal subset selection and data ordering.
Course info
Rating
(16)
Level
Beginner
Updated
Jul 17, 2018
Duration
3h 15m
Table of contents
Course Overview
Introduction to Genetic Algorithms and Genetic Programming
Solving Optimization Problems with Genetic Algorithms
Improving Genetic Algorithms by Tuning Crossover, Mutation, Fitness, and Selection
Deriving a Formula from Data with Genetic Programming
Advanced Concepts in Genetic Programming
Description
Course info
Rating
(16)
Level
Beginner
Updated
Jul 17, 2018
Duration
3h 15m
Description

Certain problems can't be solved by brute force. Combinatorial problems that involve finding an optimal ordering or subset of data can be extremely challenging to solve if the number of items is too large since the time to test each possible solution can often be prohibitive. In this course, you'll learn how to write artificial intelligence code that uses concepts from biology (like evolution, genetic crossover, and mutation) so the software can evolve optimal solutions to complex problems. The code will be written in fairly simple C#, and no external libraries will be used, so you'll understand all of the details. First, you'll learn how to write a genetic algorithm, which is a technique to manipulate data. You'll learn about different ways to represent potential solutions, as well as techniques for evolving solutions over a number of generations. Different types of crossover and mutation will be discussed, as well as various factors related to evaluating each candidate solution's fitness, which influences which candidates are selected for reproduction. After looking at how genetic algorithms can be used to find optimal solutions for data, you'll learn about genetic programming, which uses similar concepts but evolves actual executable code, rather than simply manipulating data. Genetic programming is particularly well-suited to finding an expression that fits a set of training data. The results of this technique can be used for prediction, estimates, and the like. Finally, you'll discover how genetic programming can be used to perform many complex tasks - controlling processes and making decisions, in particular. The code that results can be quite complex, balancing many different competing factors and constraints. By the end of this course, you'll have a solid foundation to apply these concepts to your own programs.

About the author
About the author

Greg Sommerville is an experienced software developer who has worked in a wide variety of business domains, including health care research, medical devices, enterprise-level software ordering and licensing, and online banking. He specializes in web and mobile development.

More from the author
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Whether it's advanced systems like Google's AlphaGo or even the software that powers voice recognition on your phone, artificial intelligence is everywhere these days. Unfortunately, writing your own AI software has always been difficult. Techniques like neural networks are powerful, but complex, and frequently involve advanced mathematics. Fortunately, there's an alternative. In this course, Understanding Genetic Algorithms and Genetic Programming, you'll learn how to apply concepts from biology to software development. Instead of you, the programmer, coming up with an algorithm the software will evolve its own solutions, which can often solve problems that would be far too complex for traditional programming. Some of the major topics that we will cover include how we can find solutions to complex problems by using populations of candidate solutions, and evolving them over time using concepts like genetic crossover and mutation, how genetic algorithms can be used to find optimal subsets of data, and how they can find optimal orderings of data, and perhaps, most impressively, how you can evolve actual executable code that can be used in your own programs. We'll examine three different applications for this technique, including finding an equation that fits a set of training data, controlling the movement of an object in space, and code to help us make decisions in a game of Texas hold'em poker. By the end of this course you'll understand how to apply these techniques to your own code. Before beginning this course you should be familiar with C#, but please be aware that this course does not require advanced programming skills. In fact, most of the code we will write will be fairly simple. I hope you'll join me as we learn more about this fascinating approach to AI with the Understanding Genetic Algorithms and Genetic Programming course at Pluralsight.

Improving Genetic Algorithms by Tuning Crossover, Mutation, Fitness, and Selection
Welcome to Improving Genetic Algorithms by Tuning Crossover, Mutation, Fitness, and Selection. In the previous module we implemented a simple genetic algorithm, which found an optimal subset of items. In this module we'll explore how different approaches to crossover, mutation, fitness calculations, and selection can result in big improvements in a solutions effectiveness. We'll also change our focus from finding an optimal subset of items to finding an optimal ordering of items. Let's consider a few applications for that. First, routing. Whether you're routing a package from factory to customer or routing materials between workstations on a factory floor, the challenge is to find an optimal ordering that maximizes efficiency. Another application is automated machine control. If you've got an automated drill or saw you want it to make its cuts or drill its holes with the least amount of wasted time. Increase efficiency results in more products produced in less time. Finally, genetic algorithms are a powerful tool for scheduling, since they can find optimal orderings of tasks while taking into account whatever resource dependencies there are in the situation. Of course, there are more applications than the ones listed here. These are just some basic descriptions. For our demonstration application we're going to use an example of an optimal ordering problem called the travelling salesman problem. Let's talk about that next.

Deriving a Formula from Data with Genetic Programming
In this module we move from genetic algorithms to genetic programming. Both are types of evolutionary computing, but with genetic programs we're actually evolving executable code. Before we get started, if you have concerns that the code to implement this sounds like it might be complicated you'll be relieved to hear that most of the code is relatively straightforward. Certainly, some of the code we'll explore in this module is slightly more complicated than what we have used so far, but once we get into it you'll see just how straightforward it actually is. In the previous two modules we demonstrated how a genetic algorithm was an effective way of searching a very large problem space for an optimal ordering or subset of data. As we move to genetic programming, the computer will actually be developing its own solutions to various problems. We won't be solving a problem with a particular set of data. We'll be evolving working programs that can be used repeatedly with different sets of inputs. The possible applications for genetic programming are wide, but we can break them into two primary categories. First, we can use a genetic program to calculate. We'll explore that idea when we develop a program that finds a formula that fits a given set of training data. The second thing we can use a genetic program for is to control a process. We'll create a second demonstration that shows this by simulating the movement of an object in physical space. The genetic program will dictate the physical force placed on that object in order to reach our goal. Of course, since we are evolving actual code, the possible applications are as wide as any conventional program. It's really limited to your imagination to find an appropriate application. So now let's get started by talking about the most basic idea in genetic programming, and that's representation.

Advanced Concepts in Genetic Programming
In this final module of the course we'll explore some of the advanced techniques that are available when doing genetic programming. We'll show how the use of these techniques will allow us to solve complex problems that might not otherwise be possible. Let's start by taking another look at closure. It's the idea that all nodes in an expression tree must have the same data type. In our previous examples, we created programs that used only floating point numbers, but what about problems where the input data doesn't fit quite as neatly? What if we want a genetic program that uses different types of data about the state of a system, and we want to make a decision based on that data? If the end result of our program is a Boolean value, for example, it seems like closure would be quite restrictive, so let's look at that problem and its possible solutions in more detail next.