0% found this document useful (0 votes)
26 views

L6&7 - 2022

Hill climbing search is an informed search algorithm that aims to find an optimal solution by iteratively moving to a neighbor of the current state that has the best heuristic value. It is fast but can get stuck in local optima. The document provides examples of applying hill climbing search to solve the 8-puzzle problem, demonstrating how it iteratively moves the puzzle tiles to reduce the misplaced tile count until reaching the goal state or getting stuck. It also compares different search techniques and discusses A* search, which combines the completeness of uniform cost search and the optimality of best-first search using an evaluation function of path cost plus heuristic estimate.

Uploaded by

zzselimahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

L6&7 - 2022

Hill climbing search is an informed search algorithm that aims to find an optimal solution by iteratively moving to a neighbor of the current state that has the best heuristic value. It is fast but can get stuck in local optima. The document provides examples of applying hill climbing search to solve the 8-puzzle problem, demonstrating how it iteratively moves the puzzle tiles to reduce the misplaced tile count until reaching the goal state or getting stuck. It also compares different search techniques and discusses A* search, which combines the completeness of uniform cost search and the optimality of best-first search using an evaluation function of path cost plus heuristic estimate.

Uploaded by

zzselimahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

INTRO TO ARTIFICIAL INTELLIGENCE

SEARCH
AHMED EZZAT LABIB
HELWAN UNIVERSITY
HILL CLIMBING SEARCH

• QUEUEINGFN IS SORT-BY-H
• ONLY KEEP LOWEST-H STATE ON OPEN LIST

• BEST-FIRST SEARCH IS TENTATIVE (NOT CERTAIN OR FIXED)


• HILL CLIMBING IS IRREVOCABLE (NOT ABLE TO BE CHANGED; FINAL)
• FEATURES
• MUCH FASTER
• LESS MEMORY
• DEPENDENT UPON H(N)
• IF BAD H(N), MAY PRUNE AWAY ALL GOALS
• NOT COMPLETE
EXAMPLE
EXAMPLE
HILL CLIMBING – THE 8-PUZZLE PROBLEM
A 3 1 2 1 2
h=5 4 5 8 3 4 5
6 7 6 7 8
Goal State
h is the number of incorrect
positions (or the misplaced
tiles) in the puzzle

Path = { }
Open = {(A, 5)}
Current = {A}
HILL CLIMBING – EXAMPLE 1 2
A 3 1 2 3 4 5
h=5 4 5 8 6 7 8
6 7 Goal State
B C D
3 1 2 3 1 2 3 1 2
h=6 4 5 8 h=5 4 8 h=4 4 5 8
6 7 6 5 7 6 7

Path = {A}
Open = {(D, 4), (B, 6), (C, 5)}
Current = {D}
HILL CLIMBING – EXAMPLE 1 2
A 3 1 2 3 4 5
h=5 4 5 8 6 7 8
6 7 Goal State
B C D
3 1 2 3 1 2 3 1 2
h=6 4 5 8 h=5 4 8 h=4 4 5 8
6 7 6 5 7 6 7
E F
3 1 2 3 1 2
Path = {A, D} h=3 4 5 h=5 4 5 8
Open = {(E, 3), (F, 5)} 6 7 8 6 7
Current = {E}
HILL CLIMBING – EXAMPLE 1 2
A 3 1 2 3 4 5
h=5 4 5 8 6 7 8
6 7 Goal State
B C D
3 1 2 3 1 2 3 1 2
h=6 4 5 8 h=5 4 8 h=4 4 5 8
6 7 6 5 7 6 7
E F
3 1 2 3 1 2
Path = {A, D, E} h=3 4 5 h=5 4 5 8
Open = {(H, 2), (G, 4) , (I, 4)} 6 7 8 6 7
Current = {H}
G H I
3 1 3 1 2 3 1 2
h=4 4 5 2 h=2 4 5 h=4 4 5 8
6 7 8 6 7 8 6 7
1 2
HILL CLIMBING – EXAMPLE 3 4 5
G H I 6 7 8
3 1 3 1 2 3 1 2 Goal State
h=4 4 5 2 h=2 4 5 h=4 4 5 8
6 7 8 6 7 8 6 7

h=3 J h=1 K h=3 L M h=3


3 1 2 3 1 2 3 2 3 1 2
4 5 4 5 4 1 5 4 7 5
6 7 8 6 7 8 6 7 8 6 8

Path = {A, D, E, H}
Open = {(K, 1), (J, 3) , (L, 3) , (M, 3)}
Current = {K}
HILL CLIMBING – EXAMPLE
G H I
3 1 3 1 2 3 1 2
h=4 4 5 2 h=2 4 5 h=4 4 5 8
6 7 8 6 7 8 6 7

h=3 J h=1 K h=3 L M h=3


