670 likes | 731 Views
Review for Finals 2011. 159.302. SEARCH. CONSTRAINT SATISFACTION PROBLEMS. GAMES. FUZZY LOGIC. NEURAL NETWORKS. GENETIC ALGORITHM (not included in the exam). LOGIC (not included in the exam). Allotment of marks. SEARCH – 15 marks. FUNDAMENTALS (true or false) – 8 marks.
E N D
Review for Finals 2011 159.302
SEARCH CONSTRAINT SATISFACTION PROBLEMS GAMES FUZZY LOGIC NEURAL NETWORKS GENETIC ALGORITHM (not included in the exam) LOGIC (not included in the exam)
Allotment of marks SEARCH – 15 marks FUNDAMENTALS (true or false) – 8 marks CONSTRAINT SATISFACTION PROBLEMS – 10 marks GAMES – 8 marks FUZZY LOGIC – 7 marks NEURAL NETWORKS – 12 marks Total = 60 marks
Robot Navigation Obstacle Avoidance, Target Pursuit, Opponent Evasion Input: Multiple Obstacles: x, y, angle Target’s x, y, angle Output: Robot angle, speed
Cascade of Fuzzy Systems Multiple Fuzzy Systems employ the various robot behaviours Path planning Layer: The A* Algorithm Path Planning Layer Next Waypoint Fuzzy System 1 Fuzzy System 1:Target Pursuit Target Pursuit Adjusted Angle Central Control Fuzzy System 2: Speed Control for Target Pursuit Fuzzy System 2 Adjusted Speed ObstacleDistance < MaxDistanceTolerance and closer than Target N Y Fuzzy System 3: Obstacle Avoidance Fuzzy System 3 Obstacle Avoidance Adjusted Angle Fuzzy System 4 Fuzzy System 4: Speed Control for Obstacle Avoidance Adjusted Speed Actuators
SEARCH 1 Background and Motivation General Idea: Search allows exploring alternatives These algorithms provide the conceptual backbone of almost every approach to the systematic exploration of alternatives. Topics for Discussion: • Background • Uninformed vs. Informed Searches • Any Path vs. Optimal Path • Implementation and Performance
SEARCH 1 Graph Search as Tree Search • We can turn graph search problems (from S to G) into tree search problems by: • Replacing undirected links by 2 directed links • Avoiding loops in path (or keeping track of visited nodes globally) S A B C A G D G D D C S B C G C G
SEARCH 1 More Abstract Example of Graphs Planning actions (graph of possible states of the world) Here, the nodes denote descriptions of the state of the world Path = “plan of actions” B C C A B A Put C on A Put B on C A B C A C C A B Put C on B B Put A on C
SEARCH 3 Classes of Search
SEARCH 3 Simple Search Algorithm A Search Node is a path from some state X to the start state e.g. (X B A S) The state of a search node is the most recent state of the path e.g. X • Initialise Q with search node (S) as only entry; • set Visited = (S). Let Q be a list of search nodes e.g. (X B A S) (C B A S) …) 2. If Q is empty, fail. Else, pick some search node N from Q. Let S be the start state. 3. If state (N) is a goal, return N (we’ve reached the goal). 4. (Otherwise) Remove N from Q. 5. Find all the descendants of state (N) not in Visited and create all the one-step extensions of N to each descendant. Critical Decisions: Step 2: picking N from Q. Step 6: adding extensions of N to Q. 6. Add the extended paths to Q; add children of state (N) to Visited. 7. Go to Step 2.
SEARCH 4 Implementing the Search Strategies Depth-First (backtracking search) 1. Pick first element of Q. Heuristic functions are applied in the hope of completing the search quicker or finding a relatively good goal state. It does not guarantee finding the “best” path though. 2. Add path extensions to front of Q. Breadth-First 1. Pick first element of Q. 2. Add path extensions to end of Q. Best-First (greedy search) 1. Pick best (measured heuristic value of state) element of Q. 2. Add path extensions anywhere in Q (it may be efficient to keep the Q ordered in some way so as to make it easier to find the “best” element.
SEARCH C A G D S B 4 Depth-First with Visited List Sequence of State Expansions: S-A-C-D-G Pick first element of Q; Add path extensions to front of Q. In DFS – nodes are pulled off the queue and inserted into the queue using a stack.
SEARCH 4 Visited States Keeping track of visited states generally improves time efficiency when searching graphs, without affecting correctness. Note, however, that substantial additional space may be required to keep track of visited states. If all we want to do is find a path from the start to the goal, there is no advantage to adding a search node whose state is already the state of another search node. Any state reachable from the node the second time would have been reachable from that node the first time. Note that, when using Visited, each state will only ever have at most one path to it (search node) in Q. We’ll have to revisit this issue when we look at optimal searching
SEARCH 4 Worst Case Running Time Max Time is proportional to the Max. number of Nodes visited. In the worst case, all the searches, with or without visited list may have to visit each state at least once. b=2 d=0 d=1 So, all searches will have worst case running times that are at least proportional to the total number of states and therefore exponential in the “depth” parameter. d=2 d=3 d is depth b is branching factor Number of States in the tree = bd < (bd+1 – 1)/(b-1) < bd+1
SEARCH 4 Worst Case Space Max Q Size = Max (#visited – #expanded). expanded visited b=2 d=0 d=1 d=2 d=3 Depth-first maximum Q size: (b-1)d ≈ bd Breadth-first max. Q size: bd
SEARCH 4 Cost and Performance of Any-Path Methods Searching a tree with branching factor b and depth d (without using a Visited List) *If there are no indefinitely long paths in the search space **Best-First needs more time to locate the best node in Q. Worst case time is proportional to the number of nodes added to Q. Worst case space is proportional to maximal length of Q.
SEARCH 4 Cost and Performance of Any-Path Methods Searching a tree with branching factor b and depth d (with Visited List) *If there are no indefinitely long paths in the search space **Best-First needs more time to locate the best node in Q. Worst case time is proportional to the number of nodes added to Q. Worst case space is proportional to maximal length of Q and Visited list.
SEARCH 4 States vs. Path b=2 d=0 d=1 d=2 d=3 Using a Visited list, the worst-case time performance is limited by the number of states in the search space rather than the number of paths through the nodes in the space (which may be exponentially larger than the number of states. Using a Visited list helps prevent loops; that is, no path visits a state more than once. However, using the Visited list for very large spaces may not be appropriate as the space requirements would be prohibitive.
SEARCH 4 Space (the final frontier) In large search problems, memory is often the limiting factor. • Imagine searching a tree with branching factor 8 and depth 10. Assume a node requires just 8 bytes of storage. Then, Breadth-First search might require up to: (23)10 * 23 = 233 bytes = 8,000 Mbytes = 8 Gbytes One strategy is to trade time for memory. For example, we can emulate Breadth-First search by repeated applications of Depth-First search, each up to a preset depth limit. This is called Progressive Deepening Search (PDS): • C=1 • Do DFS to max. depth C. If path is found, return it. • Otherwise, increment C and go to Step 2.
SEARCH 3 Simple Search Algorithm A Search Node is a path from some state X to the start state e.g. (X B A S) The state of a search node is the most recent state of the path e.g. X 1. Initialise Q with search node (S) as only entry; set Visited = (S). Let Q be a list of search nodes e.g. (X B A S) (C B A S) …) 2. If Q is empty, fail. Else, pick some search node N from Q. 3. If state (N) is a goal, return N (we’ve reached the goal). Let S be the start state. 4. (Otherwise) Remove N from Q. 5. Find all the descendants of state (N) not in Visited and create all the one-step extensions of N to each descendant. 6. Add the extended paths to Q; add children of state (N) to Visited. Do NOT use Visited List for Optimal Searching! 7. Go to Step 2. Critical Decisions: Step 2: picking N from Q. Step 6: adding extensions of N to Q.
SEARCH 4 Uniform Cost C 2 3 A 2 G D 2 4 S 1 5 5 B S 5 A 2 B The sequence of path extensions corresponds precisely to path-length order, so it is not surprising we find the shortest path. 6 10 6 4 D C D G 9 8 C G 8 C G 9 0 2 4 5 6 6 8 Sequence of State Expansions: S – A – C – B – D – D - G Uniform Cost enumerates paths in order of total path cost!
SEARCH 3 Simple Optimal Search Algorithm: Uniform Cost + Strict Expanded List A Search Node is a path from some state X to the start state e.g. (X B A S) The state of a search node is the most recent state of the path e.g. X 1. Initialise Q with search node (S) as only entry, set Expanded = {}. 2. If Q is empty, fail. Else, pick some search node N from Q. Let Q be a list of search nodes e.g. (X B A S) (C B A S) …) 3. If state (N) is a goal, return N (we’ve reached the goal). 4. (Otherwise) Remove N from Q. In effect, discard that state Let S be the start state. 5. If state (N) in Expanded, go to Step 2; otherwise, add state (N) to Expanded List. Take note that we need to add some precautionary measures in the adding of extended paths to Q. 6. Find all the children of state(N) (Not in Expanded) and create all the one-step extensions of N to each descendant. 7. Add all the extended paths to Q. If descendant state already in Q, keep only shorter path to state in Q. 8. Go to Step 2.
SEARCH C 2 3 A 2 G D 2 4 S 1 5 5 B 4 Uniform Cost (with Strict Expanded List) Remove because D is already in Q (our convention: take element at the front of the Q if a path leading to the same state is in Q). Remove because there’s a new shorter path to G Remove because C was expanded already Sequence of State Expansions: S – A – C – B – D - G
SEARCH 3 Why use estimate of goal distance? • Order in which UC looks at states. A and B are same distance from start S, so will be looked at before any longer paths. No “bias” towards goal. A B G S • Assume states are points in the Euclidean space
SEARCH 3 Why use estimate of goal distance? • Order in which UC looks at states. A and B are same distance from start S, so will be looked at before any longer paths. No “bias” towards goal. A B G S • Order of examination using distance from S + estimate of distance to G. • Note: “bias”toward the goal; The points away from G look worse • Assume states are points in the Euclidean space
SEARCH 3 Goal Direction • UC is really trying to identify the shortest path to every state in the graph in order. It has no particular bias to finding a path to a goal early in the search. • We can introduce such a bias by means of heuristic function h(N), which is an estimate (h) of the distance from a state to the goal. • Instead of enumerating paths in order of just length (g), enumerate paths in terms of • f = estimated total path length = g + h. • An estimate that always underestimates the real path length to the goal is called admissible. For example, an estimate of 0 is admissible (but useless). Straight line distance is admissible estimate for path length in Euclidean space. • Use of an admissible estimate guarantees that UC will still find the shortest path. • UCwith an admissible estimate is known as A* Search.
SEARCH C 2 3 A 2 G D 2 4 S 1 5 5 B 4 A* Heuristic Values: A=2, B=3, C=1, D=1, S=0, G=0 • Pick best (by path length + heuristic) element of Q, Add path extensions anywhere in Q. Sequence of State Expansions: S – A – C – D - G
SEARCH 4 States vs. Paths b=2 d=0 d=1 d=2 d=3 We have ignored the issue of revisiting states in our discussion of Uniform-CostSearch and A*. We indicated that we could not use the Visited List and still preserve optimality, but can we use something else that will keep the worst-case cost of a search proportional to the number of states in a graph rather than to the number of non-looping paths?
SEARCH 4 Consistency To enable implementing A* using the strict Expanded List, H needs to satisfy the following consistency (also known as monotonicity) conditions 1. h(Si) = 0, if niis a goal 2. h(Si) - h(Sj)<=c(Si, Sj), if nja child of ni That is, the heuristic cost in moving from one entry to the next cannot decrease by more than the arc cost between the states. This is a kind of triangle inequality This condition is a highly desirable property of a heuristic function and often simply assumed (more on this later). nj h(Sj) goal C(Si, Sj) h(Si) ni
SEARCH 4 A* (with Strict Expanded List) Note that the heuristic is admissible and consistent. G 100 A C 1 1 S 2 2 B Heuristic Values: A=100, B=88, C=100, S=90, G=0 If we modify the heuristic in the example we have been considering so that it is consistent, as we have done here by increasing the value of h(B), then A* (with the Expanded List) will work. Underlined paths are chosen for extension.
SEARCH 4 Dealing with inconsistent heuristic What can we do if we have an inconsistent heuristic but we still want optimal paths? Modify A* so that it detects and corrects when inconsistency has led us astray. Assume we are adding node1 to Q and node2 is present in Expanded List with node1.state = node2.state. • Strict: • Do NOT add node1 to Q. • Non-Strict Expanded List: • If (node1.path_length < node2.path_length), then • Delete node2 from Expanded List • Add node1 to Q.
SEARCH 4 Optimality and Worst Case Complexity
Fuzzy Inference Process Fuzzy Inference Process e.g. theta e.g. force Rule Evaluation Fuzzification Defuzzification Fuzzification: Translate input into truth values Rule Evaluation: Compute output truth values Defuzzification: Transfer truth values into output
Obstacle Avoidance Problem Robot Navigation obstacle (obsx, obsy) (x,y) Can you describe how the robot should turn based on the position and angle of the obstacle? Obstacle Avoidance & Target Pursuit Demonstration
Another example:Fuzzy Sets for Robot Navigation Angle and Distance SMALL MEDIUM LARGE NEAR FAR VERY FAR * Sub ranges for angles & distances overlap
Fuzzy Systems forObstacle Avoidance Vision System Nearest Obstacle (Distance and Angle) Fuzzy System 3 (Steering) e.g. If the Distance from the Obstacle is NEAR and the Angle from the Obstacle is SMALL Then turn Very Sharply. Angle Fuzzy System 4 (Speed Adjustment) e.g. If the Distance from the Obstacle is NEAR and the Angle from the Obstacle is SMALL Then move Very Slowly. Speed
NEGATIVE ZERO POSITIVE 1.0 0.0 -3.0 -2.5 -1.0 -0.5 0.0 0.5 1.0 2.5 3.0 Fuzzification 1. Fuzzification Fuzzification Example Fuzzy Sets = { Negative, Zero, Positive } Assuming that we are using trapezoidal membership functions. Crisp Input: x = 0.25 What is the degree of membership of x in each of the Fuzzy Sets?
NEGATIVE ZERO POSITIVE 1.0 0.0 -3.0 -2.5 -1.0 -0.5 0.0 0.5 1.0 2.5 3.0 Fuzzification Fuzzification Example Fuzzy Sets = { Negative, Zero, Positive }
Sample Calculations Crisp Input: Fzero(0.25) Fpositive(0.25) 3 - 2.5 Fnegative(0.25)
Sample Calculations Crisp Input: Fzero(-0.25) Fpositive(-0.25) Fnegative(-0.25)
Trapezoidal Membership Functions LeftTrapezoid Left_Slope = 0 Right_Slope = 1 / (A - B) CASE 1: X < a Membership Value = 1 CASE 2: X >= b Membership Value = 0 CASE 3: a < x < b Membership Value = Right_Slope * (X - b) a b
Trapezoidal Membership Functions • RightTrapezoid • Left_Slope = 1 / (B - A) • Right_Slope = 0 • CASE 1: X <= a • Membership Value = 0 • CASE 2: X >= b • Membership Value = 1 • CASE 3: a < x < b • Membership Value = Left_Slope * (X - a) a b
Trapezoidal Membership Functions Regular Trapezoid Left_Slope = 1 / (B - A) Right_Slope = 1 / (C - D) CASE 1: X <= a Or X >= d Membership Value = 0 CASE 2: X >= b And X <= c Membership Value = 1 CASE 3: X >= a And X <= b Membership Value = Left_Slope * (X - a) CASE 4: (X >= c) And (X <= d) Membership Value = Right_Slope * (X - d) a b c d
Fuzzy Control Different stages of Fuzzy control 2. Rule Evaluation Inputs are applied to a set of if/then control rules. e.g. IF temperature is very hot, THEN set fan speed very high. The results of various rules are summed together to generate a set of “fuzzy outputs”. FAMM Outputs NL=-5 NS=-2.5 ZE=0 PS=2.5 PL=5.0 x N ZE P N ZE P y
Fuzzy Control 2. Rule Evaluation Assuming that we are using the conjunction operator (AND) in the antecedents of the rules. FAMM x N ZE P N ZE P y
Fuzzy Control 3. Defuzzification Defuzzification Example Assuming that we are using the center of mass defuzzification method. = -1.25/ 4.5 = -0.278 FAMM x N ZE P N ZE P y