Genetic Algorithms. Genetic Algorithms (Gas) are inspired by ideas from biological evolution. Like SAs the starting point is a random poor quality solution, or rather a set of poor quality solutions.
Genetic Algorithms (Gas) are inspired by ideas from biological evolution. Like SAs the starting point is a random poor quality solution, or rather a set of poor quality solutions.
A GA searches by iterating for some number of generations. During each generation the best solutions are allowed to mate. Mating involves a process known as crossover producing a new solution by sharing parts of a pair of mating parent solutions.
Solutions may also be mutated by randomly changing some of their parts – useful to deal with local maxima.
At the end of each generation the lowest quality solutions (the least fit) are killed off – survival of the fittest.
Sometimes mating and mutation improve the quality of solutions, other times they do not. Eventually however, high quality solutions begin to form and are preserved.
In general the quality of the final solution depends on the number of generations.
One of the critical issues in Gas is that of representation. Many problems are very difficult to represent in a way that suits the GA mating and mutation operators, and non-viable solutions can be produced.
Loop for g iterations or until some solution is fit enough
Return the best solution
In satisfiability problems the task is to find a satisfying truth assignment for propositional sentences. Nsat implies that the sentence is in N-CNF (N conjunctive normal form). A sentence is in N-CNF it is a conjunction of disjunctions (clauses) such that each clause contains exactly N literals.
Satisfiability problems are extremely difficult to handle and indeed are NP complete for N>2.
This type of problems is amenable to a GA solution. Each solution can be represented by a list of V Boolean elements. Each element corresponds to the value assigned to a particular variable in the given sentence.
For example, consider the following 3Sat instance:-
(P+Q+S).(P+Q+R). (P+ R S).(P+ S+T)
Crossover and mutation operators are easily implemented:
The evaluation or fitness function simply counts the number of satisfied clauses for a given assignment.
P Q R S T
P Q R S T
(F F T T T)
(T F F F T)
(F FF F T)
(F TF F T)
The simplest TSP representation for GA is the same as for SA, namely a solution being a list of city names where the solution order corresponds to the order the cities are visited. However this can cause problems during mating.
(A B C D E F G)
(B C G E F A D)
(A B C DF A D)
This simple form of mating rules runs into serious problems because it can (and usually does) result in unviable solutions.One possible way around this is to use more complicated crossover operators during mating. Alternatively, a different representation can be employed. For example random keying involves representing solutions as lists of real numbers. Each list position corresponds to a city and the numerical order (not list order) corresponds to the visiting order
(.11 .16 .38 .4 .54 .6 .71)
(.77 .05 .1 .98 .34 .45 .12)
(.11 .16 .38 .4.34 .45 .12)
(A G B E C D F)
010 (Outlook = Overcast)
011 (Outlook = Overcast) | (Outlook = Rain)
(Outlook = Overcast) & (Wind = Strong)
IF (Wind = Strong) THEN PlayTennis = Yes
1 1 1 1 0 1
Outlook = Sunny | Outlook = OverCast | Outlook=Rain
PlayTennis = Yes
Wind = Strong