Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Artificial Intelligence

Similar presentations


Presentation on theme: "Introduction to Artificial Intelligence"— Presentation transcript:

1 Introduction to Artificial Intelligence
Lecture # 5

2 Problems, Problems Spaces and Search

3 To build a system to solve a problem
Define the problem precisely. Analyze the problem. Isolate and represent the task knowledge that is necessary to solve the problem. Choose the best problem-solving techniques and apply it to the particular problem.

4 Defining a Problem as State Space Search
A problem can be solved by examining the steps which might be taken towards its solution. Each action takes the solver to a new state. A typical problem is when the agent is in one state, it has a set of deterministic actions it can carry out, and wants to get to a goal state. State Space: the set of all states reachable from the initial state by any sequence of actions.

5 Well-Defined Problems
problems with a readily available formal specification initial state starting point from which the agent sets out actions (operators, successor functions) describe the set of possible actions state space set of all states reachable from the initial state by any sequence of actions path sequence of actions leading from one state in the state space to another goal test determines if a given state is the goal state

6 Well-Defined Problems (cont.)
solution path from the initial state to a goal state search cost time and memory required to calculate a solution path cost determines the expenses of the agent for executing the actions in a path sum of the costs of the individual actions in a path total cost sum of search cost and path cost overall cost for finding a solution

7 Defining a Problem as State Space Search
The classic example is of the Farmer who needs to transport a Goose, a Fox and some Grain across a river one at a time. The Fox will eat the Goose if left unsupervised. Likewise the Goose will eat the Grain. In this case, the State is described by the positions of the Farmer, Goose, Fox and Grain. The solver can move between States by making a legal move. Non-legal moves are not worth examining.( Cannot take the two together)

8 Example

9 Performing a State Space Search
State space search involves finding a path from the initial state of a search problem to a goal state. To do this, we build a search graph, starting from the initial state (or the goal state) We expand a state by applying the search operators to that state, generating ALL of its successor states. These successors are in the next level down of the search graph The order in which we choose states for expansion is determined by the search strategy Different strategies result in (sometimes masively) different behaviour KEY CONCEPT: We want to find the solution while realizing in memory as few as possible of the nodes in the search space.

10 State Space Search Measuring effectiveness/performance:
Does the method find a solution at all? Is it a good solution (low path cost) What is the search cost? The total cost is the sum of the search cost and the path cost (which may not be commensurate!) the search cost--how long the agent takes to come up with the solution to the problem, and the path cost--how expensive the actions in the solution are. The total cost of the solution is the sum of the above two quantities.

11 Example Problems toy problems real-world problems vacuum world
8-puzzle 8-queens cryptarithmetic vacuum agent missionaries and cannibals real-world problems route finding touring problems traveling salesperson VLSI layout robot navigation assembly sequencing Web search

12 State Space

13 Structure of a State Space

14 State Space Graph versus Search Trees

15 State Space Graph versus Search Trees

16 Trees and Graphs

17 The travelling salesman problem, an example

18 The travelling salesman problem, an example

19 Production System A production system (or production rule system) is a computer program typically used to provide some form of artificial intelligence, which consists primarily of a set of rules about behavior. These rules, termed productions, are a basic representation found useful in automated planning, expert systems and action selection. A production system provides the mechanism necessary to execute productions in order to achieve some goal for the system.

20 Production system Collection of states – Start (or initial) state.
– Goal state or states). Collection of productions: rules or moves p - Each production may have preconditions. Control system: decides which production to apply next

21 Formal Description of the problem
Define a state space that contains all the possible configurations of the relevant objects. Specify one or more states within that space that describe possible situations from which the problem solving process may start ( initial state) Specify one or more states that would be acceptable as solutions to the problem. ( goal states) Specify a set of rules that describe the actions ( operations) available.

22 Water Jug Problem

23 State Space Search: Water Jug Problem
State: (x, y) x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3 Start state: (0, 0). Goal state: (2, n) for any n. Attempting to end up in a goal state.

24

25 Production rules for Water Jug Problem

26 Water Jug Problem Through Graph Search, the following solution is found :

