Top Banner
1 Problem Solving: Search Techniques SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi
91

1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

Jan 02, 2016

Download

Documents

Oliver Kennedy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

1

Problem Solving: Search Techniques

SCCS451 Artificial Intelligence

Asst. Prof. Dr. Sukanya PongsuparbDr. Srisupa Palakvangsa Na AyudhyaDr. Benjarath Pupacdi

Page 2: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

2

Our problem is to find a path from S to G

S

G

Occupied

Free

Page 3: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

3

Convert to tree/graph

Space Representation Equivalent Tree

Page 4: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

4

What we want to do is…

Once you have your graph you need to search for the best pathTo find a solution when we are not given an algorithm to solve a problem, but only a specification of what a solution looks like

IDEA: Search for a solution

Page 5: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

5

What is “Search”?

Search Algorithm An algorithm that takes a problem as inputreturns a solution to the problem, usually after evaluating a number of possible solutions

An important aspect of search algorithm is goal-based problem solving

Page 6: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

6

Where to search?

Search from the set of all possible solutions of a problemCalled “search space”

Page 7: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

7

How to search?

How to searchStart at the start stateConsider the effect of taking different actions starting fromstates that have been encountered in the search so farStop when a goal state is encountered

A solution is a path in a state space from a start node to a goal node (there can be many goal nodes)The cost of a solution is the sum of the arc costs on the solution path

Page 8: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

8

What is “goal-based” problem solving?

Goal formationBased upon the current situation and performance measuresResult is moving into a desirable state (goal state)

Problem formationDetermining actions and states to consider given the goal

ObjectiveSelect the best sequence of actions and states to attain goal

Page 9: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

9

Example

Chess GameEach board configuration can be thought of representing a different state of the game.A change of state occurs when one of the player moves a piece.A goal state is any of the possible board configurations corresponding to a checkmate.

e2 to e4

Page 10: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

10

Example (cont.)

Chess game has more than 10120 possible states.Winning a game amounts to finding a sequence of states through many possible states that leads to one of goal states, i.e. a check mate state.An intelligent chess playing program would not play the game by exploring all possible moves.Potential hypotheses must be considered before a good one is chosen.

Page 11: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

11

Example (cont.)

Other examples using search techniquessearch to find matching words from a dictionary, sentence constructions, and matching contextsTo perceive an image, program searches must be performed to find model patterns that match input scenes

Page 12: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

12

Preliminary Concept

Programs can be characterized as a space consisting of a set of states, and a set of operators that map from one state to other statesType of States

one or more of initial state – the starting pointa number of intermediate statesone or more goal states

Page 13: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

13

Well-defined “goal-based” problem

Initial stateOperator or successor function - for any state x returns s(x), the set of states reachable from x with one actionState space - all states reachable from the initial state by any sequence of actionsPath - sequence through state spacePath cost - function that assigns a cost to a path. Cost of a path is the sum of costs of individual actions along the pathGoal test - test to determine if at goal stateGoal - a sequence of operations that map an initial state to a goal state

Page 14: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

14

Example

Page 15: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

15

How to tell which algorithm is better?

Completenessif at least one solution exists, the algorithm is guaranteed to find a solution within a finite amount of time

Time Complexitythe worst-case amount of time that the algorithm takes to run

Space Complexitythe worst-case amount of memory that the algorithm uses

OptimalityIf a solution is found, is it guaranteed to be an optimal one? That is, is it the one with minimum cost?

Page 16: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

16

How to tell which algorithm is better? (cont.)

good solution - requires the fewest operations or the least cost to map from an initial state to a goal state.Time and space complexities of an algorithms may be defined in terms of their best, their average, or their worst-case performance in completing some task

Page 17: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

17

How to implement our search space?

Page 18: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

18

Graph and Tree Representation

Page 19: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

19

Graph and Tree Representation

Traditionally a search space is represented as a diagram of a directed graph or a tree.

Each node or vertex in the graph corresponds to a problem state.Arcs between nodes correspond to transformations or mappings between the states.

