Problem Solving - Artificial Intelligence - Lecture Notes, Study notes of Artificial Intelligence

Main points of this lecture are: Problem, Solving, Approach, Generate, Test, Representation, Components, Solution.

Typology: Study notes

2011/2012

Uploaded on 10/24/2012

alia_maru
alia_maru 🇮🇳

4.5

(41)

57 documents

1 / 69

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
13
Artificial Intelligence
Lecture No. 04 - 11
1 Problem Solving
In chapter one, we discussed a few factors that demonstrate intelligence. Problem
solving was one of them when we referred to it using the examples of a mouse
searching a maze and the next number in the sequence problem.
Historically people viewed the phenomena of intelligence as strongly related to
problem solving. They used to think that the person who is able to solve more and
more problems is more intelligent than others.
In order to understand how exactly problem solving contributes to intelligence, we
need to find out how intelligent species solve problems.
2 Classical Approach
The classical approach to solving a problem is pretty simple. Given a problem at
hand, use hit and trial method to check for various solutions to that problem. This hit
and trial approach usually works well for trivial problems and is referred to as the
classical approach to problem solving.
Consider the maze searching problem. The mouse travels though one path and
finds that the path leads to a dead end, it then back tracks somewhat and goes
along some other path and again finds that there is no way to proceed. It goes on
performing such search, trying different solutions to solve the problem until a
sequence of turns in the maze takes it to the cheese. Hence, of all the solutions the
mouse tries, the one that reached the cheese was the one that solved the problem.
Consider that a toddler is to switch on the light in a dark room. He sees the
switchboard having a number of buttons on it. He presses one, nothing happens, he
presses the second one, the fan gets on, he goes on trying different buttons till at
last the room gets lighted and his problem gets solved.
Consider another situation when we have to open a combinational lock of a
briefcase. It is a lock which probably most of you would have seen where we have
different numbers and we adjust the individual dials/digits to obtain a combination
that opens the lock. However, If we don’t know the correct combination of digits that
open the lock, we usually try 0-0-0, 7-7-7, 7-8-6 or any such combination for opening
the lock. We are solving this problem in the same manner as the toddler did in the
light switch example.
All this discussion has one thing in common. That different intelligent species use a
similar approach to solve the problem at hand. This approach is essentially the
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45

Partial preview of the text

Download Problem Solving - Artificial Intelligence - Lecture Notes and more Study notes Artificial Intelligence in PDF only on Docsity!

Artificial Intelligence

Lecture No. 04 - 11

1 Problem Solving

In chapter one, we discussed a few factors that demonstrate intelligence. Problem solving was one of them when we referred to it using the examples of a mouse searching a maze and the next number in the sequence problem.

Historically people viewed the phenomena of intelligence as strongly related to problem solving. They used to think that the person who is able to solve more and more problems is more intelligent than others.

In order to understand how exactly problem solving contributes to intelligence, we need to find out how intelligent species solve problems.

2 Classical Approach

The classical approach to solving a problem is pretty simple. Given a problem at hand, use hit and trial method to check for various solutions to that problem. This hit and trial approach usually works well for trivial problems and is referred to as the classical approach to problem solving.

Consider the maze searching problem. The mouse travels though one path and finds that the path leads to a dead end, it then back tracks somewhat and goes along some other path and again finds that there is no way to proceed. It goes on performing such search, trying different solutions to solve the problem until a sequence of turns in the maze takes it to the cheese. Hence, of all the solutions the mouse tries, the one that reached the cheese was the one that solved the problem.

Consider that a toddler is to switch on the light in a dark room. He sees the switchboard having a number of buttons on it. He presses one, nothing happens, he presses the second one, the fan gets on, he goes on trying different buttons till at last the room gets lighted and his problem gets solved.

Consider another situation when we have to open a combinational lock of a briefcase. It is a lock which probably most of you would have seen where we have different numbers and we adjust the individual dials/digits to obtain a combination that opens the lock. However, If we don’t know the correct combination of digits that open the lock, we usually try 0-0-0, 7-7-7, 7-8-6 or any such combination for opening the lock. We are solving this problem in the same manner as the toddler did in the light switch example.

All this discussion has one thing in common. That different intelligent species use a similar approach to solve the problem at hand. This approach is essentially the

classical way in which intelligent species solve problems. Technically we call this hit and trial approach the “Generate and Test” approach.

3 Generate and Test

This is a technical name given to the classical way of solving problems where we generate different combinations to solve our problem, and the one which solves the problem is taken as the correct solution. The rest of the combinations that we try are considered as incorrect solutions and hence are destroyed.

