ai search - uwyo.educlan/teach/ai18/search_intro.pdfsearching for a solution is equivalent to...

56
AI Search Chao Lan

Upload: others

Post on 05-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

AI Search

Chao Lan

Page 2: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Outline

Introduction

Uninformed Search vs. Informed Search

Page 3: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Outline

Introduction

Uninformed Search vs. Informed Search

Page 4: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

IntroductionWhat is search?

What are the basic concepts in search?

What are the applications of search?

Find solution by tree search.

What is the data structure of search algorithm?

How to evaluate search algorithm?

Page 5: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

What is search?

Search is about an agent

“finding a sequence of actions to achieve its goal when no single action can do”.

We will assume a solution exists and is a fixed sequence of known actions.

Page 6: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Example: 8-Puzzle

Page 7: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Example: Vacuum Cleaner

Page 8: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Example: Route-Finding

Page 9: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

IntroductionWhat is search?

What are the basic concepts in search?

What are the applications of search?

Find solution by tree search.

What is the data structure of search algorithm?

How to evaluate search algorithm?

Page 10: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts state space: set of all states reachable from the initial state by any sequence of actions

Page 11: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts state space: set of all states reachable from the initial state by any sequence of actions

initial state: state where agent starts

Page 12: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts state space: set of all states reachable from the initial state by any sequence of actions

initial state: state where agent starts

applicable action: an action that can be taken from the current state

Page 13: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts state space: set of all states reachable from the initial state by any sequence of actions

initial state: state where agent starts

applicable action: an action that can be taken from the current state

transition model: a function mapping (current state,action) to a new state.

Page 14: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts state space: set of all states reachable from the initial state by any sequence of actions

initial state: state where agent starts

applicable action: an action that can be taken from the current state

transition model: a function mapping (current state,action) to a new state.

successor: a state reachable from a given state by a single action

Page 15: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

Page 16: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

path: a sequence of states connected by a sequence of actions

Page 17: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

path: a sequence of states connected by a sequence of actions

step cost: cost of taking an action in one state to reach another state

Page 18: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

path: a sequence of states connected by a sequence of actions

step cost: cost of taking an action in one state to reach another state

path cost: sum of step costs in the path

Page 19: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

path: a sequence of states connected by a sequence of actions

step cost: cost of taking an action in one state to reach another state

path cost: sum of step costs in the path

goal test: determine whether a given state is a goal state

Page 20: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

path: a sequence of states connected by a sequence of actions

step cost: cost of taking an action in one state to reach another state

path cost: sum of step costs in the path

goal test: determine whether a given state is a goal state

solution: a sequence of actions that leads from the initial state to a goal state

Page 21: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concepts (Cont.) graph representation of state space (node, link, cost)

path: a sequence of states connected by a sequence of actions

step cost: cost of taking an action in one state to reach another state

path cost: sum of step costs in the path

goal test: determine whether a given state is a goal state

solution: a sequence of actions that leads from the initial state to a goal state

optimal solution: a solution with the lowest path cost

Page 22: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

ConceptsAbstraction is the process of removing detail from a representation in problem formulation.

Page 23: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

IntroductionWhat is search?

What are the basic concepts in search?

What are the applications of search?

Find solution by tree search.

What is the data structure of search algorithm?

How to evaluate search algorithm?

Page 24: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Route-Finding Problem

Page 25: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Touring Problem

Visit each city at least once, and travel back to Arad.

Page 26: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Touring Problem

Visit each city at least once, and travel back to Arad.

Traveling Salesperson Problem

Visit each city exactly once, and travel back to Arad, with the shortest path.

Page 27: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

VLSI Layout Problem

Position millions of components

and connections on a chip to

minimize area, circuit delays, stray

capacitances, and maximize

manufacturing yield.

Page 28: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Robot Navigation

Agent can move in a continuous

space with an infinite set of

possible actions and states.

(Route-finding problem focuses on

discrete space with a finite set of

possible actions and states.)

Page 29: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Automatic Assembly Sequencing

Find an order to assemble

different parts of some object.

Page 30: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

IntroductionWhat is search?

What are the basic concepts in search?

What are the applications of search?

Find solution by tree search.

What is the data structure of search algorithm?

How to evaluate search algorithm?

Page 31: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Find Solution by Search Tree

Searching for a solution is equivalent to searching in a tree (or, generating a tree).

Page 32: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Find Solution by Search Tree

Page 33: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Find Solution by Search Tree

Page 34: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Find Solution by Search Tree

Page 35: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

A frontier is a list of nodes to be expanded, e.g. {Sibiu, Timisoara, Zerind}.

Concept: Frontier

Page 36: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Avoid Repeated State and Loopy Path

Avoid repeated state and loopy path by maintaining a closed set.

Page 37: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

IntroductionWhat is search?

What are the basic concepts in search?

