Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 2: Search 1.

Similar documents
Problem solving and search

Artificial Intelligence: Search Part 1: Uninformed graph search

Problem solving and search

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search

Reminders. Problem solving and search. Problem-solving agents. Outline. Assignment 0 due 5pm today

Problem solving and search

Problem solving and search

Problem solving by search

Planning and search. Lecture 1: Introduction and Revision of Search. Lecture 1: Introduction and Revision of Search 1

CS:4420 Artificial Intelligence

Problem-solving agents. Problem solving and search. Example: Romania. Reminders. Example: Romania. Outline. Chapter 3

Problem solving and search

Outline. Problem solving and search. Problem-solving agents. Example: Romania. Example: Romania. Problem types. Problem-solving agents.

Problem solving and search

Problem solving and search

Problem Solving and Search. Chapter 3

Artificial Intelligence

Artificial Intelligence Problem Solving and Uninformed Search

Multiagent Systems Problem Solving and Uninformed Search

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

4. Solving Problems by Searching

Problem-solving agents. Solving Problems by Searching. Outline. Example: Romania. Chapter 3

Outline. Solving problems by searching. Prologue. Example: Romania. Uninformed search

Solving problems by searching

Robot Programming with Lisp

CS486/686 Lecture Slides (c) 2015 P.Poupart

CS486/686 Lecture Slides (c) 2014 P.Poupart

Solving Problems by Searching

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 3: Search 2.

Artificial Intelligence

AGENTS AND ENVIRONMENTS. What is AI in reality?

KI-Programmierung. Basic Search Algorithms

Solving problems by searching

CS 8520: Artificial Intelligence

AGENTS AND ENVIRONMENTS. What is AI in reality?

Artificial Intelligence

Outline. Solving Problems by Searching. Introduction. Problem-solving agents

Solving Problems by Searching. AIMA Sections , 3.6

CS 380: Artificial Intelligence Lecture #3

Solving problems by searching. Chapter 3

Introduction to Artificial Intelligence. Informed Search

Outline. Solving problems by searching. Problem-solving agents. Example: Romania

Chapter 2. Blind Search 8/19/2017

Solving Problem by Searching. Chapter 3

Informed search algorithms

AI: problem solving and search

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Informed search algorithms. Chapter 4, Sections 1 2 1

Artificial Intelligence: Search Part 2: Heuristic search

CS:4420 Artificial Intelligence

ITCS 6150 Intelligent Systems. Lecture 3 Uninformed Searches

Uninformed Search strategies. AIMA sections 3.4,3.5

Seminar: Search and Optimization

COSC343: Artificial Intelligence

Solving problems by searching

A2 Uninformed Search

Example: The 8-puzzle. A2 Uninformed Search. It can be generalized to 15-puzzle, 24-puzzle, or. (n 2 1)-puzzle for n 6. Department of Computer Science

Solving problems by searching

Solving Problems by Searching

Solving Problems by Searching

Planning, Execution & Learning 1. Heuristic Search Planning

Solving Problems using Search

Artificial Intelligence Uninformed search

Solving problems by searching

Artificial Intelligence. Informed search methods

Outline. Informed search algorithms. Best-first search. Review: Tree search. A search Heuristics. Chapter 4, Sections 1 2 4

Overview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

PEAS: Medical diagnosis system

COMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,

Informed search algorithms

Searching and NetLogo

Search. Intelligent agents. Problem-solving. Problem-solving agents. Road map of Romania. The components of a problem. that will take me to the goal!

Informed Search and Exploration

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Informed Search and Exploration

Artificial Intelligence

Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu. Blind Searches

TDT4136 Logic and Reasoning Systems

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

Informed Search and Exploration

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

CS-E4800 Artificial Intelligence

Informed Search. Topics. Review: Tree Search. What is Informed Search? Best-First Search

Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,

Informed search algorithms

Uninformed Search. Problem-solving agents. Tree search algorithms. Single-State Problems

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

ARTIFICIAL INTELLIGENCE (CSC9YE ) LECTURES 2 AND 3: PROBLEM SOLVING

Problem Solving and Search

Informed Search Algorithms. Chapter 4

Chapter 3 Solving problems by searching

CS414-Artificial Intelligence

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Set 2: State-spaces and Uninformed Search. ICS 271 Fall 2015 Kalev Kask

Solving Problems: Blind Search

Pengju XJTU 2016

Lecture Plan. Best-first search Greedy search A* search Designing heuristics. Hill-climbing. 1 Informed search strategies. Informed strategies

Transcription:

rtificial Intelligence, S, Nanjing University Spring, 2018, Yang Yu Lecture 2: Search 1 http://lamda.nju.edu.cn/yuy/course_ai18.ashx

Problem in the lecture 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State

gent that searches a world is a set of states we first consider a world using atomic representation atomic representation: state is the basic unit states that can be factored will be considered later the big O representation: e.g. O(n) NP-hardness and NP-completness

Example: Romania On holiday in Romania; currently in rad. Flight leaves tomorrow from ucharest Formulate goal: be in ucharest Formulate problem: states: various cities actions: drive between cities Find solution: sequence of cities, e.g., rad, Sibiu, Fagaras, ucharest