The diagram above shows a simple arrangement of a Generate and Test procedure. The box on the left labeled “Solution Generator” generates different solutions to a problem at hand, e.g. in the case of maze searching problem, the solution generator can be thouht of as a machine that generates different paths inside a maze. The “Tester” actually checks that either a possible solution from the solution generates solves out problem or not. Again in case of maze searching the tester can be thought of as a device that checks that a path is a valid path for the mouse to reach the cheese. In case the tester verifies the solution to be a valid path, the solution is taken to be the “ Correct Solution ”. On the other hand if the solution was incorrect, it is discarded as being an “ Incorrect Solution ”.

4 Problem Representation

All the problems that we have seen till now were trivial in nature. When the magnitude of the problem increases and more parameters are added, e.g. the problem of developing a time table, then we have to come up with procedures better than simple Generate and Test approach.

Before even thinking of developing techniques to systematically solve the problem, we need to know one more thing that is true about problem solving namely problem representation. The key to problem solving is actually good representation of a problem. Natural representation of problems is usually done using graphics and diagrams to develop a clear picture of the problem in your mind. As an example to our comment consider the diagram below.

Solution Generator

Possible Tester Solutions

Incorrect Solutions

Correct Solutions

corner of the maze and the cheese in the top left corner, the mouse can turn left, right and might or might not be allowed to move backward and things like that. Thus it is the problem statement that gives us a feel of what exactly to do and helps us start thinking of how exactly things will work in the solution.

5.2 Problem Solution

While solving a problem, this should be known that what will be out ultimate aim. That is what should be the output of our procedure in order to solve the problem. For example in the case of mouse, the ultimate aim is to reach the cheese. The state of world when mouse will be beside the cheese and probably eating it defines the aim. This state of world is also referred to as the Goal State or the state that represents the solution of the problem.

5.3 Solution space

In order to reach the solution we need to check various strategies. We might or might not follow a systematic strategy in all the cases. Whatever we follow, we have to go though a certain amount of states of nature to reach the solution. For example when the mouse was in the lower left corner of the maze, represents a state i.e. the start state. When it was stuck in some corner of the maze represents a state. When it was stuck somewhere else represents another state. When it was traveling on a path represents some other state and finally when it reaches the cheese represents a state called the goal state. The set of the start state, the goal state and all the intermediate states constitutes something which is called a solution space.

5.4 Traveling in the solution space

We have to travel inside this solution space in order to find a solution to our problem. The traveling inside a solution space requires something called as “ operators ”. In case of the mouse example, turn left , turn right , go straight are the operators which help us travel inside the solution space. In short the action that takes us from one state to the other is referred to as an operator. So while solving a problem we should clearly know that what are the operators that we can use in order to reach the goal state from the starting state. The sequence of these operators is actually the solution to our problem.

6 The Two-One Problem

In order to explain the four components of problem solving in a better way we have chosen a simple but interesting problem to help you grasp the concepts. The diagram below shows the setting of our problem called the Two-One Problem.

A simple problem statement to the problem at hand is as under.

You are given a rectangular container that has 5 slots in it. Each slot can hold only one coin at a time. Place Rs.1 coins in the two left slots; keep the center slot empty and put Rs.2 coins in the two right slots. A simple representation can be seen in the diagram above where the top left container represents the Start State in which the coined are placed as just described. Our aim is to reach a state of the container where the left two slots should contain Rs.2 coins, the center slot should be empty and the right two slots should contain Rs.1 coin as shown in the Goal State. There are certain simple rules to play this game. The rules are mentioned clearly in the diagram under the heading of “Rules”. The rules actually define the constraints under which the problem has to be solved. The legal moves are the Operators that we can use to get from one state to the other. For example we can slide a coin to its left or right if the left or right slot is empty, or we can hop the coin over a single slot. The rules say that Rs.1 coins can slide or hop only towards right. Similarly the Rs. coins can slide or hop only towards the left. You can only move one coin at a time.

Now let us try to solve the problem in a trivial manner just by using a hit and trial method without addressing the problem in a systematic manner.

1 1? 2 2 2 2? 1 1

Start Goal

Rules:

  • 1s’ move right
  • 2s’ move left
  • Only one move at a time
  • No backing up

Legal Moves:

  • Slide
  • Hop

1 1? 2 2 2 2? 1 1

Start Goal

Rules:

  • 1s’ move right
  • 2s’ move left
  • Only one move at a time
  • No backing up

Legal Moves:

  • Slide
  • Hop

Trial 2

