1 / 33

Searching

Searching. Introduction to problem solving. What is problem solving? The activities that we usually consider to require intelligence are those that call for thinking and reasoning– for example, solving problems, proving theorems and playing games (e.g. chess)

fionnula
Download Presentation

Searching

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. Searching

  2. Introduction to problem solving • What is problem solving? • The activities that we usually consider to require intelligence are those that call for thinking and reasoning– for example, solving problems, proving theorems and playing games (e.g. chess) • To solve a problem is to find a solution, or in some cases the best solution, to it.

  3. Example • Consider walking from IFM, Shaaban Robert street to Mlimani City shopping centre… • Each location could be considered a knowledge state, and these knowledge states are linked by the actions performed at each of them (going straight on, turning left etc.)

  4. Example • The route we are describing, drawn on a map of Dar es Salaam, is a path from state to state • starting with starting point (start state) • to the finishing point (goal state). • What we are doing is constructing a path through Dar es Salaam to satisfy the need to get to Mlimani City SC

  5. Problem space theory • Such problems are described by problem space theory • We construct a path through the problem space (possible location points in our example) to satisfy the need identified in the goal. • Assuming that we do not have complete knowledge of the problem area, we are trying to construct a path between the problem and the solution.

  6. Adversary and non-adversary problems • An adversary problemis one in which two or more people compete against each other. • E.g. chess. • Non-adversary problems are ones that do not involve another person (except in the role of problem setter). • E.g. puzzle, crossword.

  7. Game playing • Game playing is a special sort of problem solving in which the problem is to find a winning strategy or to find the best current move. • Successful strategies in AI research on game playing for games with two players, in which • each player always has complete information about the state of play • there is no element of chance. • Examples • Noughts and crosses, chess • Games with incomplete information

  8. 4 1 2 2 3 3 7 4 5 1 6 5 7 8 6 8 Non-adversary problems • The 8-puzzle- a 3 x 3 square containing the numbers 1 to 8 which must be moved via the vacant square until they are in order.

  9. Non-adversary problems • Cannibals and missionaries • Transport three Cannibals and three Missionaries across a river in a boat that can only hold two people, but that needs at least one to get it across the river. • Cannibals must never outnumber Missionaries on either bank, or the Missionaries will be eaten. • Jugs problems • Three jugs, A, B and C can hold 8, 5 and 3 liters respectively. • A is full; B and C are empty. • Find a sequence of pourings that leaves 4 liters in A and 4 liters in B.

  10. A C B Non-adversary problems • The towers of Hanoi(Edouard Lucas, 1883) • Three vertical pegs with four (or more) discs of decreasing size piled on one peg. • Transfer the discs to the second peg, moving only one disc at a time, and never placing a larger disc on top of a smaller one.

  11. The search problem • We’ll consider a problem soluble by searching if • the problem can be formulated in terms of a progression of states from some initial state to some target (or goal) state. • this progression can be enumerated through the application of some given set of actions (or operators). • these actions define some transformation of all, or part, of the state. • In problems, such as Cannibals and Missionaries or the Towers of Hanoi, all three are clearly specified • AI programs are relatively successful at solving these problems

  12. Search problem • In AI there are two main approaches to describing the search for solutions to problems: • problem-reduction representations • operators that divide goals into sub-goals • state space representations • operators that change one state of the world into another

  13. Problem reduction representation • In a problem reduction representation each operator divides one goal into a set of sub-goals that are easier to achieve. • Problem reduction depends on the fact that some sub-goals are so simple that they can be satisfied directly. • The aim of problem reduction is to analyse the main goal into components of this sort.

  14. A C B Towers of Hanoi • The overall goal is to move the four discs from A to B, moving only one disc at a time, never placing a larger disc on top of a smaller one. • This goal can be divided into three sub-goals: • Transfer the three smaller discs from A to C. • Transfer the largest disc from A to B. • Transfer the three smaller discs from C to B. • Of these goals, (1) and (3) can be reduced further, while (2) can be achieved directly, provided that (1) has been achieved.

  15. State space representation • The basic component of a state space representation is a state of the world or, rather, a state of that small part of the world that is relevant to the problem. • For example, in the Missionaries and Cannibals problem a typical state of the world might be: Left Bank Right Bank 2 Missionaries 1 Missionary 2 Cannibals 1 Cannibal Boat • The states of the world are linked by operators that can change one state into another.

  16. Operators • A solution to a problem is a sequence of operators that provides a path between the initial state and (one of) the goal state(s). • To find a solution, the operators must be applied to the initial state and/or the goal state according to a set of rules (or search strategy), until a path between those two states is discovered. • In everyday problems and problems that require a high degree of creative thinking, it is usual for one or more of the initial state, the goal state, and the operators to be ill-specified.

  17. Applying the operators • For example, the operator ‘Take one Missionary and one Cannibal from the Left Bank to the Right Bank in the boat’ results in the following new state: Left BankRight BankLeft Bank Right Bank 2 Missionaries 1 Missionary 1 Missionary 2 Missionaries 2 Cannibals 1 Missionary 1 Cannibal 2 Cannibals Boat Boat • From each state it is (usually) possible to reach several others by applying different operators.

  18. State spaces • A map of all states that can be reached from the initial state by the application of one or more operators is called a state space. • State spaces can be represented by tree diagrams, with the initial state at the top, and paths to other states branching beneath it.

  19. State spaces • For many problems such tree diagrams can be extended indefinitely. • Solutions to a problem, if there are any, are represented by paths through the tree from the initial state to (one of) the goal state(s).

  20. Tree representation • In a tree representation the same state will appear more than once if it can be reached in several ways from the initial state.

  21. Tree representation • It is sometimes useful to use state space representations in which all occurrences of the same state are collapsed (overlapped). • Such representations are graphs rather than trees. • Graph theory • Every problem has a different search space • We want a general solution that may be applied to any search space. • We need an abstract formal framework for constructing and analysing search spaces.

  22. Graph terminology • A graph is defined as a set of nodes, with links between them (also called vertices and edges). • Links may be directed (denoted by arrows) or undirected. • A path is a sequence of nodes that connects two nodes via links.

  23. Graph terminology • An acyclic graph is a graph that contains no cycles (paths that link a node to itself). • The parents of a node N, are all the nodes that have links leading to N. • The children of a node N, are all the nodes that N provides a link to.

  24. A A D D C C E E B B A directed graph A (labeled) graph A D C E F B An acyclic directed graph Example graphs A D C E F B A directed graph with a cycle

  25. Tree terminology • A tree is a graph where each node has at most one parent. • Trees are always directed. • The root node of a tree is the only node that has no parent (each tree has a root) • For any node N, all the other nodes that have the same parent as N are called siblings of N. • For a node N, all the nodes whose paths pass through N (but not N itself) are considered descendents of N. • Similarly, N is considered an ancestor of its descendents. • Nodes with no children are called leaf nodes.

  26. School Factory Hospital Newsagent Church Library Park University A route-finding example • Suppose we want to find the route from the Library (L) to the University (U).

  27. We can represent the town map more abstractly Each state is a location The only action is to drive from one location to another. The initial state (L) is used as the root of the tree, and referred to as the start node. Now, rather than talking about a route from the library to the university, we can talk about finding a path from the start node (L) to the goal state - here node (U). L (Library) S (School) H (Hospital) F (Factory) P (Park) N (Newsagent) U (University) C (Church) Search space Do you see a problem with this tree?

  28. Key: M = Missionary C = Cannibal * = Boat LB = Left bank LB: MMMCCC* RB = Right bank RB: Boat: Boat: MC CC LB: LB: MMCC MMMC RB: RB: MC* CC* Boat: Boat: C CC LB: LB: MMMCC* MMMCCC* RB: C RB: Missionaries and cannibals

  29. Well-defined problems • A problem can be formally defined by • The initial state • Possible actions (operators) • Goal test – to determine if a given state is a goal • Explicit list of goal states • Property of the goal state (‘chess’) • Path cost – assigns a numeric cost to each path • A solution to a problem is a path from the initial state to a goal state. • Quality of a solution is measured by the path cost • Optimal solution has the lowest cost

  30. 8 2 3 4 7 5 1 6 8 2 7 3 4 5 1 6 8 2 8 4 8 2 8 2 2 3 4 7 3 4 7 3 4 7 3 7 5 1 6 5 1 6 5 1 6 5 1 6 Search nodes ≠ States If states are allowed to be revisited, the search tree may be infinite even when the state space is finite

  31. Uninformed vs. informed search • Uninformed (blind) search • no information about the number of steps or the path cost from the current state to the goal — all they can do is distinguishing a goal state from a non-goal state • Informed search (or heuristic search) • use information (heuristics) guesses about the search space

  32. Measuring performance • Completeness • Is the algorithm guaranteed to find a solution when there is one? • Optimality • Does the strategy find the optimal (highest-quality) solution when there are several different solutions?

  33. Measuring performance • Time complexity • How long does it take to find a solution? • Space complexity • How much memory does it need to perform the search?

More Related