WAES 3308 Numerical Methods for AI

36
WAES 3308 Numerical Methods for AI Searching Algorithm WEK070139 Wong Yik Foong WEK070134 Tee Jing Hong

description

WAES 3308 Numerical Methods for AI. Searching Algorithm WEK070139 Wong Yik FoongWEK070134Tee Jing Hong. Introduction. Searching algorithm:- Is an algorithm for finding an item with specified properties among a collection of items. - PowerPoint PPT Presentation

Transcript of WAES 3308 Numerical Methods for AI

Slide 1

WAES 3308 Numerical Methods for AISearching Algorithm

WEK070139 Wong Yik FoongWEK070134Tee Jing HongIntroductionSearching algorithm:-Is an algorithm for finding an item with specified properties among a collection of items.Is a problem-solving technique that systematically explores a space of problem states, e.g. puzzle game, chess game, etc.We concentrate on:-Depth first searchBreadth first searchA* search

Depth-First SearchAn algorithm for traversing or searching a tree, tree structure, or graph.How it works?Begin at the root and explores as far as possible along each branch before backtracking to other branch.

Depth-First SearchThe diagram shows the sequence of the moves until the goal is found using depth-first search.Start with the root node (1)Search the nodes within the same branch before proceeding to next.It takes 10 nodes to examine until the goal is found.

4Breadth-First SearchA technique of searching through a tree whereby all nodes in a tree at same level are searched before searching nodes at next level.How it works?It will check all nodes of a lower hierarchy first before further descending to higher ones.Breadth-First SearchThe diagram show the sequences of moves by using breadth-first search. Start with the root node (1)Search the nodes within same level first before proceeding to next.It takes 4 nodes to examine until the goal is found.

A* SearchA* is a best-first search algorithm that finds the least-cost path from a given initial node to one goal node.A* is a network searching algorithm that takes a "distance-to-goal + path-cost" score into consideration.

Best-first search : a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule.7Example of implementation1) Puzzle game

Initial state Our goal Number from 1 to 8 are arranged in 3x3 fieldAn empty spot that can move adjacent number to in order to change their state representation configuration of the puzzle

Knowledge representation for puzzle gameUsing 2-dimension array in C, Java, C# and etc.Every number in the puzzle can be stored using the respective integer Empty spot can store as -1 or any other integer that is not use in the puzzle tiles9Initial state3 possible states from current state :1. move down 42. move right 83. move left 6

ContinueTo make life more easy, we assume we are moving the empty spot instead of the number tiles.Diagram below show the next 3 possible state

2) Searching tree * / | \ x x $ / | \ / | \ / | \ x x x x x x x x xWhere* is the root of the treex is a node of the tree$ is the goal node of the tree/ is an edge of the treeUsing depth-firstthe most intuitive and naive strategyDisadvantage in this case: does not guarantee to find the best solution which normally is referred to as the shallowest goal in the tree/graph.Worse case : the search tree has infinite depth(may cause impossible to find solution)Why shallowest goal is the best solution?Because it mean the path (distance) from starting state to solution will be the shortest13ContinueDiagram above show the sequence of traversed node using depth-first searchTake 10 steps to find the solutionNot that bad as the best goal is found

14But how if There is 2 solutions in the search tree? ($1 and $2)

Or more worse whenWhen search tree has an infinite depth, the goal may not be found at all

Using breath-firstHas advantage over depth-first search in this example because it guarantees to always find the best solution in the first tryDisadvantage : cause additional to exponential time complexity, because breath-first search will check all nodes of a lower hierarchy before further descending to higher onesContinueDiagram above show the sequence of traversed node using breath-first searchObviously, this guarantees it finds the shallowest solution

Using A* searchEstimation of how far a node might be away from the actual goal turns out to be very helpful. A good measurement may reach the goal from root like this :

ContinueThe next node to be traversed is determined by:The cost of reaching that node The estimated rest cost of finding the goal from that nodeMore detail about A* will be in the next example203) A* Search ExampleThe diagram illustrated with green box(the starting point, A), red box(the ending point, B) and the blue filled squares being the wall in between.

The first thing you should notice is that we have divided our search area into a square grid. Simplifying the searcharea, as we have done here, is the first step in path finding.

This particular method reduces our search area to a simple two dimensional array. Each item in the array represents one of the squares on the grid, and its status is recorded as walkable or unwalkable.