3 1 2 3 1 2 3 2 3 1 2
4 5 4 5 4 1 5 4 7 5
6 7 8 6 7 8 6 7 8 6 8

h=2 N h=0 O P h=2


3 1 2 1 2 3 1 2 Path = {A, D, E, H, K}
6 4 5 3 4 5 4 5 Open = {(O, 0), (N, 2) , (P, 2)}
7 8 6 7 8 6 7 8 Current = {O}
Goal State Goal State
HILL CLIMBING SEARCH

• YOU CAN READ HILL CLIMBING SEARCH FROM ANY


TEXT BOOK
• YOU CAN SEARCH ABOUT HILL CLIMBING SEARCH
WITH ANOTHER EXAMPLE (THE 4-QUEEN OR 8-QUEEN
PROBLEM)
• YOU CAN SEARCH FOR ANY VIDEO THAT TALK ABOUT
HILL CLIMBING SEARCH WITH THE 8-PUZZLE PROBLEM
FOR MORE DESCRIPTION.
COMPARISON OF SEARCH TECHNIQUES

DFS BFS UCS IDS Best HC


Complete N Y Y Y N N
Optimal N N Y N N N
Heuristic N N N N Y Y
Time bm bd+1 bm bd bm mn
Space bm bd+1 bm bd bm b
INFORMED SEARCH – A*

• IDEA: AVOID EXPANDING PATHS THAT ARE ALREADY EXPENSIVE


• EVALUATION FUNCTION F(N) = G(N) + H(N)
• G(N) = COST SO FAR TO REACH N
• H(N) = ESTIMATED COST FROM N TO GOAL
• F(N) = ESTIMATED TOTAL COST OF PATH THROUGH N TO GOAL
• BEST FIRST SEARCH HAS F(N)=H(N)
• UNIFORM COST SEARCH HAS F(N)=G(N)
INFORMED SEARCH – A*

• QUEUEINGFN IS SORT-BY-F ( F(N) = G(N) + H(N) )

• NOTE THAT UCS AND BEST-FIRST BOTH IMPROVE SEARCH


• UCS KEEPS SOLUTION COST LOW
• BEST-FIRST HELPS FIND SOLUTION QUICKLY

• A* COMBINES THESE APPROACHES


A* – EXAMPLE
A* – EXAMPLE
A* – EXAMPLE
A* – EXAMPLE
A* – EXAMPLE
A* – EXAMPLE
A* – EXAMPLE
A* – EXAMPLE
A* SEARCH – EXAMPLE 2
g(n)=0

23
A* SEARCH – EXAMPLE 2

g(n)=0+140 g(n)=0+118 g(n)=0+75


A* SEARCH – EXAMPLE 2
g(n)=140

g(n)=140+140
g(n)=140+80

g(n)=140+99 g(n)=140+151

25
A* SEARCH – EXAMPLE 2

g(n)=0+140
g(n)=220

g(n)=140+99

g(n)=220+146 g(n)=220+97 g(n)=220+80


A* SEARCH – EXAMPLE 2

g(n)=239
g(n)=220

g(n)=220+80

g(n)=239+211 g(n)=220+146 g(n)=220+97

27
A* SEARCH – EXAMPLE 2

g(n)=317

g(n)=317+101
g(n)=317+138

28
A* SEARCH

• YOU CAN READ A* SEARCH FROM $1< TEXT BOOK

• YOU CAN SEARCH FOR ANY VIDEO THAT TALK ABOUT


A* SEARCH FOR MORE DESCRIPTION.
COMPARISON OF SEARCH TECHNIQUES

DFS BFS UCS IDS Best HC Beam A*

Complete N Y Y Y N N N Y

Optimal N N Y N N N N Y

Heuristic N N N N Y Y Y Y

Time bm bd+1 bm bd bm bm nm bm
Space bm bd+1 bm bd bm b bn bm
PROBLEM – HILL CLIMBING SEARCH
• CONSIDER THE INITIAL STATE OF THE 4-QUEENS PROBLEM SHOWN BELOW.
• Consider the hill-climbing with number of conflicts heuristic
to find a valid state of the 4-queens problem.
• The heuristic value of a state is the number of distinct
queen pairs that can attack each other.
• The successors of a state are all possible states generated
by moving a single queen to another square in the same
column.
• Hill-climbing would at each step take the successor with
the smallest number of conflicts.
• DRAW THE TREE OF STATES THAT HILL-CLIMBING USING THE MINIMUM CONFLICT HEURISTIC EXPLORES
FROM THE INITIAL STATE TO ALL POSSIBLE EXPLORATION PATHS OF HILL-CLIMBING.
• ALSO WRITE THE OPEN LIST FOR THIS PROBLEM.

• DEADLINE: 11/11/2023 - THE REPORT MUST BE IN A HAND WRITTEN FORMAT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy