1 / 76

Course written by Richard E. Korf, UCLA.

Heuristic Search in Artifitial Intelligence. Course written by Richard E. Korf, UCLA. The slides were made by students of this course from Bar-ilan University, Tel-Aviv, Israel. Chapter 1 Problems and Problem Spaces. Problems. There are 3 general categories of problems in AI:

umika
Download Presentation

Course written by Richard E. Korf, UCLA.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Heuristic Search in Artifitial Intelligence • Course written by Richard E. Korf, UCLA. • The slides were made by students of this course from Bar-ilan University, Tel-Aviv, Israel.

  2. Chapter 1 Problems and Problem Spaces

  3. Problems There are 3 general categories of problems in AI: • Single-agent pathfinding problems. • Two-player games. • Constraint satisfaction problems.

  4. Single Agent Pathfinding Problems • In these problems, in each case, we have a singleproblem-solver making the decisions, and the task is to find a sequence of primitive steps that take us from the initial location to the goal location. • Famous examples: • Rubik’s Cube (Erno Rubik, 1975). • Sliding-Tile puzzle. • Navigation - Travelling Salesman Problem.

  5. Two-Player Games • In a two-player game, one must consider the moves of an opponent, and the ultimate goal is a strategy that will guarantee a win whenever possible. • Two-player perfect information have received the most attention of the researchers till now. But, nowadays, researchers are starting to consider more complex games, many of them involve an element of chance. • The best Chess, Checkers, and Othello players in the world are computer programs!

  6. Constraint-Satisfaction Problems • In these problems, we also have a single-agent making all the decisions, but here we are not concerned with the sequence of steps required to reach the solution, but simply the solution itself. • The task is to identify a state of the problem, such that all the constraints of the problem are satisfied. • Famous Examples: • Eight Queens Problem. • Number Partitioning.

  7. Problem Spaces • A problem space consists of a set of states of a problem and a set of operators that change the state. • State: a symbolic structure that represents a single configuration of the problem in a sufficient detail to allow problem solving to proceed. • Operator: a function that takes a state and maps it to another state.

  8. Problem Spaces • Not all operators are applicable to all states. The conditions that must be true in order for an operator to be legally applied to a state are known as the preconditions of the operator. • Examples: • 8-Puzzle: • states: the different permutations of the tiles. • operators: moving the blank tile up, down, right or left. • Chess: • states: the different locations of the pieces on the board. • operators: legal moves according to chess rules.

  9. Problem Spaces • A problem instance: consists of a problem space, an initial state, and a set of goal states. • There may be a single goal state, or a set of goal states, anyone of which would satisfy the goal criteria. In addition, the goal could be stated explicitly or implicitly, by giving a rule of determining when the goal has been reached. • All 4 combinations are possible: [single\set of goal state(s)]  [explicit\implicit].

  10. Q Q Q Q Q Q Q Q Q Q Problem Spaces • For Constraint Satisfaction Problems, the goal will always be represented implicitly, since an explicit description is the solution itself. • Example: • 4-Queens has 2 different goal states.Here the goal is stated explicitly.

  11. Problem Representation • For some problems, the choice of a problem space is not so obvious. • The choice of representation for a problem can have an enormous impact on the efficiency of solving the problem. • There are no algorithms for problem representation. One general rule is that a smaller representation, in the sense of fewer states to search, is often better then a larger one.

  12. Problem Representation • For example, in the 8-Queens problem, when every state is an assignment of the 8 queens on the board: • The number of possibilities with all 8 queens on the board is 64 choose 8, which is over4 billion. • The solution of the problem prohibits more then one queen per row, so we may assign each queen to a separate row, now we’ll have 88 > 16 million possibilities. • Same goes for not allowing 2 queens in the same column either, this reduces the space to 8!, which is only 40,320 possibilities.

  13. Problem-Space Graphs • A Problem-Space Graph is a mathematical abstraction often used to represent a problem space: • The states are represented by nodes of the graph. • The operators are represented by edges between nodes. • Edges may be undirected or directed.

  14. Problem-Space Graphs • Example:a small part of the 8-puzzle problem-space graph:

  15. Problem-Space Graphs • In most problems spaces there is more then one path between a pair of nodes. • Detecting when the same state has been regenerated via a different path requires saving all the previously generated states, and comparing newly generated states against the saved states. • Many search algorithms don’t detect when a state has previously been generated. The cost of this is that any state that can be reached by 2 different paths will be represented by duplicate nodes. The benefits are memory savings and simplicity.

  16. Branching Factor and Solution Depth • The branching factor of a node : • is the number of children it has, not counting its parent if the operator is reversible. • is a function of the problem space. • The branching factor of a problem space : • is the average number of children of the nodes in the space. • The solution depth in a single-agent problem: • is the length of the shortest path from the initial node to a goal node. • is a function of the particular problem instance.

  17. Eliminating Duplicate Nodes • In many cases we can reduce the size of the search tree, by eliminating some simple duplicate paths. • In general, • we never apply an operator and it’s inverse in succession, since no optimal path can contain such a sequence. • Therefore we never list the parent of a node as one of his children. • This reduces the branching factor of the problem by approximately 1.

  18. Types of Problem Spaces • There are several types of problem spaces: • State space • Problem Reduction Space • AND/OR Graphs

  19. State Space • The states represent situations of the problem. • The operators represent actions in the world. • forward search: the root of the problem space represents the start state, and the search proceeds forward to a goal state. • backward search : the root of the problem space represents the goal state, and the search proceeds backward to the initial state. • For example: in Rubik’s Cube and the Sliding-Tile Puzzle,either a forward or backward search are possible.

  20. A B C A B C Problem Reduction Space • In a problem reduction space, the nodes represent problems to be solved or goals to be achieved, and the edges represent the decomposition of the problem into subproblems. • This is best illustrated by the example of the Towers of Hanoi problem.

  21. 3AC 2AB 1AC 2BC 1AC 1BA 1AB 1CB 1BC 1AC Problem Reduction Space • The root node, labeled “3AC” represents the original problem of transferring all 3 disks from peg A to peg C. • The goal can be decomposed into three subgoals: 2AB, 1AC, 2BC. In order to achieve the goal, all 3 subgoals must be achieved.

  22. A B C 3AC Problem Reduction Space

  23. A B C 3AC 2AB 1AC Problem Reduction Space

  24. A B C 3AC 2AB 1AC 1AB Problem Reduction Space

  25. A B C 3AC 2AB 1AC 1CB 1AB Problem Reduction Space

  26. A B C 3AC 2AB 1AC 1AC 1CB 1AB Problem Reduction Space

  27. A B C 3AC 2AB 1AC 2BC 1BA 1AC 1CB 1AB Problem Reduction Space

  28. A B C 3AC 2AB 1AC 2BC 1BC 1BA 1AC 1CB 1AB Problem Reduction Space

  29. A B C 3AC 2AB 1AC 2BC 1BC 1BA 1AC 1AC 1CB 1AB Problem Reduction Space

  30. AND/OR Graphs • An AND graph consists entirely of AND nodes, and in order to solve a problem represented by it, you need to solve the problems represented by all of his children (Hanoi towers example). • An OR graph consists entirely of OR nodes, and in order to solve the problem represented by it, you only need to solve the problem represented by one of his children (Eight Puzzle Tree example).

  31. AND/OR Graphs • An AND/OR graph consists of both AND nodes and OR nodes. • One source of AND/OR graphs is a problem where the effect of an action cannot be predicted in advanced, as in an interaction with the physical world. • Example: • the counterfeit-coin problem.

  32. 5 4 3 2 2 1 3 2 1 1 0 1 0 0 1 0 0 0 0 OR nodes AND nodes x x 0 Two-Player Game Trees • The most common source of AND/OR graphs is 2-player perfect-information games. • Example: Game Tree for 5-Stone Nim:

  33. Solution subgraph for AND/OR trees • In general, a solution to an AND/OR graph is a subgraph with the following properties: • It contains the root node. For every OR node included in the solution subgraph, one child is included. • For every OR node included in the solution subgraph, all the children are included. • Every terminal node in the solution subgraph is a solved node.

  34. Solutions • The notion of a solution is different for the different problem types: • For a path-finding problem, an optimal solution is a solution of lowest cost. • For a CSP, if there is a cost function associated with a state of the problem, an optimal solution would again be one of lowest cost. • For a 2-player game: • If the solution is simply a move to be made, an optimal solution would be the best possible move that can be made in a given situation. • If the solution is considered a complete strategy subgraph, then an optimal solution might be one that forces a win in the fewest number of moves in the worst case.

  35. Combinatorial Explosion • The number of different states of the problems above is enormous, and grows extremely fast as the problem size increases. • Examples for the number of different possibilities:

  36. Combinatorial Explosion • The combinatorial explosion of the number of possible states as a function of problem size is a key characteristic that separates artificial intelligence search algorithms in other areas of computer science. • Techniques that rely on storing all possibilities in memory, or even generating all possibilities, are out of the question except for the smallest of these problems. As a result, the problem-space graphs of AI problems are usually represented implicitly by specifying an initial state and a set of operators to generate new states.

  37. Search Algorithms • This course will focus on systematic search algorithms that are applicable to the different problem types, so that a central concern is their efficiency. • There are 3 primary measures of efficiency of a search algorithm: • The quality of the solution returned, is it optimal or not. • The running time of the algorithm. • The amount of memory required by the algorithm

  38. The Next Chapters Chapter 2 : brute force searches. Chapter 3 : heuristic search algorithms. Chapter 4 : search algorithms that run in linear space. Chapter 5 : search algorithms for the case where individual moves of a solution must be executed in the real world before a complete optimal solution can be computed. Chapter 6 : methods for deriving the heuristic function Chapter 7 : 2-player perfect-information games. Chapter 8 : analysis of alpha-beta minimax. Chapter 9 : games with more then 2 players. Chapter 10: the decision quality of minimax. Chapter 11: automatic learning of heuristic functions for 2-player games. Chapter 12: Constraint Satisfaction Problems. Chapter 13: parallel search algorithms.

  39. Chapter 2 Brute-Force Search

  40. Brute-Force Search • The most general search algorithms are Brute-Force searches, that do not use any domain specific knowledge. • It requires: • a state description • a set of legal operators • an initial state • a description of the goal state. • We will assume that all edges have unit cost. • To generate a node means to create the data structure corresponding to the that node. • To expand a node means to generate all the children of that node.

  41. Breadth-First Search (BFS) • BFS expands nodes in order of their depth from the root. • Generating one level of the tree at a time. • Implemented by first-in first-out (FIFO) queue. • At each cycle the node at the head of the queue is removed and expanded, and its children are placed at the end of the queue.

  42. 0 2 1 6 c 5 c 3 4 c 10 c 7 8 9 11 12 13 14 The numbers represent the order generated by BFS Breadth-First Search (BFS)

  43. Solution Quality • BFS continues until a goal node is generated. • Two ways to report the actual solution path: • Store with each node the sequence of moves made to reach that node. • Store with each node a pointer back to his parent - more memory efficient. • If a goal exists in the tree BFS will find a shortest path to a goal.

  44. Time Complexity • We assume : • each node can be generated in constant time • function of the branching factor b and the solution depth d • number of nodes depends on where at level d the goal node is found. • the worst case - have to generate all the nodes at level d. • N(b,d) - total number of nodes generated.

  45. Time Complexity Time Complexity of BFS is O(bd)

  46. Space Complexity • To report the solution we need to store all nodes generated. • Example: Machine speed = 100 MHz Generated a new state in 100 Instruction 106 nodes/sec node size = 4 bytes total memory = 1GB=109 byte nodes’ capacity=109/4=250*106 After 250 sec’ = 4 minutes the memory is exhausted ! Space Complexity=Time Complexity= O(bd)

  47. Space Complexity • The previous example based on current technology. • The problem won’t go away since as memories increase in size, processors get faster and our appetite to solve larger problem grows. • BFS and any algorithm that must store all the nodes are severely space-bound and will exhaust the memory in minutes.

  48. Depth-First Search (DFS) • DFS generates next a child of the deepest node that has not been completely expanded yet. • First Implementation is by last in first out (LIFO) stack. • At each cycle the node at the head of the stack is removed and expanded, and its children are placed on top of the stack.

  49. 0 2 1 10 c 9 c 3 4 c 8 c 5 6 7 11 12 13 14 The numbers represent the order generated by DFS DFS - stack implementation

  50. Depth-First Search (DFS) • Second Implementation is recursive. • The recursive function takes a node as an argument and perform DFS below that node. This function will loop through each of the node’s children and make a recursive call to perform a DFS below each of the children in turn.

More Related