lecture 3
play

Lecture 3: reflex-based, model-based, goal-based, utility-based, - PowerPoint PPT Presentation

CS440/ECE448: Intro to Artificial Intelligence Review Different kinds of agents: Lecture 3: reflex-based, model-based, goal-based, utility-based, learning-based Systematic search How do we evaluate agents? External


  1. CS440/ECE448: Intro to Artificial Intelligence � Review � Different kinds of agents: � Lecture 3: 
 reflex-based, model-based, goal-based, utility-based, learning-based � Systematic search � � How do we evaluate agents? � External performance measure 
 Prof. Julia Hockenmaier � � juliahmr@illinois.edu � What is the task environment like: � � observable?, known?, deterministic? http://cs.illinois.edu/fa11/cs440 � sequential?, static? � � � When is an agent rational? � Answer 1: When an agent chooses actions that bring it closer to the goal. � � Problem solving 
 Answer 2: When an agent chooses actions as search � that it expects to bring it closer to the goal � � Answer 2 is correct. � � CS440/ECE448: Intro AI � 3 �

  2. Problem solving as search � Problem solving � – Finding any solution ( goal-driven ) � – Finding the cheapest solution ( utility-driven ) � � Problem solving � Uninformed (blind) search (goal-driven): � – Algorithms: breadth-first; depth-first 
 � Informed (heuristic) search (utility-driven): � – Search costs; admissible heuristics � – Algorithms: greedy best first; A* search � CS440/ECE448: Intro AI � 5 � The 8 queens problem � The 8-puzzle � 4 � 8 � 2 � 1 � 2 � 3 � Can you place 8 queens on a chess board so that they don ʼ t attack each other? � 1 � 6 � 4 � 5 � 6 � 5 � 3 � 7 � 7 � 8 � ♕ ! ! ! ! ! ! ♕ ! ! ♕ ♕ ! ! !" ! ! Goal � ! ! !" ! ! Initial State � ♕ ♕ ! ! ! ! ! ! ! ! ♕ ! ! ! ! ! ! ! ! ! ! ! ! ♕ ! ! Four possible actions: � ♕ ! ! ! ! ! ! ! ! MoveTileUp 
 ♕ ! ! ! ! ! ! ! ! ! ! ! ! MoveTileDown 
 ♕ ! ! ♕ ! ! ! ! ! ! MoveTileLeft 
 ♕ ♕ ! ! ! ! ! ! ! ! MoveTileRight � This doesn’t work! Phew! 8 �

  3. Cryptarithmetic � The route-finding problem � Starting point � Destination � Oradea forty 
 71 Neamt send 
 ten 
 87 Zerind 151 + more 
 + ten 
 75 Iasi Arad = sixty � = money � 140 92 Sibiu Fagaras 99 118 � Vaslui 80 Rimnicu Vilcea Timisoara Find a letter/digit substitution that forms a 142 211 111 Pitesti natural & correct arithmetic expression � Lugoj 97 70 98 Hirsova � 146 85 Mehadia 101 Urziceni 86 75 138 Bucharest Drobeta 120 90 Eforie Craiova Giurgiu This lecture: assumptions � Solving a problem � Today ʼ s methods work when the environment is: � 1. Formulate a goal 
 � goal = a (set of) state(s) to be in 
 1. observable 
 � (Agent perceives all it needs to know) � 2. Define the corresponding problem 
 2. known 
 problem = what actions and states to consider 
 (Agent knows the effects of each action) � � 3. deterministic 
 3. Find the solution to the problem 
 (Each action always has the same outcome) 
 solution = a sequence of actions to reach goal 
 � � In such environments, the solution to any 4. Execute the solution � problem is a fixed sequence of actions . �

  4. 
 
 
 Representing states � Implementing problem solving � 8-queens: a set of chessboard positions � We need: � {}, {a4}, {a4, b6}, … � - a data structure to represent states � � 8-puzzle: a list of nine numbers � - a designated initial state � <1,2,8,5,4,0,6,7,3> � � - a function that maps states to states 
 Cryptarithmetic: a tuple of three sets to represent actions (operators) � (unassigned letters, unassigned digits, assignments) � ({e, m, n, o, r, s, y,} 
 - a boolean predicate (goal test) on states 
 {0, 1, 2, 3, 4, 5, 6, 7, 9} 
 that checks whether a state is a goal state � {d:8}) � � CS440/ECE448: Intro AI � 13 � CS440/ECE448: Intro AI � 14 � The initial state � Actions � 8-queens: � 8-queens: the empty board {} � placeQueen(e4, s): 
 if e4 � s: (precondition) return s ∪ {e4} (effect) � Cryptarithmetic: 
 (all letters, all digits, no assignments) � Cryptarithmetic: � ({d e, m, n, o, r, s, y,} 
 replaceLetterWithDigit(l,d, s): � {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 
 � if l ∈ s.unassignedLetters 
 {}) � and d ∈ s.unassignedDigits: 
 � return (s.unassignedLetters\{l}, 
 8-puzzle: a random board � s.unassignedDigits\{d}, 
 s.assignments ∪ {l:d}) � <1,2,8,5,4,0,6,7,3> � � CS440/ECE448: Intro AI � 15 � CS440/ECE448: Intro AI � 16 �

  5. The cost of actions � Goal test � Actions may have different costs: � 8-queens: 
 The cost of driving from A to B depends 
 Are eight queens placed, and no queen on the distance (and traffic conditions) � attacks another queen? � � We may need a cost function which calculates Cryptarithmetic: � the (exact) cost of each action. � Have all letters been replaced by different digits, � are there no leading zeros, and are all We may want to find the lowest-cost solution calculations correct? (otherwise, we ʼ re happy with the first one we find) � � CS440/ECE448: Intro AI � 17 � State-space graph � Solution � Goal � Goal � state � state � Initial � Initial � b3 � c5 � b3 � c5 � state � state � ! ! a1 � a1 � ! . ! . "! "! ! ! ! ! ! ! b4 � b4 � ! "! "! "! ! "! "! "! "! "! a2 � a2 � ! ! a3 � a3 � "! "! b1 � b1 � ! ! "! "! Nodes : states � A single path ! ! b2 � b2 � "! ! "! ! Edges: actions � from the initial "! "! Edge weights: state to a goal ! ! "! "! cost of actions � state. � ! ! ! ! "! "! ! . ! . "! "! ! . ! . Goal � Goal � Goal � Goal � ! ! ! ! state � state � state � state � "! "! "! "!

  6. Weighted state space graphs � Initial state 
 Goal state 
 Oradea (starting point) � 71 (destination) � Neamt 87 Zerind 151 Step costs 
 75 Iasi (distances) � Arad 140 92 Search � Sibiu Fagaras 99 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 211 111 Pitesti Lugoj 97 70 98 Hirsova 146 85 Mehadia 101 Urziceni 86 75 138 Bucharest Drobeta 120 90 Eforie Craiova Giurgiu Problem solving with search � Search Tree � [(demnorsy), (0123456789), ( )] (initial state) � Initial state and operators define search tree � � choose an action � … � We need a search algorithm to build 
 [(emnorsy) 
 [(emnorsy) 
 [(emnorsy) 
 (the relevant parts of) the search tree. � (123456789) 
 (023456789) 
 (012345678) 
 ( d=0 )] � ( d=1 )] � ( d=9 )] � NB: In code, build/represent only what is needed � – Do NOT generate the entire search tree � – Do NOT save everything generated � – Generate states incrementally � NB: If the state space graph has loops, – Forget anything not needed for future � the search tree may be infinite! �

  7. Reducing the size 
 The size of the search tree � of the search tree � If there are b possible actions at each node: � What is the branching factor of 8-queens? � ( b = branching factor) � � � At depth 1, there are b nodes. � If queens can be placed anywhere: b=64 � � At depth 2, there are b*b = b 2 nodes. � Size of tree: 64x63x…x57 = 178,462,987,637,760 � � � … � If n -th queen is placed in n -th row: b= 8 � � At depth d, there are b d nodes. � Size of tree: 8 8 = 16,777,216 � � � The size of a search tree with depth d and When possible, it can help to impose a branching factor b is O(b d ) � specific order on the actions in advance. � CS440/ECE448: Intro AI � 26 � Representing nodes 
 Exploring the search tree � of the search tree � n.STATE: 
 Start with the root (= the initial state). � the corresponding state in the state space � It may not be possible to store/build the entire tree. � � n.PARENT: 
 Leaf nodes (frontier) = unvisited nodes � pointer to the parent node in the search tree � � Visiting a node: test whether it ʼ s a goal. � n.ACTION: 
 the action which gets from parent to here � If not, expand it (find all its children). � � n.PATH-COST: 
 � the total cost from the initial state to here � CS440/ECE448: Intro AI � 27 � CS440/ECE448: Intro AI � 28 �

  8. Expanding leaf nodes � Traversing the tree � Generating all children of a node in the search tree � We need an ordered list of the leaf nodes Expand(Node N): � we have not expanded yet (= the queue) � NB: The difference between search algorithms 
 Children = new List(); � lies in how they sort the queue � For every Action a: � � � child = apply(a, N) � We may also want a list of the states we if child != null: � have explored already (= the explored set) � Children.add(child) � This allows us to search on the state graph � Return Children; � CS440/ECE448: Intro AI � 30 � Generic Search Function Generic (tree) search function � SEARCH (Problem P, QueuingFunction QF): � local: � n � /*current node*/ 
 � � q � /*queue of nodes to explore*/ � Uninformed 
 q ! new List(InitialState(P)); � (blind) search � Loop: � � if q == () return failure; � n ! pop(q); � if n solves P return n; /*Goal test*/ � � q ! QF(q, expand(n)); /*Expansion*/ � end �

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend