86
Problems, Problem Spaces and Search Chandra Prakash Assistant Professor LPU

14666_2. Problems, Problem Space n Search(Lecture 6-11)

Embed Size (px)

Citation preview

Page 1: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problems, Problem Spaces and

Search

Chandra Prakash

Assistant Professor

LPU

Page 2: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Contents

Defining the problem as a State Space Search

Production Systems

Control Strategies

Breadth First Search

Depth First Search

Heuristic Search

Problem Characteristics

Is the Problem Decomposable?

Can Solution Steps be ignored or undone?

Production system characteristics

Issues in the design of search programs

2Chandra Prakash, LPU

Page 3: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

33

Intelligent Agent

Agent

Environment

State Reward Action

Policy

Agent: Intelligent programs

Environment: External condition

Policy:Defines the agent’s behavior at a given timeA mapping from states to actionsLookup tables or simple function

3

Page 4: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Intelligent Agent –Simple Reflex

Page 5: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Intelligent agent (IA) is an autonomous entity which observes and acts upon an environment (i.e. it is an agent) and directs its activity towards achieving goals.

Sensors: to receive stimuli

Actuators: to react

Intelligent agents may also learn or use knowledge to achieve their goals

The goal of artificial intelligence:

To build agents that behave intelligently

Page 6: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Representing states

At any moment, the relevant world is represented as a state

Initial (start) state: S

An action (or an operation) changes the current state to another

state (if it is applied): state transition

An action can be taken (applicable) only if the its precondition is

met by the current state

For a given state, there might be more than one applicable actions

Goal state: a state satisfies the goal description or passes the goal

test

Dead-end state: a non-goal state to which no action is applicable

6Chandra Prakash, LPU

Page 7: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Building Goal-Based Agents

We have a goal to reach

Driving from point A to point B

Put 8 queens on a chess board such that no one attacks another

We have information about where we are now at the beginning

We have a set of actions we can take to move around (change from

where we are)

Objective: find a sequence of legal actions which will bring us from

the start point to a goal

Requires defining a “goal test” so that we know what it means to have

achieved/satisfied our goal.

This is a hard part that is rarely tackled in AI, usually assuming

that the system designer or user will specify the goal to be

achieved.

7Chandra Prakash, LPU

Page 8: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Representation in AI

Before a solution can be found, the prime condition

is that the problem must be very precisely

defined. The most common methods of problem

representation in AI are:

1. State Space representation

2. Problem Reduction

Page 9: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Representaion:

Are highly beneficial in AI because they provide all

possible state, operations and the goals.

If the entire state-space representation for a problem is

given, it is possible to trace the path from the initial

state to the goal state and identify the sequence of

operations necessary for doing it.

The major deficiency of this method is that it is not

possible to visualize all states for a given problem.

Defining the problem as State Space

Search

Page 10: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Representing states

State space:

Includes the initial state S and all other states that are reachable from S by a sequence of actions

A state space can be organized as a graph:

nodes: states in the space

arcs: actions/operations

The size of a problem is usually described in terms of the number of states (or the size of the state space) that are possible.

Tic-Tac-Toe has about 3^9 states.

Checkers has about 10^40 states.

Chess has about 10^120 states in a typical game.

10Chandra Prakash, LPU

Page 11: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Formalizing Search in a State Space• A state space is a graph, (V, E) where V -> set of nodes and E ->set of arcs

• Each arc is directed from a node to another node

• node: corresponds to a state

– state description

– plus optionally other information related to the parent of the node, operation to generate the node from that parent, and other bookkeeping data

• arc: corresponds to an applicable action/operation.

– the source and destination nodes are called as parent (immediate predecessor) and child (immediate successor) nodes with respect to each other

