1 / 34

Solving Problems by Searching

Solving Problems by Searching. By Sylvain Caron. Introduction.

Télécharger la présentation

Solving Problems by 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. Solving Problems by Searching By Sylvain Caron

  2. Introduction When dealing with problem solving, the user must remember to always consider all of the data that is available to him. This is often difficult to grasp since some search spaces are very large. In other cases, some problems are hard to solve because of the following; the problem is too complicated, the evaluation function varies too much with time, or the problem is too heavily constrained. My goal is to examine the basic steps that are taking when dealing with search in problem solving.

  3. Topics • Uninformed Search Strategies • Informed Search Algorithms • Constraint Satisfaction Problems • Example • Questions

  4. Uninformed Searches In uninformed search strategies, every possible solution is evaluated. - only used in small problems - can be time consuming but no error! There are four main uninformed search types: - breadth first search • depth first search • depth limited search • iterative deepening search.

  5. Breadth first search Breadth first search starts by searching the shallowest unexpanded node. This node is found at the top of the tree. It then works its way down evaluating each node at a time.

  6. Depth first search Depth first search searches trees a little differently. This algorithm also starts at the top of the tree, but explores as far as possible along each branches of the tree before using backtracking.

  7. Depth limited search A depth-limited search is just like a depth first search but with a search depth limit L. No node past this limit will be evaluated. This technique is most commonly used in infinite path problems.

  8. iterative deepening search The iterative deepening search applies the use of depth-limited search. This algorithm first starts applying depth-limited search with L=1. If a solution as not been found, L is increased by one. This procedure is repeated until a solution has been found, or until exhaustion.

  9. Informed Search Algorithms When dealing with a problem that has a search space that is too large or complex, we often use informed search algorithms. Informed refers to the fact that the user has some additional knowledge of the problem. This information is stored in a best-first search evaluation function f(n).

  10. Informed search Algorithms Two main informed search are 1- Greedy search 2- A* search

  11. Greedy search The Greedy search has a Heuristic function h(n). • h(n) >= 0 • h(n) = 0 is a goal node • h(n) = inf dead end This function will attempt to reach the goal the quickest by only exploring the nodes that have the lowest cost

  12. A* search To keep track of the paths we have already explored, and to avoid taking paths that are already expensive, we must define a function g(n) that keeps track of the cost so far to reach node n. We can then define the following evaluation functions. f(n) = g(n) + h(n)

  13. A* search

  14. Constraint Satisfaction Problems Constraint Satisfaction Problems are search problems that are bounded by constraints. Some common applications are: scheduling tasks, robot planning tasks, puzzles, and molecular structures. In this chapter we will look at binary Constraint Satisfaction Problems. Binary comes from the fact that the problem has two bits of information ; variables V, and domain D for each variable.

  15. Constraint Satisfaction ProblemsExample The following constraint problem serves as a benchmark problem. It is called the N-Queens problem. It involves placing N-Queens on an NxN chessboard so that no two queens can attack each other. The descriptions on variables and constrains are giving on the figure.

  16. Constraint Satisfaction ProblemsExample In this case the variables are different activities and the value is time allocated to those activities. A great example of this would be exam period scheduling for university courses. Some of the constraint attributed to this might be : no student can have two exams at the same time, no more than 500 students can be writing an exam at the same time, etc...

  17. Constraint Satisfaction ProblemsExample Suppose you want to colour regions of a graph with a given set of colours where no two adjacent regions can have the same colour. In this case the regions are the variable and the colour allowed are the values in the domain. Four Color Theorem is a proof showing that the use of four colours are sufficient enough to colour any planar map. This was well known for over a century but was only proven in 1976.

  18. Solving Constraint Satisfaction Problems Now that we know the variables, domains, and constraints of our problem, we must solve it. Solving Constraint Satisfaction Problems involves two major steps: constraint propagation, and search for a solution.

  19. Solving Constraint Satisfaction Problems Constraint propagation is the term used for verifying consistency of every arc. It is also used to eliminating the values that could not be part of our solution. Constrain propagation is as follows: Suppose two variables Vi and Vj, to assure arc consistency, then

  20. Solving Constraint Satisfaction Problems Consistency on the arc will be achieved once the values that do not fulfill the constraints are deleted from the domain Di. An informed or uninformed search strategy can now be used to solve the problem.

  21. Solving Constraint Satisfaction Problems Suppose we have six countries in total where three countries have already been coloured. Domain{ Red, Green, Blue, Yellow} and no two adjacent countries can have the same colour.

  22. Solving Constraint Satisfaction Problems If we attacked the following problem using a depth-first search, we might have to search through 64 different combination before obtaining our goal.

  23. Solving Constraint Satisfaction Problems • Using Constraint propagation we eliminate : • - Green and Blue for block E • Red for block D, and - Green for block F. • Reduced the possible combinations to 18, more than three times less than our original problem.

  24. Example 1- Specific Problem : Card game Four cards are dealt face up from the pack and two players take it in turn to put them into a 2x2 grid, with player 1 going first

  25. ExampleDefining the search space If we consider every possible solution, there would be 4! = 24

  26. Example 3- Dept-first and bread-first search.

  27. Questions Suppose we have the following graph where we wish to travel from point A to point D. The driver can take any route he wishes, as long as he does not return to a same location twice

  28. Questions a) Using a Greedy search, find a solution to this problem. Show the evaluation function at each step.

  29. Questions Solution The evaluation of a Greedy search is defined as f(x) = h(x). Hence, the solution is as follows. A B f(1) = h(1) = 3 D f(1) = h(2) = 0 Goal!! Cost = 3 + 11 = 14 Notice, this is not the optimal solution.

  30. Questions b) Find a solution to this problem using an A* search. Show the evaluation function at each step.

  31. Questions Solution The evaluation of an A* search is defined as f(x) = h(x) + g(x). A B f(x) = h(x) + g(x) = 3 + 3 = 6 C f(x) = h(x) + g(x) = 4 + (3 + 1) = 8 D f(x) = h(x) + g(x) = 0 + (3 + 1 + 4) = 8 Goal!! Cost = f(x) = g(x) = 8

  32. Questions c) Find the optimal solution using a bread-first search if no toll routes are allowed. Show a diagram of this solution.

  33. Questions From the graph, we can see that two arcs from the tree we stopped due to violation of the constraint. The optimal solution of this case would obviously be A,C,D with a cost of 12.

  34. Refrences • 1- http://www.doc.ic.ac.uk • 2-http://ocw.mit.edu • 3-http://www-g.eng.cam.ac.uk • 4- http://www.dbai.tuwien.ac.at • 5- http://pages.cs.wisc.edu • 6- Artificial Intelligence: A modern approach (3rded) by Stuart Russell and Peter Norvig

More Related