Starting from the start state we first hop a 1 to the right, then we slide the other 1 to the right and then suddenly we get STUCK !! Hence solving the problem through a hit an trial might not give us the solution.

Let us now try to address the problem in a systematic manner. Consider the diagram below.

Starting from the goal state if we hop, we get stuck. If we slide we can further carry on. Keeping this observation in mind let us now try to develop all the possible combinations that can happen after we slide.

The diagram above shows a tree sort of structure enumerating all the possible states and moves. Looking at this diagram we can easily figure out the solution to our problem. This tree like structure actually represents the “ Solution Space ” of this problem. The labels on the links are H and S representing hop and slide operators respectively. Hence H and S are the operators that help us travel through this solution space in order to reach the goal state from the start state.

We hope that this example actually clarifies the terms problem statement, start state, goal state, solution space and operators in your mind. It will be a nice exercise to design your own simple problems and try to identify these components in them in order to develop a better understanding.

7 Searching

All the problems that we have looked at can be converted to a form where we have to start from a start state and search for a goal state by traveling through a solution space. Searching is a formal mechanism to explore alternatives.

Most of the solution spaces for problems can be represented in a graph where nodes represent different states and edges represent the operator which takes us from one state to the other. If we can get our grips on algorithms that deal with searching techniques in graphs and trees, we’ll be all set to perform problem solving in an efficient manner.

? 1 1 2 2 1 1? 2 2 1 1 2 2?

1? 1 2 2 1 1 2? 2

? 1 1 2 2 1 2 1? 2 1? 2 1 2 1 1 2 2?

1 2 1 2? 1 2? 1 2? 1 2 1 2

1 2? 2 1? 2 1 1 2 1 2 2 1? 2 1? 1 2

1 2 2? 1? 2 1 2 1 2? 1 1 2 1 2 2 ?1 2 1 1 2? 2? 1 1 2

2? 1 2 1 2 1 2? 1

2 2 1? 1 2? 2 1 1

1 1? 2 2

H (^) H

S S

S (^) H H S

S S S S

S H (^) S S H S

S (^) S

H H S S

H (^) H H H

? 1 1 2 2 1 1? 2 2 1 1 2 2?

1? 1 2 2 1 1 2? 2

? 1 1 2 2 1 2 1? 2 1? 2 1 2 1 1 2 2?

1 2 1 2? 1 2? 1 2? 1 2 1 2

1 2? 2 1? 2 1 1 2 1 2 2 1? 2 1? 1 2

1 2 2? 1? 2 1 2 1 2? 1 1 2 1 2 2 ?1 2 1 1 2? 2? 1 1 2

2? 1 2 1 2 1 2? 1

2 2 1? 1 2? 2 1 1

1 1? 2 2

H (^) H

S S

S (^) H H S

S S S S

S H (^) S S H S

S (^) S

H H S S

H (^) H H H

We will use graphs to represent problems and their solution spaces. One thing to be noted is that every graph can be converted into a tree, by replicating the nodes. Consider the following example.

The graph in the figure represents a city map with cities labeled as S, A, B, C, D, E, F and G. Just by following a simple procedure we can convert this graph to a tree.

Start from node S and make it the root of your tree, check how many nodes are adjacent to it. In this case A and D are adjacent to it. Hence in the tree make A and D, children of S. Now go on proceeding in this manner and you’ll get a tree with a few nodes replicated. In this manner depending on a starting node you can get a different tree too. But just recall that when solving a problem; we usually know the start state and the end state. So we will be able to transform our problem graphs in problem trees. Now if we can develop understanding of algorithms that are defined for tree searching and tree traversals then we will be in a better shape to solve problems efficiently.

We know that problems can be represented in graphs, and are well familiar with the components of problem solving, let us now address problem solving in a more formal manner and study the searching techniques in detail so that we can systematically approach the solution to a given problem.

S G

E F

B C

D

A 2

3 3

3 1 3

2

4 4

S A D B D A E C E

D F

G

E

B F

C G

B

C E

F

G

B F

A C G

S G

E F

B C

D

A 2

3 3

3 1 3

2

4 4

S A D B D A E C E

D F

G

E

B F

C G

B

C E

F

G

B F

A C G

9 Search Strategies

Search strategies and algorithms that we will study are primarily of four types, blind/uninformed, informed/heuristic, any path/non-optimal and optimal path search algorithms. We will discuss each of these using the same mouse example.