– ancestors( (predecessors) and descendents (successors)

– each arc has a fixed, non-negative cost associated with it, corresponding to the cost of the action

11Chandra Prakash, LPU

Page 12: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Cont…

• node generation: making explicit a node by applying an action to

another node which has been made explicit

• node expansion: generate all children of an explicit node by applying

all applicable operations to that node

• One or more nodes are designated as start nodes

• A goal test predicate is applied to a node to determine if its associated

state is a goal state

• A solution is a sequence of operations that is associated with a path in a

state space from a start node to a goal node

• The cost of a solution is the sum of the arc costs on the solution path

12Chandra Prakash, LPU

Page 13: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Solving

Problem Solving is a process or procedure used to

find out the solution to a specific problem. To build a

system to solve a particular problem we need to do 4

things.

13

Page 14: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

To build a system to solve a problem

1. Define the problem precisely

2. Analyze the problem

3. Isolate and represent the task knowledge that is

necessary to solve the problem

4. Choose the best problem-solving techniques and

apply it to the particular problem.

14Chandra Prakash, LPU

Page 15: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Solving- steps

1. Define the problem precisely

This definition must include precise

specifications of what the initial situations will be

as well as what the final situations constitute

acceptable solution to the problem.

15

Page 16: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Solving - steps

2. Analyze the Problem

A few important features of the problem can help in

the selection of various possible techniques for

solving the problem.

16

Page 17: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Solving - steps

3. Knowledge Representation.

Isolate and represent the knowledge that is

necessary to solve the problem.

4. Best Techniques.

Choose the best problem solving technique and

apply it to the particular problem.

17

Page 18: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Representation

State Space Representation is a structuredrepresentation of an unstructured problem. It consistsof

1. Initial States

2. Final States (Goal State)

3. Intermediate states

4. Operators, which indicates action to be performed for makingthe changes in the initial states to reach the goal state.

5. A complete knowledge of the problem which is needed forapplying the operators to make a state change.

18

Page 19: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Search Through State-Space

Page 20: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Solution Stages

1. Assumptions

2. Solution steps

3. State Space Representations

Initial state

Final state

Operators that can be applied

Abbreviations

State space representation of the given problem

Operators and Conditions.

20

Page 21: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Search Example: Water Jug

Problem

Define the Problem Accurately.

“You are given two jugs, a 4 gallon one and a 3

gallon one. Neither has any measuring markers on

it. There is a pump that can be used to fill the jugs

with water. Discuss how exactly 2 gallon of water

can be filled into 4 gallon of jug by employing the

state space representations.

21Chandra Prakash, LPU

Page 22: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

1. Assumptions

In order to solve the given problem we can make the

following assumptions without affecting the problem.

1. We can fill the jugs with the help of a pump.

2. We can pour water from any jug to the ground.

3. We can transfer water from one jug to the other.

4. No external measuring devices are available.

22

Page 23: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

2. Solution Steps

We can list the steps that may be followed to reach the goalstate.

1. Fill the 3 gallon jug with water

2. Pour the water from 3 gallon jug to 4 gallon jug.

3. Again fill the 3 gallon jug with water

4. Pour the water carefully from 3 gallon jug to 4 gallon jug such that it is just filled.

5. Empty the 4 gallon jug

6. Transfer the water from 3 gallon jug to 4 gallon jug.

7. Stop.

23

Page 24: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Representation

1. Initial & Final States

Let the Quantity of the water present in the jug

represent the state.

State = (Water in 4 G jug, Water in 3 G jug)

Initial State = (0 , 0)

Final State = (2 , n)

24

Page 25: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Water Jug Problem

The state space for this problem can be described as the set of ordered pairs of integers (x,y) such that x = 0, 1,2, 3 or 4 and y = 0,1,2 or 3; x represents the number of gallons of water in the 4-gallon jug and y represents the quantity of water in 3-gallon jug

The start state is (0,0)

The goal state is (2,n) for any n.

Attempting to end up in a goal state.

25Chandra Prakash, LPU

Page 26: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Representation 2.Operators

26

Let us define the following 4 operators.

FILL (jug): where jug = 3 gallon or 4 gallon, fill the

jug fully with water.

EMPTY (jug): where jug = 3 gallon or 4 gallon,

empty the jug by pouring the water to ground.

POUR (jug1, jug2): pour the water from jug1 to

jug 2 until it is just filled

TRANSFER (jug1, jug2): pour the water from jug1

to jug 2 completely.

Page 27: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Representation 3. Abbreviations

G3 3 Gallon Jug

G4 4 Gallon Jug

27

Page 28: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

4.State Space Representation

State No. Operator State

(G4,G3)

0 (Initial) --------- (0, 0)

1 FILL (G3) (0, 3)

2 TRANSFER (G3, G4) (3, 0)

3 FILL (G3) (3, 3)

4 POUR (G3, G4) (4, 2)

5 EMPTY (G4) (0, 2)

6 (Final) TRANSFER (G3,G4) (2, 0)

28

Page 29: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

State Space Representation 5.Operators and Conditions

Operators

FILL (G3) :

FILL (G4) :

EMPTY (G4) :

TRANSFER (G3,G4) :

POUR (G3, G4) :

Conditions

G3 was not full

G4 was not full

G4 was not empty

G3 was not empty

& G4 was not full

G3 was not empty

& G4 was not full

29

Page 30: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production rules for Water Jug Problem

The operators to be used to solve the problem can be described as

follows:

Sl No Current state Next State Descritpion

1 (x,y) if x < 4 (4,y) Fill the 4 gallon jug

2 (x,y) if y <3 (x,3) Fill the 3 gallon jug

3 (x,y) if x > 0 (x-d, y) Pour some water out of the 4

gallon jug

4 (x,y) if y > 0 (x, y-d) Pour some water out of the 3-

gallon jug

5 (x,y) if x>0 (0, y) Empty the 4 gallon jug

6 (x,y) if y >0 (x,0) Empty the 3 gallon jug on the

ground

7 (x,y) if x+y >= 4 and y >0 (4, y-(4-x)) Pour water from the 3 –

gallon jug into the 4 –gallon

jug until the 4-gallon jug is

fullChandra Prakash, LPU 30

Page 31: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production rules

8 (x, y) if x+y >= 3 and x>0 (x-(3-y), 3) Pour water from the 4-gallon

jug into the 3-gallon jug until

the 3-gallon jug is full

9 (x, y) if x+y <=4 and y>0 (x+y, 0) Pour all the water from the 3-

gallon jug into the 4-gallon jug

10 (x, y) if x+y <= 3 and x>0 (0, x+y) Pour all the water from the 4-

gallon jug into the 3-gallon jug

11 (0,2) (2,0) Pour the 2 gallons from 3-

gallon jug into the 4-gallon jug

12 (2,y) (0,y) Empty the 2 gallons in the 4-

gallon jug on the ground

Chandra Prakash, LPU 31

Page 32: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

To solve the water jug problem

Required a control structure that loops through a simple cycle in which some rule whose left side matches the current state is chosen, the appropriate change to the state is made as described in the corresponding right side, and the resulting state is checked to see if it corresponds to goal state.

One solution to the water jug problem

Shortest such sequence will have a impact on the choice of appropriate mechanism to guide the search for solution.

Gallons in the

4-gallon jug

Gallons in the

3-gallon jug

Rule applied

0 0 2

0 3 9

3 0 2

3 3 7

4 2 5 or 12

0 2 9 0r 11

2 0

Chandra Prakash, LPU 32

Page 33: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Example: Playing Chess

To build a program that could “play chess”, we could

first have to specify the starting position of the chess

board, the rules that define the legal moves, and the

board positions that represent a win for one side or

the other.

In addition, we must make explicit the previously

implicit goal of not only playing the legal game of

chess but also winning the game, if possible

33Chandra Prakash, LPU

Page 34: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

34

Page 35: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Playing chess

The starting position can be described as an 8by 8 array where each position contains a symbol for appropriate piece.

Initial position is the game opening position.

Goal position is any position in which the opponent does not

have a legal move and his or her king is under attack.(check

mate position).

The legal moves provide the way of getting from initial state

to a goal state.

35Chandra Prakash, LPU

Page 36: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Playing chess (cont…)

Legal moves can be described easily as a set of rules consisting of two parts:

A left side that serves as a pattern to be matched against the current board position.

And a right side that describes the change to be made to reflect the move

However, this approach leads to large number of rules roughly 10120 board positions !!

Using so many rules poses problems such as:

No person could ever supply a complete set of such rules.

No program could easily handle all those rules. Just storing so many rules poses serious difficulties.

36Chandra Prakash, LPU

Page 37: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Possible Move

37

Page 38: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Defining chess problem as State Space

search We need to write the rules describing the legal moves in as

general a way as possible.

For example:

White pawn at Square( file e, rank 2) AND Square( File e, rank 3) is empty AND Square(file e, rank 4) is empty, then move the pawn from Square( file e, rank 2) to Square( file e, rank 4).

In general, the more accurately we can describe the rules we need, the less work we will have to do to provide them and more efficient the program.

38Chandra Prakash, LPU

Page 39: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Formal Description of the problem

1. Define a state space that contains all the possible configurations of the relevant objects.

2. Specify one or more states within that space that describe possible situations from which the problem solving process may start ( initial state)

3. Specify one or more states that would be acceptable as solutions to the problem. ( goal states)

4. Specify a set of rules that describe the actions ( operations) available.

What are unstated assumptions?

How general should the rules be?

How much knowledge for solutions should be in the rules?

39Chandra Prakash, LPU

Page 40: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production Systems

40

Page 41: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production Systems

One of the oldest techniques of knowledge representation.

It is a computer program used to provide some form of AI,

which consists primarily of a set of rules about behavior.

These rules , termed as production are a basic representation.

Production consist of two parts:

Sensory precondition (IF statement)

An action (THEN )

Situation Action

Premise conclusion

41Chandra Prakash, LPU

Page 42: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production System (cont..)

Production System provides structure to AI Program in such a

way that facilities describing and performing the search

process.

Includes a knowledge base,

Represented by production rules,

A working memory to hold the matching patterns of data that

causes the rules to fire and

An interpreter, also called the inference engine, that decides

which rule to fire, when more than one of them are

concurrently firable.

42

Page 43: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production Systems

A production system consists of:

A set of rules, each consisting of a left side(a pattern) that determines the applicability of the rule and a right side that describes the operation to be performed if that rule is applied.

One or more knowledge/databases that contain whatever information is appropriate for the particular task. Some parts of the database may be permanent, while other parts of it may pertain only to the solution of the current problem.

A control strategy that specifies the order in which the rules will be compared to the database and a way of resolving the conflicts that arise when several rules match at once.

A rule applier

43Chandra Prakash, LPU

Page 44: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production system

Inorder to solve a problem:

First reduce it to one for which a precise statement can be given. This can be done by defining the problem’s state space ( start and goal states) and a set of operators for moving that space.

The problem can then be solved by searching for a path through the space from an initial state to a goal state.

The process of solving the problem can usefully be modelled as a production system.

44Chandra Prakash, LPU

Page 45: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Control Strategies

If more than one rules is there then how to decide which rule

to apply next during the process of searching for a solution to a

problem?

The three requirements of good control strategy are that

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.

45Chandra Prakash, LPU

Page 46: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Breadth-First searchSearching progress level by level generate all the successor of the root node by

applying each as applicable rules to the initial state continue this until we don’t get

goal state

46Chandra Prakash, LPU

Page 47: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Breadth First Search

Algorithm:

1. Create a variable called NODE-LIST and set it to initial

state

2. Until a goal state is found or NODE-LIST is empty . do

a. Remove the first element from NODE-LIST and call it E.

If NODE-LIST was empty, quit

b. For each way that each rule can match the state described

in E do:

i. Apply the rule to generate a new state

ii. If the new state is a goal state, quit and return this state

iii. Otherwise, add the new state to the end of NODE-LIST

47Chandra Prakash, LPU

Page 48: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

BFS Tree for Water Jug problem

48Chandra Prakash, LPU

(0,0)

(4,0) (0,3)

(4,3) (0,0) (1,3) (4,3) (0,0) (3,0)

Page 49: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

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.

49Chandra Prakash, LPU

Page 50: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Amount of time needed to generate all the nodes is

considerable because of the time complexity.

Memory constraint is also a major hurdle because of

the space-complexity.

The searching process remembers all unwanted nodes

which is of no practical use for the search.

Problems Of BFS :

Page 51: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Algorithm: Depth First Search

1. If the initial state is a goal state, quit and return success

2. Otherwise, do the following until success or failure is signaled:

a. Generate a successor, E, of initial state. If there are no more successors, signal failure.

b. Call Depth-First Search, with E as the initial state

c. If success is returned, signal success. Otherwise continue in this loop.

51Chandra Prakash, LPU

Page 52: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Backtracking

In this search, 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.

52Chandra Prakash, LPU

Page 53: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

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.

53Chandra Prakash, LPU

Page 54: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

The major drawback of DFS is the determination

of the depth until which the search has to

proceed. This depth is called cut-off depth. The

value of cut-off depth is essential because

otherwise the search will go on and on.

If cut-off depth is small, solution may not found

and if cut-off depth is large, time-complexity will

be more.

Drawback of DFS

Page 55: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Traveling Salesman Problem

There are cities and given distances between

them. Travelling salesman has to visit all of them,

but he does not to travel very much. Task is to

find a sequence of cities to minimize travelled

distance.

55

Page 56: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Traveling Salesman Problem

A simple motion causing and systematic control structure could solve this problem.

Simply explore all possible paths in the tree and return the shortest path.

If there are N cities, then number of different paths among them is 1.2….(N-1) or (N-1)!

The time to examine single path is proportional to N

So the total time required to perform this search is proportional to N!

For 10 cities, 10! = 3,628,800

This phenomenon is called Combinatorial explosion.

56Chandra Prakash, LPU

Page 57: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Branch and Bound

Begin generating complete paths, keeping track of the shortest path found so far.

Give up exploring any path as soon as its partial length becomes greater than the shortest path found so far.

Using this algorithm, we are guaranteed to find the shortest path.

It still requires exponential time.

The time it saves depends on the order in which paths are explored.

57Chandra Prakash, LPU

Page 58: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Heuristic Search

A Heuristic is a technique that improves the efficiency of a search process, possibly by sacrificing claims of completeness.

Heuristics are like tour guides

They are good to the extent that they point in generally interesting directions;

They are bad to the extent that they may miss points of interest to particular individuals.

On the average they improve the quality of the paths that are explored.

Using Heuristics, we can hope to get good ( though possibly nonoptimal ) solutions to hard problems such as a TSP in non exponential time.

There are good general purpose heuristics that are useful in a wide variety of problem domains.

Special purpose heuristics exploit domain specific knowledge

58Chandra Prakash, LPU

Page 59: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Nearest Neighbour Heuristic

It works by selecting locally superior alternative at each step.

Applying to TSP:

1. Arbitrarily select a starting city

2. To select the next city, look at all cities not yet visited and select the one closest to the current city. Go to next step.

3. Repeat step 2 until all cities have been visited.

– This procedure executes in time proportional to N2

– It is possible to prove an upper bound on the error it incurs. This provides reassurance that one is not paying too high a price in accuracy for speed.

59Chandra Prakash, LPU

Page 60: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Heuristic Function

This is a function that maps from problem state descriptions to measures of goal state and usually represented as numbers.

Which aspects of the problem state are considered,

how those aspects are evaluated, and

The weights given to individual aspects are chosen in such a way that

the value of the heuristic function at a given node in the search process gives as good an estimate as possible of whether that node is on the desired path to a solution.

Well designed heuristic functions can play an important part in efficiently guiding a search process toward a solution.

60Chandra Prakash, LPU

Page 61: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Example Simple Heuristic functions

Chess : The material advantage of our side over

opponent.

TSP: the sum of distances so far

Tic-Tac-Toe: ???/

61Chandra Prakash, LPU

Page 62: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

4 square problem :

8 square problem :

62

1 3

2 B

B 3

1 2

1 2 3

8 5 6

4 7

1 2 3

8 4

7 6 5

Page 63: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Characteristics

Inorder to choose the most appropriate method for a particular problem, it is necessary to analyze the problem along several key dimensions: Is the problem decomposable into a set of independent smaller or easier

subproblems?

Can solution steps be ignored or at least undone if they prove unwise?

Is the problem’s universe predictable?

Is a good solution to the problem obvious without comparison to all other possible solutions?

Is the desired solution a state of the world or a path to a state?

Is a large amount of knowledge absolutely required to solve the problem or is knowledge important only to constrain the search?

Can a computer that is simply given the problem return the solution or will the solution of the problem require interaction between the computer and a person?

63Chandra Prakash, LPU

Page 64: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Is the problem Decomposable?

Whether the problem can be decomposed into

smaller problems?

Using the technique of problem decomposition,

we can often solve very large problems easily.

Example for decomposable problems

∫( x2 +3x + Sin2x.Cos2x )dx

64Chandra Prakash, LPU

Page 65: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Blocks World Problem

Following operators

are available:

CLEAR(x) [ block x

has nothing on it]->

ON(x, Table)

CLEAR(x) and

CLEAR(y) ->

ON(x,y) [ put x on y]

65Chandra Prakash, LPU

C

A B

A

B

C

Start: ON(C,A)

Goal: ON(B,C) and ON(A,B)

ON(B,C)

ON(B,C) and ON(A,B)

ON(B,C)

ON(A,B)

CLEAR(A) ON(A,B)

CLEAR(A) ON(A,B)

Page 66: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Can Solution Steps be ignored or undone?

Suppose we are trying to prove a math theorem. We can prove a lemma. If we find the lemma is not of any help, we can still continue.

8-puzzle problem

Chess: A move cannot be taken back.

Important classes of problems:

Ignorable (e.g. theorem proving) in which solution steps can be ignored

Recoverable (e.g. 8-puzzle) in which solution steps can be undone.

Irrecoverable (e.g. chess) in which solution steps cannot be undone

66Chandra Prakash, LPU

Page 67: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Conti …..

The recoverability of a problem plays an important role in determining the complexity of the control structure necessary for the problem’s solution.

Ignorable problems can be solved using a simple control structure that never backtracks

Recoverable problems can be solved by a slightly more complicated control strategy that does sometimes make mistakes

Irrecoverable problems will need to be solved by systems that expends a great deal of effort making each decision since decision must be final. Planning is required here.

67

Page 68: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Is the universe Predictable?

Certain Outcome ( ex: 8-puzzle)

Uncertain Outcome ( ex: Bridge, controlling a robot arm)

For solving certain outcome problems, open loop approach ( without feedback) will work fine.

For uncertain-outcome problems, planning can at best generate a sequence of operators that has a good probability of leading to a solution. We need to allow for a process of plan revision to take place.

68Chandra Prakash, LPU

Page 69: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Is a good solution absolute or relative?

Any path problem

Best path problem

Any path problems can often be solved in a reasonable amount of time by using heuristics that suggest good paths to explore.

Best path problems are computationally harder.

69Chandra Prakash, LPU

Page 70: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Consider the following problem

1. Marcus was a man

2. Marcus was a Pompean

3. Marcus was born in 40 AD

4. All men are mortal

5. All Pompeans died when volcano erupted in 79 AD

6. No mortal lives longer than 150 years

7. Now it is 1983 AD

“ Is Marcus alive now? “

Is a good solution absolute or relative?

Page 71: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

1. Marcus was a man - Axiom1

4. All men are mortal -Axiom4

8. Marcus was Mortal - 1&4

3. Marcus was born in 40 AD -Axiom3

7. Now it is 1983 AD -Axiom7

9. Marcus lived 1983 years - 3,7

6. No mortal lives longer than 150 years Axiom6

10. Marcus is not alive -8,6,9

Page 72: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

7. It is now 1983 A.D. Axiom 7

5. All Pompeans died when volcano

erupted in 79 AD Axiom 5

11. All pompeians are dead now 7, 5

2. Marcus was a Pompean Axiom 2

12. So Marcus is not alive 11,2

Page 73: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Is the solution a state or a path?

Examples:

Finding a consistent interpretation for the sentence “The

bank president ate a dish of pasta salad with the fork”. We

need to find the interpretation but not the record of the

processing.

Water jug : Here it is not sufficient to report that we have

solved , but the path that we found to the state (2,0). Thus

the a statement of a solution to this problem must be a

sequence of operations ( Plan) that produces the final state.

73Chandra Prakash, LPU

Page 74: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

What is the role of knowledge?

Two examples:

Chess: Knowledge is required to constrain the search for a solution

Newspaper story understanding: Lot of knowledge is required even to be able to recognize a solution.

Consider a problem of scanning daily newspapers to decide which are supporting the democrats and which are supporting the republicans in some election. We need lots of knowledge to answer such questions as:

The names of the candidates in each party

The facts that if the major thing you want to see done is have taxes lowered, you are probably supporting the republicans

The fact that if the major thing you want to see done is improved education for minority students, you are probably supporting the democrats.

etc

74Chandra Prakash, LPU

Page 75: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Does the task require Interaction with a person?

The programs require intermediate interaction with people for additional inputs and to provided reassurance to the user.

There are two types of programs:

Solitary

Conversational:

Decision on using one of these approaches will be important in the choice of problem solving method.

75Chandra Prakash, LPU

Page 76: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Problem Classification

There are several broad classes into which the

problems fall. These classes can each be

associated with generic control strategy that is

appropriate for solving the problems:

Classification : ex: medical diagnostics, diagnosis of

faults in mechanical devices

Propose and Refine: ex: design and planning

76Chandra Prakash, LPU

Page 77: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Production System Characteristics

1. Can production systems, like problems, be described by a set of characteristics that shed some light on how they can easily be implemented?

2. If so, what relationships are there between problem types and the types of production systems best suited to solving the problems?

Classes of Production systems:

Monotonic Production System: the application of a rule never prevents the later application of another rule that could also have been applied at the time the first rule was selected.

Non-Monotonic Production system

Partially commutative Production system: property that if application of a particular sequence of rules transforms state x to state y, then permutation of those rules allowable, also transforms state x into state y.

Commutative Production system

77Chandra Prakash, LPU

Page 78: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Monotonic Production Systems

Production system in which the application of a

rule never prevents the later application of another

rule that could also have been applied at the time

the first rule was applied.

i.e., rules are independent.

78Chandra Prakash, LPU

Page 79: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Commutative Production system

A partially Commutative production system has a property that if the application of a particular sequence of rules transform state x into state y, then any permutation of those rules that is allowable, also transforms state x into state y.

A Commutative production system is a production system that is both monotonic and partially commutative.

79Chandra Prakash, LPU

Page 80: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Partially Commutative, Monotonic

These production systems are useful for solving ignorable problems.

Example: Theorem Proving

They can be implemented without the ability to backtrack to previous states when it is discovered that an incorrect path has been followed.

This often results in a considerable increase in efficiency, particularly because since the database will never have to be restored, It is not necessary to keep track of where in the search process every change was made.

They are good for problems where things do not change; new things get created.

80Chandra Prakash, LPU

Page 81: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Non Monotonic, Partially Commutative

Useful for problems in which changes occur but can

be reversed and in which order of operations is not

critical.

Example: Robot Navigation, 8-puzzle, blocks world

Suppose the robot has the following ops: go North

(N), go East (E), go South (S), go West (W). To reach

its goal, it does not matter whether the robot executes

the N-N-E or N-E-N.

81Chandra Prakash, LPU

Page 82: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Not partially Commutative

Problems in which irreversible change occurs

Example: chemical synthesis

The ops can be :Add chemical x to the pot, Change the temperature to t degrees.

These ops may cause irreversible changes to the potion being brewed.

The order in which they are performed can be very important in determining the final output.

(X+y) +z is not the same as (z+y) +x

Non partially commutative production systems are less likely to produce the same node many times in search process.

When dealing with ones that describe irreversible processes, it is partially important to make correct decisions the first time, although if the universe is predictable, planning can be used to make that less important.

82Chandra Prakash, LPU

Page 83: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Four Categories of Production System

Monotonic NonMonotonic

Partially

Commutative

Theorem

proving

Robot

Navigation

Not Partially

Commutative

Chemical

Synthesis

Bridge

Chandra Prakash, LPU 83

Page 84: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Issues in the design of search programs

The direction in which to conduct the search (

forward versus backward reasoning).

How to select applicable rules ( Matching)

How to represent each node of the search process (

knowledge representation problem)

84Chandra Prakash, LPU

Page 85: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Summary

Four steps for designing a program to solve a

problem:

1. Define the problem precisely

2. Analyse the problem

3. Identify and represent the knowledge required by the

task

4. Choose one or more techniques for problem solving

and apply those techniques to the problem.

85Chandra Prakash, LPU

Page 86: 14666_2. Problems, Problem Space n Search(Lecture 6-11)

Reference

Artificial Intelligence by Elaine Rich & Kevin

Knight, Third Ed, Tata McGraw Hill

Artificial Intelligence and Expert System by

Patterson

86Chandra Prakash, LPU