A tree is a graph which each node has at most one parent.The immediate successors of a node are referred to as children, sibling or offspring.The predecessor nodes are ancestors.An immediate ancestor to a node is a parent.

Page 20: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

20

“Search”… “Search”… and “Search”

Search Procedure is a strategy to select the order in which nodes are generated and a given path selectedThe aim of search is not to produce complete physical trees in memory, but rather explore as little of the virtual tree looking for root-goal paths.

Search problems could be classified into two groups according to information used to carry out a given strategy:

Uninformed SearchInformed Search

Page 21: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

21

Uninformed Search (or Blind Search)

Orders nodes without using any domain specific information (blindly followed)This algorithm uses the initial state, the search operators, and a test to find a solution.A blind search should proceed in systematic way by exploring nodes in some pre-determined order.Implemented in general with the same implementation for various problems

Page 22: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

22

Uninformed Search (or Blind Search) (cont.)

Drawbackdoes not take into account the specific nature of the problemmost search spaces are extremely large, and an uninformed search (especially of a tree or graph) will take a reasonable amount of time only for small examples.

ExampleBreadth-First SearchDepth-First SearchDepth-First Iterative Deepening Search

Page 23: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

23

Informed Search

Informed search tries to reduce the amount of search that must be done by making intelligent choices for the nodes that are selected for exploration and expansion. This implies that there are methods to evaluate the likelihood that given nodes are on solution pathsa heuristic that is specific to the problem is used as a guideExample

Hill Climbing MethodBest-First SearchA* SearchBranch-and-Bound Search

Page 24: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

24

Example of Search Problems

Eight Puzzles

Travelling Salesman Problem

Page 25: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

25

Example: 8 Puzzles

Initial State

8 3 5

6 1

2 4 7

1 2 3

8 4

7 6 5

Goal State

Page 26: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

26

State Space Definition of 8-Puzzle

State description: position of each of the 8 tiles in one of 9 squares (or 3x3 board)

Operators: blank position moves up, down, left, or right

Goal Test: current state matches goal configuration illustrated in the previous slide

Path cost: each move is assigned a cost of 1.

Page 27: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

27

8 Puzzles (cont.)

An optimal or good solution is one that maps an initial arrangement of tiles to the goal configuration with the smallest number of moves.

The search space for the eight puzzle problem is depicted as the tree structure

Page 28: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

28

8 puzzle Search Space

Page 29: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

29

8 Puzzles (cont.)

In the tree structure, the nodes are depicted as puzzle configurationsthe root node represents a randomly chosen starting configurationits successor nodes correspond to the movements that are possibleA path is a sequence of nodes starting from the root and progressing downward to the goal node

Page 30: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

30

Travelling Salesman Problem

Given a list of cities and their pair wise distances, the task is to find a shortest possible tour that visits each city exactly once.

an exponential amount of time is needed to solve e.g. a minimal solution with only 10 cities is 10! (3,628,800 tours).

Page 31: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

31

Examples of Uninformed Search

Breadth-First Search

Depth-First Search

Depth-First Iterative Deepening Search

Page 32: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

32

Breadth-First Search (BFS)

Breadth-First Search are performed by exploring all nodes at a given depth before proceeding to the next level.

Advantage: Always finding a minimum path length solution when one exists.

Disadvantage: A great many nodes may need to be explored before a solution is found.

Page 33: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

33

Example: Map Navigation

S G

A B

D E

C

F

State Space:S = start, G = goal, other nodes = intermediate states, links = legal transitions

Page 34: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

34

BFS Search Tree

SS G

A B

D E

C

F

Queue = {S}

Select S

Goal(S) = true?

If not, Expand(S)

Page 35: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

35

BFS Search Tree

SS G

A B

D E

C

FA D

Queue = {A, D}

Select A

Goal(A) = true?

If not, Expand(A)

Page 36: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

36

BFS Search Tree

SS G

A B

D E

C

FA D

B D Queue = {D, B, D}

Select D

Goal(D) = true?

If not, expand(D)

Page 37: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

37

BFS Search Tree

SS G

A B

D E

C

FA D

A EB D Queue = {B, D, A, E}

Select Betc.

Page 38: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

