You are on page 1of 14

Artificial Intelligence

Informed Search

Gloria Virginia & Matahari Bhakti Nendya

DWCU, Genap 2019/2020

Uninformed Search
• = Blind Search = Naive search
• They are given no information other than its definition
• A class of general purpose search algorithm that operate in a brute-
force way

• Some algorithms:
1. Generate and Test 5. Non-Deterministic Search
2. Random search 6. Depth-Limited Search (DLS)
3. Depth first search (DFS) 7. Iterative Deepening Search (IDS)
4. Breadth first search (BFS) 8. Bidirectional Search (BIDI)

2
Informed Search
• Heuristic Search
➡ Methods that use a heuristic function to provide specific
knowledge about the problem that helps narrow or focus the
search process
➡ Using problem-specific knowledge
➡ Widely used in optimization problem

• Heuristic (Greek)
– To discover
– A rule of thumbs, hint, or trick that may help solve a given problem
– It takes problem knowledge into consideration to help guide the
search within the domain

• It is used to further improve the quality of previous method (blind


search)

Heuristic Function

• It is a problem-specific knowledge of the problem

• Heuristic function:
– f : state T à number x
– f(T) : expresses the quality of state T
– f(T) = x

• (+) : for good heuristic function, the search may expand much
less nodes
• (-) : the cost of computing such functions may be high

4
Example of Heuristic Function
A B C
• Problem:
finding a route S
on a road map G

D E F

• f1(T) = the_distance_between_two_nodes

A
4 B
4 C
3 • SABEFG = 19
S
5 5 • SADEFG = 17
G • SDEFG = 13
2 3
4 D E
4 F

Example of Heuristic Function (2)


A B C
• Problem:
finding a route S
on a road map G

D E F

• f2(T) = the_straight_line_distance_from_T_to_G

A 10.4 B 6.7 C

11 4 The
S
G estimation
8.9
3 can be wrong!
D E 6.9 F

6
Example of Heuristic Function (3)
A B C
• Problem:
finding a route S
on a road map G

D E F

• f3(T) = f1(T) + f2(T)

• f1(T) = the_distance_between_two_nodes

• f2(T) = the_straight_line_distance_from_T_to_G

Example of Heuristic Function (4)


f1(T) = the_distance_between_two_ f2(T) = the_straight_line_distance_
nodes from_T_to_G

4 4 10.4
A B C A B 6.7 C
3
4
5 5 S 11
G G
3 8.9
2 4 3
4 D E F D E 6.9 F

• f3(T) = f1(T) + f2(T)

• f3(A) = f1(A) + f2(A) = 3 + 10.4 = 13.4 (in SADEFG)

• f3(E) = f1(E) + f2(E) = 2 + 6.9 = 8.9 (in SDEFG)

8
Examples of Heuristic Search
1. Generate and Test
2. Simple Hill Climbing
3. Steepest Ascent Hill Climbing
4. Best First Search
5. A* & SMA* (Simplified Memory Bounded A*)
6. Minimax
7. Alpha Beta Prunning
8. Simulated Annealing
9. Genetic Algorithm
10. Ant Algorithm

Generate and Test


• Generate all alternatives solutions
➡ Depth first search + backtracking
• Test value à ‘yes’ or ‘no’

• Algorithm:
1. Generate all alternative solutions
2. Compare all alternative solutions
3. Choose the optimal solution

10
Generate and Test (2)
• Example: Traveling Salesman Problem (TSP)
➡ Given a list of cities and the distances between each pair of cities,
what is the shortest possible route that visits each city exactly once
and returns to the origin city?

• f(T) = the_distance_between_two_nodes

8
A B
3 4

7 5

D C
6

11

Hill Climbing
• Depth first search + heuristic
• Backtracking is not allowed

• Idea:
- start with an alternative of solution
➡ start at the base of a hill
- repeatedly improve the solution
➡ walk up the hill
- until some condition is maximized
➡ until the top of the hill is reached