Example: Romania map: 71 Oradea Neamt Zerind 75 rad 140 118 Timisoara 111 70 75 Dobreta 151 Sibiu 99 Fagaras 80 Rimnicu Vilcea Lugoj Mehadia 120 Pitesti 211 97 146 101 85 138 ucharest raiova 90 Giurgiu 87 Iasi 92 142 98 Urziceni Vaslui Hirsova 86 Eforie

Problems problem is defined by 5 components: initial state possible actions (and state associated actions) transition model taking an action will cause a state change goal test judge if the goal state is found path cost constitute the cost of a solution

Problems Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind rad Timisoara Lugoj Mehadia Dobreta raiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea ucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 state transition cost goal initial state actions

Problems initial state Oradea 71 Neamt 75 Zerind 87 151 Iasi rad 140 Sibiu 99 Fagaras 92 118 80 Timisoara Rimnicu Vilcea 111 142 Lugoj Pitesti 211 97 70 98 Mehadia 146 101 85 Urziceni 75 138 ucharest Dobreta 120 90 raiova Giurgiu e.g., at rad Vaslui Hirsova 86 Eforie successor function S(x) = set of action state pairs e.g., S(rad) = { rad Zerind, Zerind,...} <-- transition goal test, can be explicit, e.g., x = at ucharest implicit, e.g., N odirt(x) path cost (additive) e.g., sum of distances, number of actions executed, etc. c(x, a, y) is the step cost, assumed to be 0 solution is a sequence of actions leading from the initial state to a goal state

Problems we assume observable states (a seen state is accurate) in partial observable case, states are not accurate discrete states there are also continuous state spaces deterministic transition there could be stochastic transitions

Example: vacuum world R L S S S S R L R L R L S S S S L L L L R R R R states??: integer dirt and robot locations (ignore dirt amounts etc.) actions??: Left, Right, Suck, NoOp goal test??: no dirt path cost??: 1 per action (0 for NoOp)

Example: 8-puzzle 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State states??: integer locations of tiles (ignore intermediate positions) actions??: move blank left, right, up, down (ignore unjamming etc.) goal test??: = goal state (given) path cost??: 1 per move [Note: optimal solution of n-puzzle family is NP-hard]

Search lgorithms on Graphs

Tree search 1. start from the initial state 2. expand the current state essence of search: following up one option now and putting the others aside function Tree-Search( problem, strategy) returns a solution, or failure initialize the search tree using the initial state of problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add the resulting nodes to the search tree end all search algorithms share this tree search structure they vary primarily according to how they choose which state to expand --- the so-called search strategy

General tree search function Tree-Search( problem, fringe) returns a solution, or failure fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node Remove-Front(fringe) if Goal-Test(problem, State(node)) then return node fringe Insertll(Expand(node, problem), fringe) function Expand( node, problem) returns a set of nodes successors the empty set for each action, result in Successor-Fn(problem, State[node]) do s a new Node Parent-Node[s] node; ction[s] action; State[s] result Path-ost[s] Path-ost[node] + Step-ost(node, action, s) Depth[s] Depth[node] + 1 add s to successors return successors note the time of goaltest: expanding time not generating time

Example Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind rad Timisoara Lugoj Mehadia Dobreta raiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea ucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Rimnicu Vilcea Lugoj Zerind Sibiu rad Fagaras Oradea Timisoara rad rad Oradea rad

Example rad Sibiu Timisoara Zerind rad Fagaras Oradea Rimnicu Vilcea rad Lugoj rad Oradea Oradea 71 Neamt 75 Zerind 87 151 Iasi rad 140 Sibiu 99 Fagaras 92 118 80 Timisoara Rimnicu Vilcea 111 142 Lugoj Pitesti 211 97 70 98 Mehadia 146 101 85 Urziceni 75 138 ucharest Dobreta 120 90 raiova Giurgiu Vaslui Hirsova 86 Eforie

Example Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind rad Timisoara Lugoj Mehadia Dobreta raiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea ucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Lugoj rad rad Oradea Rimnicu Vilcea Zerind rad Sibiu rad Fagaras Oradea Timisoara

Example Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind rad Timisoara Lugoj Mehadia Dobreta raiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea ucharest 71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86 Lugoj rad rad Oradea Rimnicu Vilcea Zerind rad Sibiu rad Fagaras Oradea Timisoara

Graph search function Tree-Search( problem, fringe) returns a solution, or failure fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node Remove-Front(fringe) if Goal-Test(problem, State(node)) then return node fringe Insertll(Expand(node, problem), fringe) function Graph-Search( problem, fringe) returns a solution, or failure closed an empty set fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node Remove-Front(fringe) if Goal-Test(problem, State[node]) then return node if State[node] is not in closed then add State[node] to closed fringe Insertll(Expand(node, problem), fringe) end

Graph separation property the frontier (expandable leaf nodes) separates the visited and the unexplored nodes

