Top Banner
Artificial Intelligence (part 4b) Exhaustive Search Algorithm (Exhaustive ..Uninformed..Blind search)
46

TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Apr 10, 2018

Download

Documents

dokiet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Artificial Intelligence(part 4b)

Exhaustive Search Algorithm(Exhaustive ..Uninformed..Blind search)

Page 2: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Course ContentsAgain..Selected topics for our course. Covering all of AI is impossible!

Key topics include:Introduction to Artificial Intelligence (AI) Knowledge Representation and SearchIntroduction to AI ProgrammingProblem Solving Using SearchExhaustive Search AlgorithmHeuristic SearchTechniques and Mechanisms of Search AlgorithmKnowledge Representation Issues and ConceptsStrong Method Problem SolvingReasoning in Uncertain SituationsSoft Computing and Machine Learning

Page 3: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Selection of a Search Strategy

most of the effort is often spent on the selection of an appropriate search strategy for a given problem

uninformed search (blind..exhaustive search)

number of steps, path cost unknown

knows when it reaches a goal

informed search (heuristic search)

has background information about the problem

map, costs of actions

Page 4: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Search Strategies (The Order..)

Uninformed Search

breadth-first

depth-first

iterative deepening

uniform-cost search

depth-limited search

bi-directional search

constraint satisfaction

Informed Search

best-first search

search with heuristics

memory-bounded search

iterative improvement search

Page 5: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Graph for breadth- and depth-first search examples.

HOW? BREADTH-FIRST? HOW? DEPTH-FIRST?

Page 6: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

all the nodes reachable from the current node are explored first

achieved by the TREE-SEARCH method by appending newly generated nodes at the end of the search queue

function BREADTH-FIRST-SEARCH(problem) returns solution

return TREE-SEARCH(problem, FIFO-QUEUE())

Breadth-First

b branching factor

d depth of the tree

Time Complexity bd+1

Space Complexity bd+1

Completeness yes (for finite b)

Optimality yes (for non-negative

path costs) Solution is found

Page 7: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Function

breadth_

first

search

algorithm

Page 8: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

breadth-first search

• States on open and closed are highlighted.

• Explore level by level• Use list open ~ NSL in backtrack – states not yet evaluated

• Use list close ~ SL and DE in backtrack –states already evaluated

• Which state is removed from open determines the order of search- BFS adds at the

right list and removes from the left (queue-FIFO)

Page 9: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-first search of the 8-puzzle, showing

order in which states were

removed from open.

Page 10: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Function depth_first_search algorithm and the trace

Page 11: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Depth-first search (DFS)

• States on open and closed are highlighted.

• Child and descendents are evaluated before siblings

• Goes deeper into search space whenever possible• Which state is removed from open determines the order of search- DFS adds and

removes from the left end (stack-LIFO)

Page 12: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Depth-first search of the 8-puzzle with a

depth bound of 5.

Page 13: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 1InitialVisitedFringeCurrentVisibleGoal

1

2 3

Fringe: [] + [2,3]

Page 14: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 2InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5

Fringe: [3] + [4,5]

Page 15: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 3InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

Fringe: [4,5] + [6,7]

Page 16: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 4InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9

Fringe: [5,6,7] + [8,9]

Page 17: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 5InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11

Fringe: [6,7,8,9] + [10,11]

Page 18: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 6InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13

Fringe: [7,8,9,10,11] + [12,13]

Page 19: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 7InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

Fringe: [8,9.10,11,12,13] + [14,15]

Page 20: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 8InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17

Fringe: [9,10,11,12,13,14,15] + [16,17]

Page 21: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 9InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19

Fringe: [10,11,12,13,14,15,16,17] + [18,19]

Page 22: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 10InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21

Fringe: [11,12,13,14,15,16,17,18,19] + [20,21]

Page 23: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 11InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23

Fringe: [12, 13, 14, 15, 16, 17, 18, 19, 20, 21] + [22,23]

Page 24: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 12InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25

Fringe: [13,14,15,16,17,18,19,20,21] + [22,23]

Note:

The goal node

is “visible”

here, but we can

not perform the

goal test yet.

Page 25: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 13InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27

Fringe: [14,15,16,17,18,19,20,21,22,23,24,25] + [26,27]

Page 26: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 14InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29

Fringe: [15,16,17,18,19,20,21,22,23,24,25,26,27] + [28,29]

Page 27: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 15InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] + [30,31]

Page 28: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 17InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [18,19,20,21,22,23,24,25,26,27,28,29,30,31]

Page 29: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 18InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [19,20,21,22,23,24,25,26,27,28,29,30,31]

Page 30: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 19InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [20,21,22,23,24,25,26,27,28,29,30,31]

Page 31: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 20InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [21,22,23,24,25,26,27,28,29,30,31]

Page 32: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 21InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [22,23,24,25,26,27,28,29,30,31]

Page 33: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 22InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [23,24,25,26,27,28,29,30,31]

Page 34: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 23InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [24,25,26,27,28,29,30,31]

Page 35: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Breadth-First Snapshot 24InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [25,26,27,28,29,30,31]

Note:

The goal test is

positive for this

node, and a

solution is

found in 24

steps.

Page 36: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Depth-First Snapshot

InitialVisitedFringeCurrentVisibleGoal

1

2 3

4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Fringe: [3] + [22,23]

Page 37: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Depth-First vs. Breadth-First

depth-first goes off into one branch until it reaches a leaf node

not good if the goal is on another branch

neither complete nor optimal

uses much less space than breadth-first

much fewer visited nodes to keep track of

smaller fringe

breadth-first is more careful by checking all alternatives

complete and optimal

under most circumstances

BUT ..very memory-intensive !!

Page 38: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Using State Space to Represent Reasoning..with predicate calculus

Predicate calculus – map nodes/some states of a graph onto state space

Inference rules – describe the arc between states

Eg. Is expression a logical consequence of given assertion? Use search to solve

Guarantee correctness of conclusion derived- a formal proof of integrity of solution

Page 39: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

eg. define a graph from propositional calculus- to view the logical relationships.

•State space graph of a set of implications in the propositional calculus.•Reasoning:- How to infer p using moden ponens?

s , s ->r yields r

r , r->p yields p

Translate into

graph??

Page 40: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

And/or graph

To represent logical operators AND and OR in predic.calculus

• extension of basic graph model known as and/or graph

•To differ the relationships graphically, curve link indicates operator AND.

q r p q r p

Page 41: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

HYPERGRAPH

AND/OR graph is a specialization of a type of graph known as hypergraph, which connects nodes by sets of arcs rather than a single arcs

Page 42: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

eg. And/or graph of a set of propositional calculus expressions.

Draw the and/or graph

Page 43: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

More eg…And/or graph of part of the state space for integrating a function, from

Nilsson (1971).

Page 44: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

More eg…Where is Fred??..The facts and rules of this example are given as

English sentences followed by their predicate calculus equivalents:

Page 45: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

Where is Fred???..The solution subgraph showing that fred is at the museum.

Page 46: TOPIC 4 (Part b) Strategies for State Space Search ... AI/AI_Part04b... · Knowledge Representation and Search Introduction to AI Programming ... Search Strategies ... TOPIC 4 (Part

More

eg…

FIN

AN

CIA

L A

DVIS

OR…

And/o

r gra

ph

search

ed b

y th

e fin

ancia

l adviso

r.