38

BFS Search Tree

SS G

A B

D E

C

FA D

A EB D

B FE S E S BC

Level 3Queue = {C, E, S, E, S, B, B, F}

Page 39: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

39

BFS Search Tree

SS G

A B

D E

C

FA D

A EB D

B FE S E S B

GD F B FA D C E A C

C

Level 4Expand queue until G is at frontSelect GGoal(G) = true

Page 40: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

40

BFS

Page 41: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

41

Examples of Uninformed Search

Breadth-First Search

Depth-First Search

Depth-First Iterative Deepening Search

Page 42: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

42

Depth First Search

Depth-first searches are performed by diving downward into a tree.It generates a child node from the most recently expand node, then generating that child’s children, and so on until a goal is found, or some cutoff depth point d is reached. If a goal is not found when a leaf node is reached or at the cutoff point, the program backtracks to the most recently expanded node and generates another of its children.This process continues until a goal is found or failure occurs

Page 43: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

43

Depth First Search (cont.)

The depth-first is preferred over the breadth-first when the search tree is known to have a plentiful number of goals.

The depth cutoff introduces some problems. If it is set too shallow, goals may be missed. If set too deep, extra computation may be performed.

Page 44: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

44

DFS Search Tree

SS G

A B

D E

C

FA D

Stack = {A,D}

Page 45: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

45

DFS Search Tree

SS G

A B

D E

C

FA D

B DStack = {B,D,D}

Page 46: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

46

DFS Search Tree

SS G

A B

D E

C

FA D

B D

EC

Stack = {C,E,D,D}

Page 47: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

47

DFS Search Tree

SS G

A B

D E

C

FA D

B D

E

D F

C

Stack = {D,F,D,D}

Page 48: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

48

DFS Search Tree

SS G

A B

D E

C

FA D

B D

E

D F

C

G

Stack = {G,D,D}

Page 49: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

49

DFS

Page 50: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

50

Depth-First Search with a depth-limit

Suppose we set the depth limit = 3, then we won’t reach the goal node.

Page 51: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

51

Depth-First Search with a depth-limit

For the sake of argument, suppose node 16 is a goal node, then setting the depth limit = 3 will allow us to reach a goal.

Page 52: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

52

Examples of Uninformed Search

Breadth-First Search

Depth-First Search

Depth-First Iterative Deepening Search

Page 53: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

53

Depth First Iterative Deepening Search (IDS)

Run multiple DFS searches with increasing depth-limitsProcedure

L = 1While no solution, do

DFS from initial state S0 with cutoff L If found goal, stop and return solution, else, increment depth limit L

Page 54: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

54

Depth First Iterative Deepening Search (cont.)

Advantage: It is guaranteed to find a shortest-path solution.

Disadvantage: It performs wasted computations before reaching a goal depth. (In many cases, this is okay as the number of nodes up top of the tree isn’t that high.)

Page 55: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

55

Iterative deepening search L=0

Page 56: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

56

Iterative deepening search L=1

Page 57: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

57

Iterative deepening search L=2

Page 58: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

58

Iterative Deepening Search L=3

Page 59: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

59

Iterative deepening search

Page 60: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

60

Informed Search

Use heuristic information to guide the search“heuristic” is a rule of thumb or judgmental technique that sometime leads to a solution, but provides no guarantee of successHeuristic Information - Information about the problem such as

the nature of the statesthe cost of transforming from one state to anotherthe promise of taking a certain path

Page 61: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

61

Informed Search (cont.)

Heuristic function - expressed in the form of a heuristic evaluation function

f(n,g) where n is a node and g is the goal

Heuristics help to reduce the number of alternatives from an exponential number to a polynomial number in order to obtain a solution in a tolerable amount of time.

Page 62: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

62

Examples of Informed Search

Hill Climbing Method

Best-First Search

A* Search

Branch-and-Bound Search

Page 63: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

63

Informed Search: Hill Climbing Method

Hill Climbing is a mathematical optimization technique which belongs to the family of local search. (wiki)

"Like climbing Everest in thick fog with amnesia"

Page 64: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

64