State v.s. node state is a (representation of) a physical configuration node is a data structure constituting part of a search tree includes parent, children, depth, path cost g(x) States do not have parents, children, depth, or path cost! parent, action State 5 6 4 1 8 Node depth = 6 g = 6 7 3 2 state The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.

Search strategies strategy is defined by picking the order of node expansion Strategies are evaluated along the following dimensions: completeness does it always find a solution if one exists? time complexity number of nodes generated/expanded space complexity maximum number of nodes in memory optimality does it always find a least-cost solution? Time and space complexity are measured in terms of b maximum branching factor of the search tree d depth of the least-cost solution m maximum depth of the state space (may be )

Uninformed Search Strategies Uninformed strategies use only the information available in the problem definition readth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search

readth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G

readth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G

readth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G

Properties omplete?? Yes (if b is finite) Time?? 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space?? O(b d+1 ) (keeps every node in memory) Optimal?? Yes (if cost = 1 per step); not optimal in general Space is the big problem; can easily generate nodes at 100M/sec so 24hrs = 8640G.

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O

Properties omplete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time?? O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space?? O(bm), i.e., linear space! Optimal?? No with repeated states avoid

Uniform-cost search readth-first search: First In First Out queue Depth-first search: Last In First Out queue (stack) Uniform-cost search: Priority queue (least cost out) part of the map Sibiu 99 Fagaras 80 Rimnicu Vilcea 97 Pitesti 211 101 ucharest

Uniform-cost search readth-first search: First In First Out queue Depth-first search: Last In First Out queue (stack) Uniform-cost search: Priority queue (least cost out) part of the map Sibiu cost=99 99 Fagaras cost=80 80 Rimnicu Vilcea 97 Pitesti 211 101 ucharest

Uniform-cost search readth-first search: First In First Out queue Depth-first search: Last In First Out queue (stack) Uniform-cost search: Priority queue (least cost out) part of the map Sibiu cost=99 99 Fagaras cost=80 80 Rimnicu Vilcea 97 cost=177 Pitesti 211 101 ucharest

Uniform-cost search readth-first search: First In First Out queue Depth-first search: Last In First Out queue (stack) Uniform-cost search: Priority queue (least cost out) part of the map Sibiu cost=99 99 Fagaras cost=80 80 Rimnicu Vilcea cost=310 97 cost=177 Pitesti 211 101 ucharest

Uniform-cost search readth-first search: First In First Out queue Depth-first search: Last In First Out queue (stack) Uniform-cost search: Priority queue (least cost out) part of the map Sibiu cost=99 99 Fagaras cost=80 80 Rimnicu Vilcea cost=310 97 cost=177 Pitesti 211 101 cost=278 ucharest

Uniform-cost search readth-first search: First In First Out queue Depth-first search: Last In First Out queue (stack) Uniform-cost search: Priority queue (least cost out) Equivalent to breadth-first if step costs all equal part of the map Sibiu cost=99 99 Fagaras cost=80 80 Rimnicu Vilcea cost=310 97 cost=177 Pitesti 211 101 cost=278 ucharest best path from Sibiu to ucharest

Properties omplete?? Yes, if step cost ϵ Time?? # of nodes with g cost of optimal solution, O(b /ϵ ) where is the cost of the optimal solution Space?? # of nodes with g cost of optimal solution, O(b /ϵ ) Optimal?? Yes nodes expanded in increasing order of g(n) Question: why it is optimal?

readth-first v.s. depth-first readth-first: faster, larger memory Depth-first: less memory, slower Question: how to better balance time and space?

Depth-limited search limit the maximum depth of the depth-first search i.e., nodes at depth l have no successors function Depth-Limited-Search( problem, limit) returns soln/fail/cutoff Recursive-DLS(Make-Node(Initial-State[problem]), problem, limit) function Recursive-DLS(node, problem, limit) returns soln/fail/cutoff cutoff-occurred? false if Goal-Test(problem, State[node]) then return node else if Depth[node] = limit then return cutoff else for each successor in Expand(node, problem) do result Recursive-DLS(successor, problem, limit) if result = cutoff then cutoff-occurred? true else if result failure then return result if cutoff-occurred? then return cutoff else return failure

Iterative deepening search try depth-limited search with increasing limit restart the search at each time function Iterative-Deepening-Search( problem) returns a solution inputs: problem, a problem for depth 0 to do result Depth-Limited-Search( problem, depth) if result cutoff then return result end

Example Limit = 0 Limit = 1 Limit = 3 D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O wasteful searching the beginning nodes many times?

Properties omplete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? O(bd) Optimal?? Yes, if step cost = 1 an be modified to explore uniform-cost tree in the same order as the breadth-first search small space as depth-first search Numerical comparison for b = 10 and d = 5, solution at far right leaf: N(IDS) = 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450 N(FS) = 10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100 IDS does better because other nodes at depth d are not expanded FS can be modified to apply goal test when a node is generated

Summary riterion readth- Uniform- Depth- Depth- Iterative First ost First Limited Deepening omplete? Yes Yes No Yes, if l d Yes Time b d+1 b /ϵ b m b l b d Space b d+1 b /ϵ bm bl bd Optimal? Yes Yes No No Yes