12
Hill Climbing: Global & Local Max

13

Hill Climbing (2)

• “Iterative movement” method:


‣ Start at a random configuration
‣ Repeatedly consider various moves
‣ Accept some & reject some
‣ When you’re stuck restart

• moveset: moves we’ll consider from any configuration

14
Hill Climbing: Global & Local Max (2)

15

Hill Climbing: Algorithm


• Algorithm:
- Attempt to
maximize Eval(X)
by moving to the
highest
configuration in
our moveset
- If they’re all
lower, we’re stuck
at a “local
optimum”

Andrew W. Moore, School of Computer Science, Carnegie Mellon University.


http://www.autonlab.org/tutorials/

16
Hill Climbing: Types
• Types:
1. Simple Hill Climbing
2. Steepest Ascent Hill Climbing

• Example:
• Traveling Salesman Problem (TSP) à 4 cities

8
A B
3 4

7 5

D C
6
17

Hill Climbing: Example


• Example:
• Traveling Salesman Problem (TSP) à 4 cities

• Operator:
– To switch the position of solution composition

– Number of operator:

– Operators:
1.Switch 1,2 4.Switch 4,1
Combination:
2.Switch 2,3 5.Switch 2,4
6.Switch 1,3 Order does NOT matter
3.Switch 3,4

18
Simple Hill Climbing
• Procedure:
1. Generate all nodes based on the operator
2. Omit the node that has generated before
3. Chose the node that is better than the previous one

8 Operators:
A B
1.Switch 1,2
3 4 2.Switch 2,3
3.Switch 3,4
7 5 4.Switch 4,1
5.Switch 2,4
6.Switch 1,3
D C
6

19

Simple Hill Climbing (2)


• Procedure:
1. Generate a node based on the operator
2. Omit the node that has generated before
3. Chose the node that is better than the previous one

8 Operators:
A B
1.Switch 1,2
3 4 2.Switch 2,3
3.Switch 3,4
7 5 4.Switch 4,1
5.Switch 2,4
6.Switch 1,3
D C
6

20
Steepest Ascent Hill Climbing
• Procedure:
1. Generate all nodes based on the operator
2. Omit the node that has generated before
3. Chose the best node

8 Operators:
A B
1.Switch 1,2
3 4 2.Switch 2,3
3.Switch 3,4
7 5 4.Switch 4,1
5.Switch 2,4
6.Switch 1,3
D C
6

21

Best First Search

• Greedy search: always expand the heuristically best


node first

• At each step, select the best node with the best value
heuristically, then expand it

• Backtracking is allowed

22
Best First Search (2)

1. QUEUE <-- path only containing the root

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


create new paths (to all children);
reject the new paths with loops;
add the new paths to front of QUEUE and sort it;

3. IF goal reached THEN success ELSE failure

23

Best First Search (3)


• Example Problem: finding a route on a road map
➡ f1(T) = the_distance_between_two_nodes
➡ f2(T) = the_accumulated_distance_from_initial_state_(S)_to_
node_T

• Note: the best heuristically value is the lowest value


4 4
3 A B C

S 5 5
3 G
4 2 4
D E F

24
f1(x) = distance cost Example 1
S
Route: SDEFG
3 4

A D
4 5 5 2

B D A E
4 5 4 4
2 5
C E E B B F

2 4 5 4 4 5 4 4 3

D F B F C E A C G

3 4 3 4 Goal
(End)
G C G F

25

f2(x) = accumulated cost Example 2


S
Route: SDEFG
3 4

A D
7 8 9 6

B D A E
11 10 13 10
12 11
C E E B B F

14 15 14 17 18 15 15 13
16
D F B F C E A C G

19 19 17 Goal
22 (End)
G C G F

25
G
26

26
Best First Search (4)
• Route = SDEFG (13)

4 4
3 A B C

S 5 5
3 G
4 2 4
D E F

à The Best First Search did find the optimal route!

27

You might also like