600 likes | 703 Views
ISC 4322/6300 – GAM 4322 Artificial Intelligence. Lecture 2 Solving Problems by Searching Instructor: Alireza Tavakkoli September 3, 2009. University Of Houston- Victoria Computer Science Department. Intelligent Agents. Vacuum-Cleaner World. Performance Measure
E N D
ISC 4322/6300 – GAM 4322Artificial Intelligence Lecture 2 Solving Problems by Searching Instructor: Alireza Tavakkoli September 3, 2009 University Of Houston- Victoria Computer Science Department
Vacuum-Cleaner World • Performance Measure • Award One Point per Clean Cell Over 1000 Time Step • Environment • Two Cell World • Actions • Left, Right, Suck, NoOp • Percepts • Location and Contents, e.g., [A, Dirty]
Reflex Vacuum Agent Program Sensing input: [Cell Id, Dirty or Not Dirty] Actions: [Clean, move Left, move Right, NoOp] • Advantages • Small Table • Cutting Down the Table Size by Eliminating Percept History • Action Does Not Depend on the Location
Uninformed Search • Problem Solving Agents • A sequence of actions • Desirable state • Definition • Problem • Solution • Approach • Uninformed search mechanisms • Analysis of algorithms concepts • Asymptotic complexity • NP-completeness
Complexity Analysis • Benchmarking • Run the algorithm and measure • Speed • Memory consumption • Disadvantages • Platform dependent • Need to write the program on a specific machine • Asymptotic analysis • Analysis of the algorithm • Abstract • The input • The implementation • Measure the speed and memory
Example • Consider this • The sequence size = n • The total number of steps • T( n ) = ? • T( n ) = 2n + 2
Analysis of Algorithms • Two difficulties in analyzing algorithms • Hard to find a number to describe the complexity alone • Tworst ( n ) • Tavg( n ) • Algorithm resist exact analysis • Big-O notation • Previous exmaple’s complexity : O ( n ) • Formal definition • Orders
NP-Completeness • O() • Approximation of the complexity of a particular algorithm • Is there a better algorithm for a particular problem? • Complexity analysis • Satisfiablity problems are NP-Complete!
Back to AI • Intelligent agents • Maximize the performance measure • Adopt a goal and aim to achieve it. • Example • Starting in Arad • Goal • Go to Bucharest • The first step in problem solving • Goal formulation
Problem Solving • What is a goal? • A set of world states • What actions to take? • Level of detail • Problem formulation • In our example • Driving to a particular town • States are being in a particular town • Goal • Driving to Bucharest
How to Get to Bucharest? • Get out of Arad • Without more knowledge • Pick randomly • With a map • Compare hypothetical journeys • Solution • Examine different sequences • Lead to states of known values • Pick the best sequence • Search • Input: a problem • Output: action sequences
Formulate, Search, Execute! Static, Observable, Discrete, and Determinist Environment While searching ignores the percepts!
Problem and Solution Definition • Problem Definition • Initial state • Actions • Successor functions • Goal test • Path cost • Step cost • State space • Initial state + Successor function • Path • Sequence of states connected by sequence of actions • Solution • Optimal Solution Romania state space
Problem Formulation • Abstraction • Removing irrelevant details • Valid abstraction
Example Toy Problems • Vacuum world • States • Initial state • Successor function • Goal test • Path cost Vacuum world state space
Example Toy Problems • 8 – Puzzle • States • Initial state • Successor function • Goal test • Path cost • NP-Complete • 9! States • Half unsolvable! 9x8x7x6x5x4x3x2x1 = 9! 9 8 7 6 5 4 3 2 1 Some 8 – Puzzle states
Example Toy Problems • 8 – Queen problem • Incremental formulation • States • Naïve: ~1014 states • Better: 2057 states • Initial state • Successor function • Goal test • Path cost • Complete formulations Almost a solution to 8 – Queen problem
Searching for Solutions • Search tree • Search nodes • Root • Initial state search node • Expansion of states • Applying the successor function Search Strategy
Searching for Solutions • Node representation • State • Parent • Action • Path cost • Depth Fringe Nodes
Queue Implementation • Queue operations • MAKE-QUEUE • EMPTY? • FIRST • REMOVE-FIRST • INSERT • INSERT-ALL • Check the general tree search code • Book p. 72 Queue
Performance Measurement • Performance • Completeness • Optimality • Complexity • Time • Space • Complexity in AI • b • d • m • Search cost • Time it takes to find the solution • Total cost • Search cost + Path cost • Generally convert to the path cost format • What really agent cares about.
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Implementation: • Fringe is a FIFO queue
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Implementation: • Fringe is a FIFO queue
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Implementation: • Fringe is a FIFO queue
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Implementation: • Fringe is a FIFO queue
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Implementation: • Fringe is a FIFO queue
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Performance • Complete? • Yes (if b is finite) • Optimal? • Yes (if cost = 1per step) • Time cost • Space cost
Uninformed Search Strategies • Breath-First Search • Expand shallowest unexpanded node • Space requirements (b=10, 1000 nodes/sec, byte/node)
Uninformed Search Strategies • Uniform-Cost Search • Expand least-cost unexpanded node • Implementation: • Fringe is a FIFO queue ordered by path cost • Equivalent to BFS if cost is equal for all nodes. • Performance • Complete? • Yes (if cost ≠ 0 per step) • Time and space cost • If C* is the optimum cost and is the minimum cost then • Can be much higher than BFS!
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand deepest unexpanded node • Implementation: • Fringe is a LIFO queue
Uninformed Search Strategies • Depth-First Search • Expand shallowest unexpanded node • Performance • Complete? • No (in infinite-depth spaces or spaces w/ loops) • Optimal? • No • Time cost • Terrible if m is larger than d ! • Space cost • Linear Space!
Uninformed Search Strategies • Depth-Limited Search • Expand deepest unexpanded node but stop at limit • Properties: • Optimal? • No if limit > d • Complete? • No if limit < d • More knowledge! Cut off limit
Uninformed Search Strategies • Iterative Deepening Search • Depth limited search • Iteratively increase the depth limit; 0, 1, 2, …
Iterative Deepening Search • Number of nodes generated in a • depth-limited search to depth d with branching factor b: NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd • iterative deepening search to depth d with branching factor b: NIDS = (d+1)b0 + d b^1 + (d-1)b^2 + … + 3bd-2 +2bd-1 + 1bd • Breath first search to depth d with branching factor b: NBFS = b + b2 + b3 + … + bd +bd+1 – b • For b = 10, d = 5, • NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111 NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456 • NBFS = 10+100+1,000+10,000+100,000+999,990 = 1,111,100 • Overhead • IDS/DLS = (123,456 - 111,111)/111,111 = 11% • IDS/BFS = (1,111,100-123,456)/123,456 = 800%
Iterative Deepening Search Properties • Complete? • Yes • Time? • (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd) • Space? • O(bd) • Optimal? • Yes, if path cost is non-decreasing
Bidirectional Search • Run two searches – one from the initial state • and one backward from the goal. • We stop when the two searches meet. • Motivation: • Time complexity: (b d/2 + b d/2 ) < b d Searching backwards not easy.