What are the applications of search?

Find solution by tree search.

What is the data structure of search algorithm?

How to evaluate search algorithm?

Page 38: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Several concepts in this section are from data structure (COSC3020)...

Page 39: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Concept Review

Node

Edge

Parent Node

Child Node

Root Node

Leaf Node

Page 40: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

A node contains four components

1. state: state of current node

2. parent node: state of parent node

3. action: action applied to the parent to generate the node

4. path-cost: cost of path from initial state to the node

Data Structure of a Node

Page 41: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

The circled node has

1. State =

2. parent node =

3. action =

4. path-cost =

Example

Page 42: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

The circled node has

1. State = Sibiu

2. parent node = Arad

3. action = turn east

4. path-cost = 140

Example

Page 43: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

The circled node has

1. State =

2. parent node =

3. action =

4. path-cost =

Example 2

Page 44: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

The circled node has

1. State = Fagaras

2. parent node = Sibiu

3. action = turn east

4. path-cost = 239

Example 2

Page 45: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., Q = (Arad, Sibiu, Fagaras).

Data Structure to Store Nodes

Page 46: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., Q = (Arad, Sibiu, Fagaras).

Three queue operations

- empty: return true if there is no node in the queue

- pop: return the first node in the queue, then remove it from the queue

- insert: insert a node to the queue, then return the resulting queue

Data Structure to Store Nodes

Q: what is empty(Q)?

Page 47: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., Q = (Arad, Sibiu, Fagaras).

Three queue operations

- empty: return true if there is no node in the queue

- pop: return the first node in the queue, then remove it from the queue

- insert: insert a node to the queue, then return the resulting queue

Data Structure to Store Nodes

Q: what is empty(Q)? False.

Q: what is pop(Q)?

Page 48: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., Q = (Arad, Sibiu, Fagaras).

Three queue operations

- empty: return true if there is no node in the queue

- pop: return the first node in the queue, then remove it from the queue

- insert: insert a node to the queue, then return the resulting queue

Data Structure to Store Nodes

Q: what is empty(Q)? False.

Q: what is pop(Q)? Arad.

Q: what is insert(Zerind)?

Page 49: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., Q = (Arad, Sibiu, Fagaras).

Three queue operations

- empty: return true if there is no node in the queue

- pop: return the first node in the queue, then remove it from the queue

- insert: insert a node to the queue, then return the resulting queue

Data Structure to Store Nodes

Q: what is empty(Q)? False.

Q: what is pop(Q)? Arad.

Q: what is insert(Zerind)? Q = (Arad, Sibiu, Fagaras, Zerind)

Page 50: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., (Arad, Sibiu, Fagaras).

Three queue operations

- empty: return true if there is no node in the queue

- pop: return the first node in the queue, then remove it from the queue

- insert: insert a node to the queue, then return the resulting queue

Three types of queue

- FIFO (First-In-First-Out): pop the oldest node in the queue

- LIFO (Last-In-First-Out): pop the newest node in the queue

- Priority: pop node with the highest priority in the queue

Data Structure to Store Nodes

Page 51: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Nodes are stored in a queue, e.g., (Arad, Sibiu, Fagaras).

Three queue operations

- empty: return true if there is no node in the queue

- pop: return the first node in the queue, then remove it from the queue

- insert: insert a node to the queue, then return the resulting queue

Three types of queue

- FIFO (First-In-First-Out): pop the oldest node in the queue

- LIFO (Last-In-First-Out): pop the newest node in the queue

- Priority: pop node with the highest priority in the queue

Data Structure to Store Nodes

Q: what is pop(Q) if FIFO?

Q: what is pop(Q) if LIFO?

Q: what about pop(Q) if priority?

Page 52: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

IntroductionWhat is search?

What are the basic concepts in search?

What are the applications of search?

Find solution by tree search.

What is the data structure of search algorithm?

How to evaluate search algorithm?

Page 53: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Four metrics to evaluate a search algorithm

1. Completeness: is the algorithm guaranteed to find a solution (if it exists)?

2. Optimality: does the algorithm find the optimal solution?

3. Time Complexity: how long does it take to find a solution?

4. Space Complexity: how much memory is needed to perform search?

Evaluate Search Algorithm

Page 54: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Is the following search algorithm complete?

Example

Search Algorithm 1 - always turn left

Page 55: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Is the following search algorithm complete?

Example

Search Algorithm 1 - always turn left (not complete)

Page 56: AI Search - uwyo.educlan/teach/ai18/search_intro.pdfSearching for a solution is equivalent to searching in a tree (or, generating a tree). Find Solution by Search Tree A frontier is

Complexities of a search algorithm are often measure indirectly, e.g.,

- branching factor (# successors), depth, maximum length

- # nodes |V| + # edges |E|

- time = # generated nodes

- space = # stored nodes

Complexities of Search Algorithm