The path is found by figuring out which squares we should take to get from A to B. Once the path is found, our person moves from the center of one square to the center of the next until the target is reached. 21Algorithm: Begin at the starting point A and add it to an open list of squares to be considered. Look at all the reachable or walkable squares adjacent to the starting point, ignoring squares with walls, water, or other illegal terrain. Add them to the open list. For each of these squares, save point A as its parent square. Drop the starting square A from your open list, and add it to a closed list.

- A closed list of squares is the square that dont need to look at again for now.

Dark green square is the starting square.It is outlined in light green to indicate that the square has been added to the closed list.All of the adjacent squares are now on the open list of squares to be checked, and they are outlined in light green.A gray pointer that points back to its parent

Which square do we choose?The one with the lowest F cost.Path Scoring, F = G + H where G = the movement cost to move from the starting point A to a given square on the grid, following the path generated to get there.H = the estimated movement cost to move from that given square on the grid to the final destination, point B.

We begin the search by doing the following:1. Begin at the starting point A and add it to an open list of squares to be considered. The open list is kind of like a shopping list. Right now there is just one item on the list, but we will have more later. It contains squares that might fall along the path you want to take, but maybe not. Basically, this is a list of squares that need to be checked out. 2. Look at all the reachable or walkable squares adjacent to the starting point, ignoring squares with walls, water, or other illegal terrain. Add them to the open list, too. For each of these squares, save point A as its parent square. This parent square stuff is important when we want to trace our path. It will be explained more later.3. Drop the starting square A from your open list, and add it to a closed list of squares that you dont need to look at again for now.

25Continue search4. Drop it from the open list and add it to the closed list.5. Check all of the adjacent squares. Ignoring those that are on the closed list or unwalkable (terrain with walls, water, or other illegal terrain), add squares to the open list if they are not on the open list already. Make the selected square the parent of the new squares.Continue search6. If an adjacent square is already on the open list, check to see if this path to that square is a better one. In other words, check to see if the G score for that square is lower if we use the current square to get there. If not, dont do anything. On the other hand, if the G cost of the new path is lower, change the parent of the adjacent square to the selected square. Finally, recalculate both the F and G scores of that square.

To continue the search, we simply choose the lowest F score square from all those that are on the open list. Wethen do the following with the selected square:

4) Drop it from the open list and add it to the closed list.

5) Check all of the adjacent squares. Ignoring those that are on the closed list or unwalkable (terrain with walls,water, or other illegal terrain), add squares to the open list if they are not on the open list already. Make theselected square the parent of the new squares.

6) If an adjacent square is already on the open list, check to see if this path to that square is a better one. Inother words, check to see if the G score for that square is lower if we use the current square to get there. Ifnot, dont do anything. On the other hand, if the G cost of the new path is lower, change the parent of the adjacent square to theselected square (in the diagram above, change the direction of the pointer to point at the selected square).Finally, recalculate both the F and G scores of that square. If this seems confusing, you will see it illustratedbelow.

28

29

Summary of the A* Method1) Add the starting square (or node) to the open list. 2)Repeat the following:a) Look for the lowest F cost square on the open list.b) Switch it to the closed list. c) For each of the 8 squares adjacent to this current square If it is not walkable or if it is on the closed list, ignore it. Otherwise do the following. If it isnt on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square. If it is on the open list already, check to see if this path to that square is better, using G cost as the measure. A lower G cost means that this is a better path. If so, change the parent of the square to the current square, and recalculate the G and F scores of the square. If you are keeping your open list sorted by F score, you may need to resort the list to account for the change. d) Stop when you:Add the target square to the closed list, in which case the path has been found (see note below), orFail to find the target square, and the open list is empty. In this case, there is no path. 3)Save the path. Working backwards from the target square, go from each square to its parent square until reach the starting square. That is the path.

Google PageRankPageRank is most important technique for Google to verify the ranking of the webpage.Methods:Find all the related web pages based on the keywordsBased on the title and the occurrence of keyword to arrange the level of the web pagesCalculate the keywords inside the inbound link pagesBased on the PageRank scoring to adjust the website ranking on the SERP (Search Engine Results Page)Google PageRankIf page B have a link to page A (B is inbound link of A), then B think A have linking value, considered as a vote from page B to page A.Votes cast by pages that are themselves "important" weigh more heavily and help to make other pages "important".When B ranking is high, then A will based on the inbound link, B to receive certain rank and the score will separate averagely to all of the outbound link of A.

Thank you