Advanced Search
For these advanced searches, the goal is to find a node n such that f(n) ≥ f(i) for all nodes i in the state space. The goal is to find the state with the highest score.
Hill-Climbing
Looks at all immediate neighbors of current state m to find a successor n such that f(n) > f(m) and f(n) \geq f(t) for all successors t of m, then move from m to n. If no such n is found, halt.
Not complete, terminates at local maxima.
Pseudocode
- Pick initial state s
- Pick t in neighbors(s) with largest f(t)
- if(f(t) ≤ f(s)) then STOP, return s
- s = t. GOTO 2
Repeated Hill Climbing with Random Restarts
- When stuck, pick random new start and run basic hill climbing
- Repeat k times
- Return the best of the k local optima
Simulated Annealing
Instead of picking the best move, simulated annealing picks a random move and checks successor. If the successor is an improvement over the current state, the move is made; otherwise make the move with some small probability < 1. The probability decreases exponentially with the badness of the move.
Pseudocode
- Pick initial state s
- Randomly pick t in the neighbors(s)
- if(f(t) better) then accept s ← t
- else accept s ← t with small probability
- GOTO 2 until bored
Genetic Algorithm
Pseudocode
- Let s1,...,sN be the current population
- Let pi = f(si)/∑jf(sj) be the reproduction probability
- for(k = 1; k < N; k += 2)
- parent1 = randomly pick according to p
- parent2 = randomly pick another
- randomly select a crossover point, swap strings of parents 1, 2 to generate childern t[k], t[k+1]
- for(k = 1; k ≤ N; k++)
- randomly mutate each position in t[k] with a small probability (mutation rate)
- The new generation replaces the old: {s} ← {t}. Repeat.