Suppose the mouse does not know where and how far is the cheese and is totally blind to the configuration of the maze. The mouse would blindly search the maze without any hints that will help it turning left or right at any junction. The mouse will purely use a hit and trial approach and will check all combinations till one takes it to the cheese. Such searching is called blind or uninformed searching.

Consider now that the cheese is fresh and the smell of cheese is spread through the maze. The mouse will now use this smell as a guide, or heuristic (we will comment on this word in detail later) to guess the position of the cheese and choose the best from the alternative choices. As the smell gets stronger, the mouse knows that the cheese is closer. Hence the mouse is informed about the cheese through the smell and thus performs an informed search in the maze. For now you might think that the informed search will always give us a better solution and will always solve our problem. This might not be true as you will find out when we discuss the word heuristic in detail later.

When solving the maze search problem, we saw that the mouse can reach the cheese from different paths. In the diagram above two possible paths are shown.

In any-path/non optimal searches we are concerned with finding any one solution to our problem. As soon as we find a solution, we stop, without thinking that there might as well be a better way to solve the problem which might take lesser time or fewer operators.

Contrary to this, in optimal path searches we try to find the best solution. For example, in the diagram above the optimal path is the blue one because it is smaller and requires lesser operators. Hence in optimal searches we find solutions that are least costly, where cost of the solution may be different for each problem.

We start with a tree containing nodes S, A, B, C, D, E, F, G, and H, with H as the goal node. In the bottom left table we show the two queues Q and Visited. According to the Simple Search Algorithm, we initialize Q with the start node S, shown below.

If Q is not empty, pick the node X with the minimum P(n) (in this case S), as it is the only node in Q. Check if X is goal, (in this case X is not the goal). Hence find all the children of X not in Visited and add them to Q and Visited. Goto Step 2.

Again check if Q is not empty, pick the node X with the minimum P(n) (in this case either A or B), as both of them have the same value for P(n). Check if X is goal, (in this case A is not the goal). Hence, find all the children of A not in Visited and add them to Q and Visited. Go to Step 2.

Go on following the steps in the Simple Search Algorithm till you find a goal node. The diagrams below show you how the algorithm proceeds.

picked from Q. In other words, greater the depth/height greater the priority. The following sequence of diagrams will show you how BFS works on a tree using the Simple Search Algorithm.

We start with a tree containing nodes S, A, B, C, D, E, F, G, and H, with H as the goal node. In the bottom left table we show the two queues Q and Visited. According to the Simple Search Algorithm, we initialize Q with the start node S.

If Q is not empty, pick the node X with the minimum P(n) (in this case S), as it is the only node in Q. Check if X is goal, (in this case X is not the goal). Hence find all the children of X not in Visited and add them to Q and Visited. Goto Step 2.

Again, check if Q is not empty, pick the node X with the minimum P(n) (in this case either A or B), as both of them have the same value for P(n). Remember, n refers to the node X. Check if X is goal, (in this case A is not the goal). Hence find all the children of A not in Visited and add them to Q and Visited. Go to Step 2.

Now, we have B, C and D in the list Q. B has height 1 while C and D are at a height

  1. As we are to select the node with the minimum P(n) hence we will select B and repeat. The following sequence of diagram tells you how the algorithm proceeds till it reaches the goal state.

When we remove H from the 9 th^ row of the table and check if it’s the goal, the algorithm says YES and hence we return H since we have reached the goal state. The path followed by the BFS is shown by green arrows at each step. The diagram below also shows that BFS travels a significant area of the search space if the solution is located somewhere deep inside the tree.

Hence, simply by selecting a specific P(n) our Simple Search Algorithm was converted to a BFS procedure.

13 Problems with DFS and BFS

Though DFS and BFS are simple searching techniques which can get us to the goal state very easily yet both of them have their own problems.

DFS has small space requirements (linear in depth) but has major problems:

ƒ DFS can run forever in search spaces with infinite length paths ƒ DFS does not guarantee finding the shallowest goal

BFS guarantees finding the shallowest path even in presence of infinite paths, but it has one great problem ƒ BFS requires a great deal of space (exponential in depth)

We can still come up with a better technique which caters for the drawbacks of both these techniques. One such technique is progressive deepening.

14 Progressive Deepening

Progressive deepening actually emulates BFS using DFS. The idea is to simply apply DFS to a specific level. If you find the goal, exit, other wise repeat DFS to the next lower level. Go on doing this until you either reach the goal node or the full height of the tree is explored. For example, apply a DFS to level 2 in the tree, if it reaches the goal state, exit, otherwise increase the level of DFS and apply it again until you reach level 4. You can increase the level of DFS by any factor. An example will further clarify your understanding.