Hill Climbing Method (cont.)

Hill climbing attempts to maximize (or minimize) a function f(x), where x are discrete states. Hill climbing will follow the graph from vertex to vertex, always locally increasing (or decreasing) the value of f, until a local maximum (or local minimum) xm is reached. Hill climbing can also operate on a continuous space: in that case, the algorithm is called gradient ascent (or gradient descent if the function is minimized).

Wikipedia

Page 65: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

65

Hill Climbing Method (cont.)

Hill climbing is like depth-first searching where the most promising child is selected for expansion.

When the children have been generated, alternative choices are evaluated using some type of heuristic function.

Page 66: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

66

Hill Climbing Method (cont.)

The path that appears most promising is then chosen and no further reference to the parent or other children is retained.

This process continues from node-to-node with previously expanded nodes being discarded.

Page 67: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

67

Hill Climbing Method (cont.)

Page 68: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

68

Hill Climbing Method (cont.)

Possible Problems: local maxima, ridges, plateau

Page 69: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

69

Hill Climbing Method (cont.)

ridge

Page 70: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

70

Examples of Informed Search

Hill Climbing Method

Best-First Search

A* Search

Branch-and-Bound Search

Page 71: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

71

Best First Search

Best-first search is a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule. (wikipedia)This search uses an evaluation function and always chooses the next node with the best scoreThis search can avoid potential traps encountered in Hill Climbing i.e. local maxima, ridges, and plateau It requires a good measure of goal distance.

Page 72: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

72

Hill-Climbing vs Best First Search

Hill-Climbing is a local search. A local search does not keep a history of its path (no frontier nodes stored), and only uses the neighbors to compute the heuristics. Therefore, hill-climbing saves on memory requirement, but its output is only a goal state, not the path from the starting state to the goal state.Example: integrated-circuit design, floor layoutIn Best-first search, we stores the frontier nodes.

Page 73: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

73

Examples of Informed Search

Hill Climbing Method

Best-First Search

A* Search

Branch-and-Bound Search

Page 74: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

74

A* Search

A* is a best-first graph search algorithm that finds the least-cost path from a given initial node to one goal node (out of one or more possible goals).

The algorithm traverses various paths from start to goal. For each node x traversed, it maintains 3 values:

g(x): the actual shortest distance traveled from initial node to current nodeh(x): the estimated (or "heuristic") distance from current node to goalf(x): g(x) + h(x)

Page 75: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

75

A* Search (cont.)

A* algorithm is a specialization of best-first search.

At each node, the A* algorithm generates all successor nodes and computes an estimate of distance (cost) from the start node to a goal node through each of successors.

Then, it chooses the successor with the shortest estimated distance for expansion.

Page 76: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

76

A* Search - Example

h(x)

= estimated cost to goal

8

7

6

9

S

6

5

8 7 6

4

3

2

5

5

4

3

6

4

5

6

5

3

4

5

2

3

4 3

G

1

2

1

1

2

3

2

Page 77: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

77

A* Search - Example (cont.)

1

2

3

2

S

1

2

1 2 3

5

6

7

4

6

7

8

5

5

6

7

4

6

7

8

7

8

9 10

G

12

11

8

10

11

12

9

g(x)

= actual cost from start to current nodes

Page 78: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

78

A* Search - Example (cont.)

8+1

7+2

6+3

9+2

S

6+1

5+2

8+1 7+2 6+3

4+5

3+6

2+7

5+4

5+6

4+7

3+8

6+5

4+5

5+6

6+7

5+4

3+6

4+7

5+8

2+7

3+8

4+9 3+10

G

1+12

2+11

1+8

1+10

2+11

3+12

2+9

f(x) = h(x) + g(x)

Page 79: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

79

A* Search - Example (cont.)

Graph

Open List

Closed List

S

S

G goal node

S start node

1

2

3

2

S

1

2

1 2 3

5

6

7

4

6

7

8

5

5

6

7

4

6

7

8

7

8

9 10

G

12

11

8

10

11

12

9

g(x)

8+1 node_successor_2

6+1 node_successor_3

8+1 node_successor_1

1