27 Problem: Sort a string Input: a string, e.g., cbaca
Output: the sorted string, aabcc Write a program to sort a string. What are the space and time complexities? Instead of a programming language, use production system to solve this problem. No program to write.

28 Production system: example

29 Example: The 8-puzzle states? actions? goal test? path cost?
[Note: optimal solution of n-Puzzle family is NP-hard]

30 8-Puzzle states initial state successor function (operators) goal test
location of tiles (including blank tile) initial state any legitimate configuration successor function (operators) move tile alternatively: move blank goal test any legitimate configuration of tiles path cost one unit per move Properties: abstraction leads to discrete configurations, discrete moves, deterministic 9!/2 = 181,440 reachable states

31 Search tree for 8-puzzle

32 Example: n-queens Put n queens on an n × n board with no two queens on the same row, column, or diagonal

33 8-Queens incremental formulation complete-state formulation
states arrangement of up to 8 queens on the board initial state empty board successor function (operators) add a queen to any square goal test all queens on board no queen attacked path cost irrelevant (all solutions equally valid) Properties: 3*1014 possible sequences; can be reduced to 2,057 complete-state formulation states arrangement of 8 queens on the board initial state all 8 queens on board successor function (operators) move a queen to a different square goal test no queen attacked path cost irrelevant (all solutions equally valid) Properties: good strategies can reduce the number of possible sequences considerably

34 Control Strategies How to decide which rule to apply next during the process of searching for a solution to a problem? Requirements of good control strategy It causes motion Otherwise, it will never lead to a solution. 2. It is systematic Otherwise, it may use more steps than necessary. 3. It is efficient Find a good, but not necessarily the best, answer.

35 Search Strategies 1. Uninformed search (blind search) Having no information about the number of steps from the current state to the goal.(e.g. breadth first search, depth first search) 2. Informed search (heuristic search) More efficient than uninformed search.

36 Uninformed Search Strategies
Uninformed Search : strategies that order nodes without using any domain specific information, i.e., don’t use any information stored in a state BFS: breadth-first search – Queue (FIFO) used for the Frontier list – remove from front, add to back DFS: depth-first search – Stack (LIFO) used for the Frontier list – remove from front, add to front

37 Breadth-first search Breadth-first search is a simple strategy in which the root node is expanded first, then all the successors of the root node are expanded next, then their successors, and so on. In general, all the nodes are expanded at a given depth in the search tree before any nodes at the next level are expanded.

38 Breadth-first search Expand the shallowest node first: 1. Examine states one step away from the initial states 2. Examine states two steps away from the initial states 3. and so on

39

40

41

42

43

44 Breadth First Search

45

46

47 Another Example

48 Breadth-First Search Example

49 Advantages of BFS BFS will not get trapped exploring a blind alley.
If there is a solution, BFS is guaranteed to find it. If there are multiple solutions, then a minimal solution will be found.

50 Depth First Search A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path The deepest node is expanded first Backtrack when the path cannot be further expanded

51 Depth First Search

52 Algorithm: Depth First Search
If the initial state is a goal state, quit and return success Otherwise, do the following until success or failure is signaled: Generate a successor, E, of initial state. If there are no more successors, signal failure. Call Depth-First Search, with E as the initial state If success is returned, signal success. Otherwise continue in this loop.

53 Depth First Search

54 Depth First Search

55

56

57 And so on… till the last node

58

59 Backtracking We pursue a single branch of the tree until it yields a solution or until a decision to terminate the path is made. It makes sense to terminate a path if it reaches dead-end, produces a previous state. In such a state backtracking occurs Chronological Backtracking: Order in which steps are undone depends only on the temporal sequence in which steps were initially made. Specifically most recent step is always the first to be undone. This is also simple backtracking.

60 Depth-first Search Example

61 Advantages of Depth-First Search
DFS requires less memory since only the nodes on the current path are stored. By chance, DFS may find a solution without examining much of the search space at all.

62 Search Strategies

63 For BFS

64 For DFS

65 Breadth First Search Vs Depth First Search

66 END OF LECTURE # 5


Download ppt "Introduction to Artificial Intelligence"

Similar presentations


Ads by Google