foundations of computational agents
The preceding local search algorithms maintain a single total assignment. This section considers algorithms that maintain multiple total assignments. The first method, beam search, maintains the best assignments. The next algorithm, stochastic beam search, selects which assignments to maintain stochastically. In genetic algorithms, which are inspired by biological evolution, the assignments forming a population interact to produce the new population. In these algorithms, a total assignment of a value to each variable is called an individual and the set of current individuals is a population.
Beam search is a method similar to iterative best improvement, but it maintains up to assignments instead of just one. It reports success when it finds a satisfying assignment. At each stage of the algorithm, it selects best possible successors of the current individuals (or all of them if there are less than ) and picks randomly in the case of ties. It repeats with this new set of total assignments.
Beam search considers multiple assignments at the same time. Beam search is useful for memory-bounded cases, where can be selected depending on the memory available. The variants of stochastic local search presented earlier are also applicable to beam search; you can spend more time finding the best , or spend less time and only approximate the best .
Stochastic beam search is an alternative to beam search, which, instead of choosing the best individuals, selects of the individuals at random; the individuals with a better evaluation are more likely to be chosen. This is done by making the probability of being chosen a function of the evaluation function. A standard way to do this is to use a Gibbs distribution or Boltzmann distribution and to select an assignment with probability proportional to
where is an evaluation function and is a temperature.
Stochastic beam search tends to allow more diversity in the individuals than does plain beam search. As an analogy to evolution in biology, the evaluation function reflects the fitness of the individual; the fitter the individual, the more likely it is to pass its genetic material – here its variable assignment – onto the next generation. Stochastic beam search is like asexual reproduction; each individual gives slightly mutated children and then stochastic beam search proceeds with survival of the fittest. Note that under stochastic beam search it is possible for an individual to be selected multiple times at random.
Genetic algorithms further pursue the evolution analogy. Genetic algorithms are like stochastic beam searches, but each new element of the population is a combination of a pair of individuals – its parents. In particular, genetic algorithms use an operation known as crossover that select pairs of individuals and then create new offspring by taking some of the values for the offspring’s variables from one of the parents and the rest of the values from the other parent, loosely analogous to how DNA is spliced in sexual reproduction.
A genetic algorithm is shown in Figure 4.11. This maintains a population of individuals (where is an even number). At each step, a new generation of individuals is generated via the following steps until a solution is found:
Randomly select pairs of individuals where the fitter individuals are more likely to be chosen. How much more likely a fit individual is to be chosen than a less fit individual depends on the difference in fitness levels and a temperature parameter.
For each pair, perform a crossover.
Randomly mutate some (very few) values by choosing other values for some randomly chosen variables. This is a random walk step.
It proceeds in this way until it has created individuals, and then the operation proceeds to the next generation.
The new operation that occurs in genetic algorithms is called crossover. Uniform crossover takes two individuals (the parents) and creates two new individuals, called the children. The value for each variable in a child comes from one of the parents. A common method is one-point crossover, shown in the procedure Crossover in Figure 4.11, which assumes a total ordering of the variables. An index is selected at random. One of the children is constructed by selecting the values for the variables up to from one of the parents, and the values for variables after from the other parent. The other child gets the other values. The effectiveness of the crossover depends on the total ordering of the variables. The ordering of the variables is part of the design of the genetic algorithm.
Consider Example 4.9 where the evaluation function to be minimized is the number of unsatisfied constraints. The individual , , , , has an evaluation of 4. It has a low value mainly because . Its offspring that preserve this property will tend to have a lower evaluation than those that do not and, thus, will be more likely to survive. Other individuals may have low values for different reasons; for example, the individual , , , , also has an evaluation of 4. It is low mainly because of the assignment of values to the first four variables. Again, offspring that preserve this property will be fitter and more likely to survive than those that do not. If these two were to mate, some of the offspring would inherit the bad properties of both and would die off. Some, by chance, would inherit the good properties of both. These would then have a better chance of survival.
Efficiency is very sensitive to the variables used to describe the problem and the ordering of the variables. Getting this to work is an art. As with many other randomized algorithms, evolutionary algorithms have many degrees of freedom and, therefore, are difficult to configure or tune for good performance.
A large community of researchers are working on genetic algorithms to make them practical for real problems and there have been some impressive results. What we have described here is only one of the possible genetic algorithms.