artificial intelligence problem solving by searching csc 361 dr. yousef al-ohali computer science...
TRANSCRIPT
![Page 1: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/1.jpg)
Artificial IntelligenceProblem solving by searching
CSC 361
Dr. Yousef Al-Ohali
Computer Science Depart.CCIS – King Saud University
Saudi Arabia
[email protected]://faculty.ksu.edu.sa/YAlohali
![Page 2: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/2.jpg)
Problem Solving by Searching
Search Methods : Local Search forOptimization Problems
![Page 3: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/3.jpg)
3
Heuristic Functions A heuristic function is a function f(n) that gives an estimation on
the “cost” of getting from node n to the goal state – so that the node with the least cost among all possible choices can be selected for expansion first.
Three approaches to defining f:
f measures the value of the current state (its “goodness”)
f measures the estimated cost of getting to the goal from the current state:
f(n) = h(n) where h(n) = an estimate of the cost to get from n to a goal
f measures the estimated cost of getting to the goal state from the current state and the cost of the existing path to it. Often, in this case, we decompose f:
f(n) = g(n) + h(n) where g(n) = the cost to get to n (from initial state)
![Page 4: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/4.jpg)
4
Approach 1: f Measures the Value of the Current State
Usually the case when solving optimization problems Finding a state such that the value of the metric f is optimized
Often, in these cases, f could be a weighted sum of a set of component values:
Chess
Example: piece values, board orientations …
Traveling Salesman Person
Example: the length of a tour (sum of distances between visited cities)
![Page 5: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/5.jpg)
5
Traveling Salesman Person Find the shortest Tour traversing all cities
once.
![Page 6: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/6.jpg)
6
Traveling Salesman Person A Solution: Exhaustive Search
(Generate and Test) !!
The number of all tours is about (n-1)!/2
If n = 36 the number is about:
566573983193072464833325668761600000000
Not Viable Approach !!
![Page 7: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/7.jpg)
7
Traveling Salesman Person A Solution: Start from an initial solution
and improve using local transformations.
![Page 8: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/8.jpg)
8
2-opt mutation for TSP
Choose two edges at random
![Page 9: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/9.jpg)
9
2-opt mutation for TSP
Choose two edges at random
![Page 10: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/10.jpg)
10
2-opt mutation for TSP
Remove them
![Page 11: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/11.jpg)
11
2-opt mutation for TSP
Reconnect in a different way (there is only one valid new way)
![Page 12: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/12.jpg)
Optimization Problems
Local Search Algorithms
![Page 13: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/13.jpg)
13
Local Search AlgorithmsLocal Search Algorithms
The search algorithms we have seen so far keep track of the current state, the “fringe” of the search space, and the path to the final state.
In some problems, one doesn’t care about a solution path but only the orientation of the final goal state
Example: 8-queen problem
Local search algorithms operate on a single state – current state – and move to one of its neighboring states
Solution path needs not be maintained Hence, the search is “local”
![Page 14: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/14.jpg)
14
Local Search AlgorithmsLocal Search Algorithms
Example:
Put N Queens on an n × n board with no two queens on the same row, column, or diagonal
Initial state … Improve it … using local transformations (perturbations)
![Page 15: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/15.jpg)
15
Local Search AlgorithmsLocal Search Algorithms
Basic idea: Local search algorithms operate on a single state – current state – and move to one of its neighboring states.
The principle: keep a single "current" state, try to improve it
Therefore: Solution path needs not be maintained. Hence, the search is “local”.
Two advantages Use little memory. More applicable in searching large/infinite search space. They find
reasonable solutions in this case.
![Page 16: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/16.jpg)
16
Local Search Algorithms for Local Search Algorithms for optimization Problemsoptimization Problems Local search algorithms
are very useful for optimization problems
systematic search doesn’t work
however, can start with a suboptimal solution and improve it
Goal: find a state such that the objective function is optimized
Minimize the number
of attacks
![Page 17: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/17.jpg)
Local Search Algorithms
Hill Climbing,Simulated Annealing,
Tabu Search
![Page 18: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/18.jpg)
18
Local Search: State SpaceLocal Search: State Space
A state space landscape is a graph of states associated with their costs
![Page 19: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/19.jpg)
19
Hill Climbing
• Hill climbing search algorithm (also known as greedy local search) uses a loop that continually moves in the direction of increasing values (that is uphill).
• It teminates when it reaches a peak where no neighbor has a higher value.
• "Like climbing Everest in thick fog with amnesia"
![Page 20: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/20.jpg)
20
Steepest Ascent VersionSteepest Ascent Version
Steepest ascent version
Function Hill climbing (problem) return state that is a local maximun
Inputs: problem, a problem Local variables: current, a node neighbor, a nodeCurrent ← Make-Node (initial-state [problem])Loop doneighbor ← a highest-valued successor of currentIf Value[neighbor] ≤ Value[current] then return state
[current]Current ← neighbor
![Page 21: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/21.jpg)
21
Hill Climbing: NeighborhoodConsider the 8-queen problem:
A State contains 8 queens on the board
The neighborhood of a state is all states generated by moving a single queen to another square in the same column (8*7 = 56 next states)
The objective function h(s) = number of queens that attack each other in state s.
h(s) = 17 best next is 12 h(s)=1 [local minima]
![Page 22: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/22.jpg)
22
Hill Climbing DrawbacksHill Climbing Drawbacks
Local maxima/minima : local search can get stuck on a local maximum/minimum and not find the optimal solution
Local minimum
• Cure+ Random restart+ Good for Only few local maxima
![Page 23: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/23.jpg)
23
Hill Climbing
Cost
States
![Page 24: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/24.jpg)
24
Hill ClimbingCurrent Solution
![Page 25: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/25.jpg)
25
Hill ClimbingCurrent Solution
![Page 26: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/26.jpg)
26
Hill ClimbingCurrent Solution
![Page 27: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/27.jpg)
27
Hill ClimbingCurrent Solution
![Page 28: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/28.jpg)
28
Hill ClimbingBest
![Page 29: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/29.jpg)
Local Search Algorithms
Simulated Annealing(Stochastic hill climbing …)
![Page 30: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/30.jpg)
30
Simulated Annealing Key Idea: escape local maxima by allowing some "bad"
moves but gradually decrease their frequency
Take some uphill steps to escape the local minimum
Instead of picking the best move, it picks a random move
If the move improves the situation, it is executed. Otherwise, move with some probability less than 1.
Physical analogy with the annealing process: Allowing liquid to gradually cool until it freezes
The heuristic value is the energy, E
Temperature parameter, T, controls speed of convergence.
![Page 31: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/31.jpg)
31
Simulated Annealing Basic inspiration: What is annealing? In mettallurgy, annealing is the physical process used to
temper or harden metals or glass by heating them to a high temperature and then gradually cooling them, thus allowing the material to coalesce into a low energy cristalline state.
Heating then slowly cooling a substance to obtain a strong cristalline structure.
Key idea: Simulated Annealing combines Hill Climbing with a random walk in some way that yields both efficiency and completeness.
Used to solve VLSI layout problems in the early 1980
![Page 32: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/32.jpg)
32
Simulated Annealing
![Page 33: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/33.jpg)
33
Simulated Annealing
![Page 34: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/34.jpg)
34
Simulated Annealing Temperature T
Used to determine the probability High T : large changes Low T : small changes
Cooling Schedule Determines rate at which the temperature T is lowered Lowers T slowly enough, the algorithm will find a global
optimum
In the beginning, aggressive for searching alternatives, become conservative when time goes by
![Page 35: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/35.jpg)
35
Simulated Annealing
Cost
States
Best
![Page 36: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/36.jpg)
36
Simulated Annealing
Cost
States
Best
![Page 37: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/37.jpg)
37
Simulated Annealing
Cost
States
Best
![Page 38: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/38.jpg)
38
Simulated Annealing
Cost
States
Best
![Page 39: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/39.jpg)
39
Simulated Annealing
Cost
States
Best
![Page 40: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/40.jpg)
40
Simulated Annealing
Cost
States
Best
![Page 41: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/41.jpg)
41
Simulated Annealing
Cost
States
Best
![Page 42: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/42.jpg)
42
Simulated Annealing
Cost
States
Best
![Page 43: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/43.jpg)
43
Simulated Annealing
Cost
States
Best
![Page 44: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/44.jpg)
44
Simulated Annealing
Cost
States
Best
![Page 45: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/45.jpg)
45
Simulated Annealing
Cost
States
Best
![Page 46: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/46.jpg)
46
Simulated Annealing
Cost
States
Best
![Page 47: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/47.jpg)
47
Simulated Annealing
Cost
States
Best
![Page 48: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/48.jpg)
48
Simulated Annealing
Cost
States
Best
![Page 49: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/49.jpg)
49
Simulated Annealing
Cost
States
Best
![Page 50: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/50.jpg)
50
Simulated Annealing
Cost
States
Best
![Page 51: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/51.jpg)
51
Simulated Annealing
Cost
States
Best
![Page 52: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/52.jpg)
52
Simulated Annealing
Cost
States
Best
![Page 53: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/53.jpg)
53
Simulated Annealing
Cost
States
Best
![Page 54: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/54.jpg)
54
Simulated Annealing
Cost
States
Best
![Page 55: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/55.jpg)
55
Simulated Annealing
Cost
States
Best
![Page 56: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/56.jpg)
56
Simulated Annealing
Cost
States
Best
![Page 57: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/57.jpg)
57
Simulated Annealing
Cost
States
Best
![Page 58: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/58.jpg)
Local Search Algorithms
Tabu Search(hill climbing with small
memory)
![Page 59: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/59.jpg)
59
Tabu Search The basic concept of Tabu Search as described by
Glover (1986) is "a meta-heuristic superimposed on another heuristic.
The overall approach is to avoid entrainment in cycles by forbidding or penalizing moves which take the solution, in the next iteration, to points in the solution space previously visited ( hence "tabu").
The Tabu search is fairly new, Glover attributes it's origin to about 1977 (see Glover, 1977).
![Page 60: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/60.jpg)
60
Tabu Search: TS
Cost
States
![Page 61: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/61.jpg)
61
Tabu Search: TSBest
![Page 62: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/62.jpg)
62
Tabu Search: TSBest
![Page 63: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/63.jpg)
63
Tabu Search: TSBest
![Page 64: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/64.jpg)
64
Tabu Search: TSBest
![Page 65: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/65.jpg)
65
Tabu Search: TSBest
![Page 66: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/66.jpg)
66
Tabu Search: TSBest
![Page 67: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/67.jpg)
67
Tabu Search: TSBest
![Page 68: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/68.jpg)
68
Tabu Search: TSBest
![Page 69: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/69.jpg)
69
Tabu Search: TSBest
![Page 70: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/70.jpg)
70
Tabu Search: TSBest
![Page 71: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/71.jpg)
71
Tabu Search: TSBest
![Page 72: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/72.jpg)
72
Tabu Search: TSBest
![Page 73: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/73.jpg)
73
Tabu Search: TSBest
![Page 74: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/74.jpg)
74
Tabu Search: TSBest
![Page 75: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/75.jpg)
75
Tabu Search: TSBest
![Page 76: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/76.jpg)
76
Tabu Search: TSBest
![Page 77: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/77.jpg)
77
Tabu Search: TSBest
![Page 78: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/78.jpg)
78
Tabu Search: TSBest
![Page 79: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/79.jpg)
79
Tabu Search: TSBest
![Page 80: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/80.jpg)
80
Tabu Search: TSBest
![Page 81: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/81.jpg)
81
Tabu Search: TSBest
![Page 82: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/82.jpg)
82
Tabu Search: TSBest
![Page 83: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/83.jpg)
Optimization Problems
Population Based AlgorithmsBeam Search, Genetic Algorithms & Genetic
Programming
![Page 84: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/84.jpg)
Population based Algorithms
Beam Search Algorithm
![Page 85: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/85.jpg)
85
Local Beam Search
Unlike Hill Climbing, Local Beam Search keeps track of k states rather than just one.
It starts with k randomly generated states.
At each step, all the successors of all the states are generated.
If any one is a goal, the algorithm halts, otherwise it selects the k best successors from the complete list and repeats.
LBS≠ running k random restarts in parallel instead of sequence.
Drawback: less diversity. → Stochastic Beam Search
![Page 86: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/86.jpg)
86
Local Beam Search Idea: keep k states instead of just 1
Begins with k randomly generated states
At each step all the successors of all k states are generated.
If one is a goal, we stop, otherwise select k best successors from complete list and repeat
![Page 87: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/87.jpg)
87
Local Beam Search
Cost
States
![Page 88: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/88.jpg)
88
Local Beam Search
![Page 89: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/89.jpg)
89
Local Beam Search
![Page 90: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/90.jpg)
90
Local Beam Search
![Page 91: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/91.jpg)
91
Local Beam Search
![Page 92: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/92.jpg)
92
Local Beam Search
![Page 93: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/93.jpg)
93
Local Beam Search
![Page 94: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/94.jpg)
94
Local Beam Search
![Page 95: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/95.jpg)
95
Local Beam Search
![Page 96: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/96.jpg)
96
Local Beam Search
![Page 97: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/97.jpg)
97
Local Beam Search
![Page 98: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/98.jpg)
98
Local Beam Search
![Page 99: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/99.jpg)
99
Local Beam Search
![Page 100: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/100.jpg)
100
Local Beam Search
![Page 101: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/101.jpg)
101
Local Beam Search
![Page 102: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/102.jpg)
102
Local Beam Search
![Page 103: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/103.jpg)
Population based Algorithms
Genetic AlgorithmsGenetic programming
![Page 104: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/104.jpg)
104
Stochastic Search: Genetic Algorithms
Formally introduced in the US in the 70s by John Holland.
GAs emulate ideas from genetics and natural selection and can search potentially large spaces.
Before we can apply Genetic Algorithm to a problem, we need to answer:
- How is an individual represented?- What is the fitness function?- How are individuals selected?- How do individuals reproduce?
![Page 105: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/105.jpg)
105
Stochastic Search: Genetic AlgorithmsRepresentation of states (solutions)
• Each state or individual is represented as a string over a finite alphabet. It is also called chromosome which Contains genes.
1001011111Solution: 607 Encoding
Chromosome:
Binary String
genes
![Page 106: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/106.jpg)
106
Stochastic Search: Genetic AlgorithmsFitness Function
• Each state is rated by the evaluation function called fitness function. Fitness function should return higher values for better states:
Fitness(X) should be greater than Fitness(Y) !!
[Fitness(x) = 1/Cost(x)]
Cost
StatesX Y
![Page 107: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/107.jpg)
107
Stochastic Search: Genetic AlgorithmsSelection
How are individuals selected ?
Roulette Wheel Selection
1 2 3 1 3 5 1 2
0 18
21 3 4 5 6 7 8
Rnd[0..18] = 7
Chromosome4
Rnd[0..18] = 12
Chromosome6
![Page 108: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/108.jpg)
108
Stochastic Search: Genetic AlgorithmsCross-Over and Mutation
How do individuals reproduce ?
![Page 109: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/109.jpg)
109
Stochastic Search: Genetic AlgorithmsStochastic Search: Genetic AlgorithmsCrossover - RecombinationCrossover - Recombination
1010000000
1001011111
Crossover single point -
random
1011011111
1010000000
Parent1
Parent2
Offspring1
Offspring2
With some high probability (crossover rate) apply crossover to the parents. (typical values are 0.8 to 0.95)
![Page 110: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/110.jpg)
110
Stochastic Search: Genetic AlgorithmsStochastic Search: Genetic AlgorithmsMutationMutation
1011011111
1010000000
Offspring1
Offspring2
1011001111
1000000000
Offspring1
Offspring2
With some small probability (the mutation rate) flip each bit in the offspring (typical values between 0.1
and 0.001)
mutate
Original offspring Mutated offspring
![Page 111: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/111.jpg)
111
Genetic Algorithms GA is an iterative process and can be described as
follows:
Iterative process
Start with an initial population of “solutions” (think: chromosomes)
Evaluate fitness of solutions
Allow for evolution of new (and potentially better) solution populations
E.g., via “crossover,” “mutation”
Stop when “optimality” criteria are satisfied
![Page 112: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/112.jpg)
112
Genetic Algorithms
Algorithm:
1. Initialize population with p Individuals at random
2. For each Individual h compute its fitness
3. While max fitness < threshold do Create a new generation Ps
4. Return the Individual with highest fitness
![Page 113: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/113.jpg)
113
Genetic Algorithms
Create a new generation Ps:
1. Select (1-r)p members of P and add them to Ps. The probability of selecting a member is as follows:
P(hi) = Fitness (hi) / Σj Fitness (hj)
2. Crossover: select rp/2 pairs of hypotheses from P according to P(hi).
For each pair (h1,h2) produce two offspring by applying the Crossover operator. Add all offspring to Ps.
3. Mutate: Choose mp members of Ps with uniform probability. Invert one bit in the representation randomly.
4. Update P with Ps5. Evaluate: for each h compute its fitness.
![Page 114: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/114.jpg)
114
Stochastic Search: Genetic Algorithms
![Page 115: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/115.jpg)
115
Genetic Algorithms
Cost
States
![Page 116: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/116.jpg)
116
Genetic Algorithms
Mutation
Cross-Over
![Page 117: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/117.jpg)
117
Genetic Algorithms
![Page 118: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/118.jpg)
118
Genetic Algorithms
![Page 119: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/119.jpg)
119
Genetic Algorithms
![Page 120: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/120.jpg)
120
Genetic Algorithms
![Page 121: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/121.jpg)
121
Genetic Algorithms
![Page 122: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/122.jpg)
122
Genetic Algorithms
![Page 123: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/123.jpg)
123
Genetic Algorithms
![Page 124: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/124.jpg)
124
Genetic Algorithms
![Page 125: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/125.jpg)
125
Genetic Algorithms
![Page 126: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/126.jpg)
126
Genetic Algorithms
![Page 127: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/127.jpg)
127
Genetic Algorithms
![Page 128: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/128.jpg)
128
Genetic Algorithms
![Page 129: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/129.jpg)
129
Genetic Algorithms
![Page 130: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/130.jpg)
130
Genetic Algorithms
![Page 131: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/131.jpg)
131
Genetic Algorithms
![Page 132: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/132.jpg)
132
Genetic Algorithms
![Page 133: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/133.jpg)
133
Genetic Algorithms
![Page 134: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/134.jpg)
Optimization Problems
Genetic programming: GP
![Page 135: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/135.jpg)
135
Genetic Programming
Genetic programming (GP)
Programming of Computersby Means of Simulated Evolution
How to Program a ComputerWithout Explicitly Telling It What to Do?
Genetic Programming is Genetic Algorithms where solutions are programs …
![Page 136: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/136.jpg)
136
Genetic programming
When the chromosome encodes an entire program or function itself this is called genetic programming (GP)
In order to make this work,encoding is often done in the form of a tree representation
Crossover entials swaping subtrees between parents
![Page 137: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/137.jpg)
137
Genetic programming
It is possible to evolve whole programs like this but only small ones. Large programs with complex functions present big problems
![Page 138: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/138.jpg)
138
Genetic programmingInter-twined Spirals: Classification Problem
Red Spiral
Blue Spiral
![Page 139: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/139.jpg)
139
Genetic programmingInter-twined Spirals: Classification Problem
![Page 140: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/140.jpg)
Optimization Problems
New AlgorithmsACO, PSO, QGA …
![Page 141: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/141.jpg)
141
Anything to be Learnt from Ant Colonies?
Fairly simple units generate complicated global behaviour.
An ant colony expresses a complex collective behavior providing intelligent solutions to problems such as:
carrying large items forming bridges finding the shortest routes from
the nest to a food source, prioritizing food sources based on their distance and ease of access.
“If we knew how an ant colony works, we might understand more about how all such systems work, from brains to ecosystems.”
(Gordon, 1999)
![Page 142: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/142.jpg)
142
Shortest path discovery
![Page 143: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/143.jpg)
143
Shortest path discovery Ants get to find the shortest path after few minutes …Ants get to find the shortest path after few minutes …
![Page 144: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/144.jpg)
144
Ant Colony Optimization Each artificial ant is a probabilistic mechanism that Each artificial ant is a probabilistic mechanism that constructs a solution to the problem, using:constructs a solution to the problem, using:
• Artificial pheromone depositionArtificial pheromone deposition• Heuristic information: pheromone trails, Heuristic information: pheromone trails, already visited cities memory …already visited cities memory …
![Page 145: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/145.jpg)
145
TSP Solved using ACO
![Page 146: Artificial Intelligence Problem solving by searching CSC 361 Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia yousef@ccis.edu.sa](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649e005503460f94ae9952/html5/thumbnails/146.jpg)
146
Summary
* Local search methods keep small number of nodes in memory.They are suitable for problems where the solution is the goal state itself and not the path.
* Hill climbing, simulated annealing and local beam search areexamples of local search algorithms.
* Stochastic algorithms represent another class of methods forinformed search. Genetic algorithms are a kind of stochastic hill-climbing search in which a large population of states is maintained. New states are generated by mutation and bycrossover which combines pairs of states from the population.