General question about crossover operator for a genetic algorithm

In summary, genetic algorithms can be used to create populations that are more fit than the original parents. It depends on the goal of the GA, but the most commonly used crossover operator is single-point and mutation is used to improve the population's fitness.
  • #1
markiv
26
0
Hey guys, this is my first time working on a genetic algorithm. It seems to me that the algorithm is primarily defined by how you choose to define your crossover operator and fitness function. Let's say the crossover takes two parents and produces one child. Is it necessary/good/bad/etc that the child should have a higher fitness than either of its parents? Or do we let the selection function take care of making sure that our population increases in fitness over time?
 
Technology news on Phys.org
  • #2
It technically depends on the goal of you GA, but the way that I had it explained to me was this:

You take an initial population of M and F parents. You combine them and produce children. You take the children with a lower fitness than your continuation criteria, you shoot them in the head, and you move on. Morbid, but it does a good job of getting the point of the algorithm.

What language are you writing in? I have an evolutionary algorithm written in Fortran 90 from a few years ago that you could take a look at. It's from college, so it's not perfect, but it might give you good ideas.
 
  • #3
Artificial Intelligence - A Modern Approach by Russell and Norvig and Machine Learning by Mitchell offer high level overviews of genetic algorithms.

The population's overall fitness will increase over time due to the way the GA works. It's common to basically have three ways to create the new population:
  1. Elite children
  2. Crossover
  3. Mutation
Elite children are the elements of the population with the highest fitness. A fixed number of these elites will automatically join the next generation.

Crossover combines two individuals to produce two offspring. The parents are generally chosen probabilistically according to the following function, where [itex]h[/itex] is an individual hypothesis, [itex]\Phi(h)[/itex] is the fitness function, and [itex]n[/itex] is the population size:
[tex]P(h_i \text{ is selected}) = \frac{\Phi(h_i)}{\sum_{j=1}^n \Phi(h_j)}[/tex]
Then, you either do single-point crossover, two-point crossover, or uniform crossover to create two offspring.

Mutation is then applied to the population. Generally speaking, a percentage of the population is chosen with uniform probability and each chosen individual has a random bit inverted.

So, basically, the fitness function drives which individuals are selected to move on; technically speaking, the fitness function solely assigns a numerical score representing the quality of the hypothesis; the actual genetic algorithm decides which individuals are kept. Crossover is a method to generate new individuals which may or may not be more fit than the parents.

Of course, the above details can change based on the way the GA is implemented.
 
  • #4
Thanks for the feedback.

swartzism said:
What language are you writing in? I have an evolutionary algorithm written in Fortran 90 from a few years ago that you could take a look at. It's from college, so it's not perfect, but it might give you good ideas.
The final program will likely be written in C, but I may write it in Python first for proof of concept. If you do have code though, I'd like to look at it.

jhae2.718 said:
Artificial Intelligence - A Modern Approach by Russell and Norvig and Machine Learning by Mitchell offer high level overviews of genetic algorithms.

The population's overall fitness will increase over time due to the way the GA works. It's common to basically have three ways to create the new population:
  1. Elite children
  2. Crossover
  3. Mutation
Elite children are the elements of the population with the highest fitness. A fixed number of these elites will automatically join the next generation.

Crossover combines two individuals to produce two offspring. The parents are generally chosen probabilistically according to the following function, where [itex]h[/itex] is an individual hypothesis, [itex]\Phi(h)[/itex] is the fitness function, and [itex]n[/itex] is the population size:
[tex]P(h_i \text{ is selected}) = \frac{\Phi(h_i)}{\sum_{j=1}^n \Phi(h_j)}[/tex]
Then, you either do single-point crossover, two-point crossover, or uniform crossover to create two offspring.

Mutation is then applied to the population. Generally speaking, a percentage of the population is chosen with uniform probability and each chosen individual has a random bit inverted.

So, basically, the fitness function drives which individuals are selected to move on; technically speaking, the fitness function solely assigns a numerical score representing the quality of the hypothesis; the actual genetic algorithm decides which individuals are kept. Crossover is a method to generate new individuals which may or may not be more fit than the parents.

Of course, the above details can change based on the way the GA is implemented.
Thanks a lot for the references, they look very good. After browsing around the internet about GA, though, there's this question that keeps coming up that I haven't found an answer to. I know single-point, two-point, and uniform crossovers are all different ways to crossover two individuals, but are these the only ways to perform a crossover? For example, I'd like to represent each individual in my population as pair of permutations, but permutations don't exactly lend themselves to these types of crossover. I've thought of ways of "combining" two individuals in such a way that the offspring "resembles" the parents, but they aren't any of the 3 mentioned above. Must they be so?
 
  • #5
Crossover is basically just swapping parts of two parents to create two children, so you're fine. There are other types of crossover defined for different types of individuals; trees for example can't use the types of crossover defined above.
 

1. What is a crossover operator in a genetic algorithm?

A crossover operator in a genetic algorithm is a genetic operator that combines two parent solutions to generate a new offspring solution. It simulates the process of sexual reproduction in nature, where genetic material from two individuals is combined to create a new individual with a mix of traits from both parents.

2. How does a crossover operator work?

A crossover operator works by randomly selecting a crossover point in the parent solutions and then swapping the genetic material at and after that point to create two new offspring solutions. The two new solutions are then evaluated and may be selected to become parent solutions for the next generation in the genetic algorithm.

3. What is the purpose of a crossover operator in a genetic algorithm?

The purpose of a crossover operator in a genetic algorithm is to promote diversity and prevent the algorithm from getting stuck in local optima. By combining genetic material from two parent solutions, the crossover operator allows for the exploration of new regions of the solution space and can lead to improved solutions in the long run.

4. How is the crossover operator used in practice?

The crossover operator is typically used in combination with other genetic operators, such as mutation and selection, in a genetic algorithm. It is applied to a population of solutions at each generation, with the goal of producing a new population with improved fitness values. The specific implementation and parameters of the crossover operator can vary depending on the problem being solved.

5. Are there different types of crossover operators?

Yes, there are several different types of crossover operators, including single-point crossover, multi-point crossover, and uniform crossover. These variations differ in how they select the crossover point(s) and how they combine the genetic material from the parent solutions. The choice of crossover operator can have a significant impact on the performance of a genetic algorithm, and it is often problem-specific.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
6
Views
9K
  • Programming and Computer Science
Replies
29
Views
3K
  • Programming and Computer Science
Replies
7
Views
3K
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
17
Views
3K
Back
Top