1

18+1

8+1

6+1

8+1

6+1

8+1

997

S

S

Page 80: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

80

A* Search - Example (cont.)

Graph

Open List

Closed List

S

G goal node

8+1

6+1

8+1

997

S

8+1

2

3

2

S

6+1

2

8+1 2 3

5

6

7

4

6

7

8

5

5

6

7

4

6

7

8

7

8

9 10

G

12

11

8

10

11

12

9

S

7 (6+1) current node

6+1

2

S

2

7+2 node_successor_2

5+2 node_successor_3

S node_successor_1

7+2

5+2

5+2

7+2

9

Page 81: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

81

A* Search - Example (cont.)

And so it continues until the goal node is popped off the open list…

Graph

Open List

Closed List

S

8+1

6+1

8+1

997

S

5+2

7+2

9

6+1

G goal node

8+1

7+2

3

2

S

6+1

5+2

8+1 2 3

5

6

7

4

6

7

8

5

5

6

7

4

6

7

8

7

8

9 10

G

12

11

8

10

11

12

9

Page 82: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

82

A* Search - Example (cont.)

8+1

7+2

3(9)

9+2

S

1(7)

2(7)

1(9) 2(9) 3(9)

5(9)

6(9)

7(9)

4(9)

5+6

4+7

3+8

6+5

5(9)

5+6

6

4(9)

6(9)

4+7

5

7(9)

3+8

4 3

G

1

2

8(9)

1

2

3

2+9

Final Result !!!

Page 83: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

83

Examples of Informed Search

Hill Climbing Method

Best-First Search

A* Search

Branch-and-Bound Search

Page 84: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

84

Branch-And-Bound Search

Branch and Bound (BB) is a general algorithm for finding optimal solutions of various optimization problems, especially in discrete and combinatorial optimization. Description of Steps:-

divide a feasible region into sub-regions find the lower and the upper bounds of each regionIf these values are equal for the global problem, the optimal value is found.perform this process recursively

Page 85: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

85

Branch-And-Bound Search (cont.)

Let’s define that the goal is to find the minimum of f(x)Functions involved:-

Branching – this process splits a given set S of candidates into subsets S1, S2, … of which vi is the minimum of f(x) within Si and min{v1, v2, …} is the minimum of f(x)Bounding - a procedure that computes upper and lower bounds for the minimum value of f(x) within a given subset SPruning – a procedure to remove a node A of which lower bound is greater than the upper bounds of other nodes

Page 86: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

86

Branch-And-Bound Search (cont.)

The recursion stops when the current candidate set S is reduced to a single element OR when the upper bound for set S matches the lower bound.Either way, any element of S will be a minimum of the function within S

Page 87: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

87

Branch-And-Bound Search - ExampleOptimization Problem: Search for the max value

(50, 1000)(5, 10)

(30, 100)

Page 88: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

88

Branch-And-Bound Search - Example

(800, 1000)

Optimization Problem: Search for the max value

(5, 10)

(30, 100) (50, 300)

Page 89: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

89

Branch-And-Bound Search - Example

(5, 10)

(30, 100) (50, 300)

(800, 900) (850, 990) (900, 1000)

Optimization Problem: Search for the max value

Page 90: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

90

Search Recap

Search

Uninformed search Informed search

Breadth-first search

Depth-first iterative

deepeningsearch

Depth first search

Hill climbing search

Best-first search

A* search

Branch-and-boundsearch

Page 91: 1 SCCS451 Artificial Intelligence Asst. Prof. Dr. Sukanya Pongsuparb Dr. Srisupa Palakvangsa Na Ayudhya Dr. Benjarath Pupacdi.

91

ReferencesWikiPediahttp://www-cs-students.stanford.edu/~amitp/http://www.cs.sandia.gov/opt/survey/http://qatar.cmu.edu/cs/16200/http://www.policyalmanac.org/games/aStarTutorial.htmwww.cs.ubc.ca/~kevinlb/teaching/cs322%20-%202006-7/Lectures/lect7.pdfbio.fsu.edu/~stevet/BSC5936/Swofford.F2003.2.pdf