0% found this document useful (0 votes)
103 views47 pages

Problems, Problem Spaces and Search: Dr. Suthikshn Kumar

1. The document discusses defining problems as state space searches and using production systems and search algorithms like breadth-first search and depth-first search to solve problems. 2. It provides the example of modeling the game of chess as a state space problem and describes how water jug problems can be formalized and solved using production rules. 3. Search algorithms like breadth-first search are guaranteed to find solutions but can be inefficient for large problems, while heuristics can guide searches to solutions faster but may miss some.

Uploaded by

ssregens82
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views47 pages

Problems, Problem Spaces and Search: Dr. Suthikshn Kumar

1. The document discusses defining problems as state space searches and using production systems and search algorithms like breadth-first search and depth-first search to solve problems. 2. It provides the example of modeling the game of chess as a state space problem and describes how water jug problems can be formalized and solved using production rules. 3. Search algorithms like breadth-first search are guaranteed to find solutions but can be inefficient for large problems, while heuristics can guide searches to solutions faster but may miss some.

Uploaded by

ssregens82
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 47

Problems, Problem Spaces and Search

Dr. Suthikshn Kumar

Contents
Defining the problem as a State Space Search Production Systems Control Strategies Breadth First Search Depth First Search euristic Search Problem Characteristics !s the Problem Decomposable" Can Solution Steps be ignored or undone" Production system characteristics !ssues in the design of search programs

#o build a system to sol$e a problem


%. Define the problem precisely &. 'nalyse the problem (. !solate and represent the task kno)ledge that is necessary to sol$e the problem *. Choose the best problem+sol$ing techni,ues and apply it to the particular problem.

Defining the problem as State Space Search


#he state space representation forms the basis of most of the '! methods. !ts structure corresponds to the structure of problem sol$ing in t)o important )ays. !t allo)s for a formal definition of a problem as the need to con$ert some gi$en situation into some desired situation using a set of permissible operations. . !t permits us to define the process of sol$ing a particular problem as a combination of kno)n techni,ues /each represented as a rule defining a single step in the space0 and search, the general techni,ue of e1ploring the space to try to find some path from current state to a goal state. . Search is a $ery important process in the solution of hard problems for )hich no more direct techni,ues are a$ailable.

21ample- Playing Chess


#o build a program that could 3play chess4, )e could first ha$e to specify the starting position of the chess board, the rules that define the legal mo$es, and the board positions that represent a )in for one side or the other. !n addition, )e must make e1plicit the pre$iously implicit goal of not only playing the legal game of chess but also )inning the game, if possible,

Playing chess
#he starting position can be described as an 5by 5 array )here each position contains a symbol for appropriate piece. 6e can define as our goal the check mate position. #he legal mo$es pro$ide the )ay of getting from initial state to a goal state. #hey can be described easily as a set of rules consisting of t)o parts. ' left side that ser$es as a pattern to be matched against the current board position. . 'nd a right side that describes the change to be made to reflect the mo$e

o)e$er, this approach leads to large number of rules %7%&7 board positions 88 9sing so many rules poses problems such as. :o person could e$er supply a complete set of such rules. . :o program could easily handle all those rules. ;ust storing so many rules poses serious difficulties.

Defining chess problem as State Space search


6e need to )rite the rules describing the legal mo$es in as general a )ay as possible. For e1ample. 6hite pa)n at S,uare/ file e, rank &0 ':D S,uare/ File e, rank (0 is empty ':D S,uare/file e, rank *0 is empty, then mo$e the pa)n from S,uare/ file e, rank &0 to S,uare/ file e, rank *0.

!n general, the more succintly )e can describe the rules )e need, the less )ork )e )ill ha$e to do to pro$ide them and more efficient the program.

6ater ;ug Problem


#he state space for this problem can be described as the set of ordered pairs of integers /1,y0 such that 1 < 7, %,&, ( or * and y < 7,%,& or (= 1 represents the number of gallons of )ater in the *+gallon >ug and y represents the ,uantity of )ater in (+gallon >ug #he start state is /7,70 #he goal state is /&,n0

Production rules for 6ater ;ug Problem

Sl :o % & ( * A B C

#he operators to be used to sol$e the problem can be described as follo)sCurrent state /1,y0 if 1 ? * /1,y0 if y ?( /1,y0 if 1 @ 7 /1,y0 if y @ 7 /1,y0 if 1@7 /1,y0 if y @7 /1,y0 if 1Dy @< * and y @7 :e1t State /*,y0 /1,(0 /1+d, y0 /1, y+d0 /7, y0 /1,70 /*, y+/*+100 Descritpion Fill the * gallon >ug Fill the ( gallon >ug Pour some )ater out of the * gallon >ug Pour some )ater out of the (+ gallon >ug 2mpty the * gallon >ug 2mpty the ( gallon >ug on the ground Pour )ater from the ( . gallon >ug into the * .gallon >ug until the *+gallon >ug is full

Production rules
5 /1, y0 if 1Dy @< ( and 1@7 /1+/(+y0, (0 Pour )ater from the *+gallon >ug into the (+gallon >ug until the (+ gallon >ug is full Pour all the )ater from the (+ gallon >ug into the *+gallon >ug Pour all the )ater from the *+ gallon >ug into the (+gallon >ug Pour the & gallons from (+gallon >ug into the *+gallon >ug 2mpty the & gallons in the *+ gallon >ug on the ground E /1, y0 if 1Dy ?<* and y@7 /1Dy, 70

%7

/1, y0 if 1Dy ?< ( and 1@7

/7, 1Dy0

%%

/7,&0

/&,70

%&

/&,y0

/7,y0

#o sol$e the )ater >ug problem


Fe,uired a control structure that loops through a simple cycle in )hich some rule )hose 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. Gne solution to the )ater >ug problem Shortest such se,uence )ill ha$e a impact on the choice of appropriate mechanism to guide the search for solution.
Hallons in the *+gallon >ug 7 7 ( ( * 7 & Hallons in the (+gallon >ug 7 ( 7 ( & & 7 Fule applied & E & C A or %& E 7r %%

Formal Description of the problem


%. Define a state space that contains all the possible configurations of the rele$ant ob>ects. &. Specify one or more states )ithin that space that describe possible situations from )hich the problem sol$ing process may start / initial state0 (. Specify one or more states that )ould be acceptable as solutions to the problem. / goal states0 *. Specify a set of rules that describe the actions / operations0 a$ailable.

Production Systems
' production system consists of ' set of rules, each consisting of a left side that determines the applicability of the rule and a right side that describes the operation to be performed if that rule is applied. Gne or more kno)ledgeIdatabases that contain )hate$er information is appropriate for the particular task. Some parts of the database may be permanent, )hile other parts of it may pertain only to the solution of the current problem. ' control strategy that specifies the order in )hich the rules )ill be compared to the database and a )ay of resol$ing the conflicts that arise )hen se$eral rules match at once. ' rule applier

Production system
!norder to sol$e a problem 6e must first reduce it to one for )hich a precise statement can be gi$en. #his can be done by defining the problemJs state space / start and goal states0 and a set of operators for mo$ing that space. #he problem can then be sol$ed by searching for a path through the space from an initial state to a goal state. #he process of sol$ing the problem can usefully be modelled as a production system.

Control Strategies
o) to decide )hich rule to apply ne1t during the process of searching for a solution to a problem" #he t)o re,uirements of good control strategy are that
. it should cause motion. . !t should be systematic

Breadth First Search


'lgorithm%. &. Create a $ariable called :GD2+K!S# and set it to initial state 9ntil a goal state is found or :GD2+K!S# is empty do
a. b. Femo$e the first element from :GD2+K!S# and call it 2. !f :GD2+K!S# )as empty, ,uit For each )ay that each rule can match the state described in 2 doi. 'pply the rule to generate a ne) state ii. !f the ne) state is a goal state, ,uit and return this state iii. Gther)ise, add the ne) state to the end of :GD2+K!S#

BFS #ree for 6ater ;ug problem


/7,70

/*,70

/7,(0

/*,(0

/7,70

/%,(0

/*,(0

/7,70

/(,70

'lgorithm- Depth First Search


%. !f the initial state is a goal state, ,uit and return success &. Gther)ise, do the follo)ing until success or failure is signaleda. Henerate a successor, 2, of initial state. !f there are no more successors, signal failure. b. Call Depth+First Search, )ith 2 as the initial state c. !f success is returned, signal success. Gther)ise continue in this loop.

Backtracking
!n this search, )e pursue a singal branch of the tree until it yields a solution or until a decision to terminate the path is made. !t makes sense to terminate a path if it reaches dead+ end, produces a pre$ious state. !n such a state backtracking occurs Chronological Backtracking- Grder in )hich steps are undone depends only on the temporal se,uence in )hich steps )ere initially made. Specifically most recent step is al)ays the first to be undone. #his is also simple backtracking.

'd$antages of Depth+First Search


DFS re,uires less memory since only the nodes on the current path are stored. By chance, DFS may find a solution )ithout e1amining much of the search space at all.

'd$antages of BFS
BFS )ill not get trapped e1ploring a blind alley. !f there is a solution, BFS is guarnateed to find it. !f there are multiple solutions, then a minimal solution )ill be found.

#SP
' simple motion causing and systematic control structure could sol$e this problem. Simply e1plore all possible paths in the tree and return the shortest path. !f there are : cities, then number of different paths among them is %.&L./:+%0 or /:+%08 #he time to e1amine single path is proportional to : So the total time re,uired to perform this search is proportional to :8 For %7 cities, %78 < (,B&5,577 #his phenomenon is called Combinatorial e1plosion.

Branch and Bound


Begin generating complete paths, keeping track of the shortest path found so far. Hi$e up e1ploring any path as soon as its partial length becomes greater than the shortest path found so far. 9sing this algorithm, )e are guaranteed to find the shortest path. !t still re,uires e1ponential time. #he time it sa$es depends on the order in )hich paths are e1plored.

euristic Search
' euristic is a techni,ue that impro$es the efficiency of a search process, possibly by sacrificing claims of completeness. euristics are like tour guides #hey are good to the e1tent that they point in generally interesting directions= #hey are bad to the e1tent that they may miss points of interest to particular indi$iduals. Gn the a$erage they impro$e the ,uality of the paths that are e1plored. 9sing euristics, )e can hope to get good / though possibly nonoptimal 0 solutions to hard problems such asa #SP in non e1ponential time. #here are good general purpose heuristics that are useful in a )ide $ariety of problem domains. Special purpose heuristics e1ploit domain specific kno)ledge

:earest :eighbour

euristic

!t )orks by selecting locally superior alternati$e at each step. 'pplying to #SP%. &. (. 'rbitrarily select a starting city #o select the ne1t city, look at all cities not yet $isited and select the one closest to the current city. Ho to ne1t step. Fepeat step & until all cities ha$e been $isited.

. .

#his procedure e1ecutes in time proportional to :& !t is possible to pro$e an upper bound on the error it incurs. #his pro$ides reassurance that one is not paying too high a price in accuracy for speed.

euristic Function
#his is a function that maps from problem state descriptions to measures of desirsability, usually represented as numbers.
. 6hich aspects of the problem state are considered, . ho) those aspects are e$aluated, and . the )eights gi$en to indi$idual aspects are chosen in such a )ay that

the $alue of the heuristic function at a gi$en node in the search process gi$es as good an estimate as possible of )hether that node is on the desired path to a solution. 6ell designed heuristic functions can play an important part in efficiently guiding a search process to)ard a solution.

21ample Simple euristic functions


Chess - #he material ad$antage of our side o$er opponent. #SP- the sum of distances so far #ic+#ac+#oe- % for each ro) in )hich )e could )in and in )e already ha$e one piece plus & for each such ro) in )e ha$e t)o pieces

Problem Characteristics
!norder to choose the most appropriate method for a particular problem, it is necessary to analyMe the problem along se$eral key dimensions. !s the problem decomposable into a set of independent smaller or easier subproblems" . Can solution steps be ignored or at least undone if they pro$e un)ise" . !s the problemJs uni$erse predictable" . !s a good solution to the problem ob$ious )ithout comparison to all other possible solutions" . !s the desired solution a state of the )orld or a path to a state" . !s a large amount of kno)ledge absolutely re,uired to sol$e the problem or is kno)ledge important only to constrain the search" . Can a computer that is simply gi$en the problem return the solution or )ill the solution of the problem re,uire interaction bet)een the computer and a person"

!s the problem Decomposable"


6hether the problem can be decomposed into smaller problems" 9sing the techni,ue of problem decomposition, )e can often sol$e $ery large problems easily.

Blocks 6orld Problem


Follo)ing operators are a$ailable CK2'F/10 N block 1 has nothing on itO+@ G:/1, #able0 CK2'F/10 and CK2'F/y0 +@ G:/1,y0 N put 1 on yO
Start- G:/C,'0 C ' B ' B C
HoalG:/B,C0 and G:/',B0

G:/B,C0 and G:/',B0 G:/B,C0 G:/',B0

G:/B,C0

CK2'F/'0 CK2'F/'0

G:/',B0 G:/',B0

Can Solution Steps be ignored or undone"


Suppose )e are trying to pro$e a math theorem.6e can pro$e a lemma. !f )e find the lemma is not of any help, )e can still continue. 5+puMMle problem Chess- ' mo$e cannot be taken back. !mportant classes of problems. !gnorable / theorem pro$ing0 . Feco$erable / 5+puMMle0 . !rreco$erable / Chess0

#he reco$erability of a problem plays an important role in determining the comple1ity of the control structure necessary for the problemJs solution.
. !gnorable problems can be sol$ed using a simple control structure that ne$er backtracks . Feco$erable problems can be sol$ed by a slightly more complicated control strategy that does sometimes make mistakes . !rreco$erable problems )ill need to be sol$ed by systems that e1pends a great deal of effort making each decision since decision must be final.

!s the uni$erse Predictable"


Certain Gutcome / e1- 5+puMMle0 9ncertain Gutcome / e1- Bridge, controlling a robot arm0 For sol$ing certain outcome problems, open loop approach / )ithout feedback0 )ill )ork fine. For uncertain+outcome problems, planning can at best generate a se,uence of operators that has a good probability of leading to a solution. 6e need to allo) for a process of plan re$ision to take place.

!s a good solution absolute or relati$e"


'ny path problem Best path problem 'ny path problems can often be sol$ed in a reasonable amount of time by using heuristics that suggest good paths to e1plore. Best path problems are computationally harder.

!s the solution a state or a path"


21amples. Finding a consistent interpretation for the sentence 3The bank president ate a dish of pasta salad with the fork4. 6e need to find the interpretation but not the record of the processing. . 6ater >ug - ere it is not sufficient to report that )e ha$e sol$ed , but the path that )e found to the state /&,70. #hus the a statement of a solution to this problem must be a se,uence of operations / Plan0 that produces the final state.

6hat is the role of kno)ledge"


#)o e1amples. Chess- Kno)ledge is re,uired to constrain the search for a solution . :e)spaper story understanding- Kot of kno)ledge is re,uired e$en to be able to recogniMe a solution.

Consider a problem of scanning daily ne)spapers to decide )hich are supporting the democrats and )hich are supporting the republicans in some election. 6e need lots of kno)ledge to ans)er such ,uestions as. #he names of the candidates in each party . #he facts that if the ma>or thing you )ant to see done is ha$e ta1es lo)ered, you are probably supporting the republicans . #he fact that if the ma>or thing you )ant to see done is impro$ed education for minority students, you are probably supporting the democrats. . etc

Does the task re,uire !nteraction )ith a person"


#he programs re,uire intermediate interaction )ith people for additional inputs and to pro$ided reassurance to the user. #here are t)o types of programs. Solitary . Con$ersational-

Decision on using one of these approaches )ill be important in the choice of problem sol$ing method.

Problem Classification
#here are se$eral broad classes into )hich the problems fall. #hese classes can each be associated )ith generic control strategy that is appropriate for sol$ing the problems. Classification - e1- medical diagnostics, diagnosis of faults in mechanical de$ices . Propose and Fefine- e1- design and planning

Production System Characteristics


%. &.
. . .

Can production systems, like problems, be described by a set of characteristics that shed some light on ho) they can easily be implemented" !f so, )hat relationships are there bet)een problem types and the types of production systems best suited to sol$ing the problems" Classes of Production systemsPonotonic Production System- the application of a rule ne$er pre$ents the later application of another rule that could also ha$e been applied at the time the first rule )as selected. :on+Ponotonic Production system Partially commutati$e Production system- property that if application of a particular se,uence of rules transforms state 1 to state y, then permutation of those rules allo)able, also transforms state 1 into state y. Commutati$e Production system

Ponotonic Production Systems


Production system in )hich the application of a rule ne$er pre$ents the later application of another rule that could also ha$e been applied at the time the first rule )as applied. i.e., rules are independent.

Commutati$e Production system


' partially Commutati$e production system has a property that if the application of a particular se,uence of rules transform state 1 into state y, then any permutation of those rules that is allo)able, also transforms state 1 into state y. ' Commutati$e production system is a production system that is both monotonic and partially commutati$e.

Partially Commutati$e, Ponotonic


#hese production systems are useful for sol$ing ignorable problems. 21ample- #heorem Pro$ing #hey can be implemented )ithout the ability to backtrack to pre$ious states )hen it is disco$ered that an incorrect path has been follo)ed. #his often results in a considerable increase in efficiency, particularly because since the database )ill ne$er ha$e to be restored, !t is not necessary to keep track of )here in the search process e$ery change )as made. #hey are good for problems )here things do not change= ne) things get created.

:on Ponotonic, Partially Commutati$e


9seful for problems in )hich changes occur but can be re$ersed and in )hich order of operations is not critical. 21ample- Fobot :a$igation, 5+puMMle, blocks )orld Suppose the robot has the follo)ing ops- go :orth /:0, go 2ast /20, go South /S0, go 6est /60. #o reach its goal, it does not matter )hether the robot e1ecutes the :+:+2 or :+2+:.

:ot partially Commutati$e


Problems in )hich irre$ersible change occurs 21ample- chemical synthesis #he ops can be -'dd chemical 1 to the pot, Change the temperature to t degrees. #hese ops may cause irre$ersible changes to the potion being bre)ed. #he order in )hich they are performed can be $ery important in determining the final output. /QDy0 DM is not the same as /MDy0 D1 :on partially commutati$e production systems are less likely to produce the same node many times in search process. 6hen dealing )ith ones that describe irre$ersible processes, it is partially important to make correct decisions the first time, although if the uni$erse is predictable, planning can be used to make that less important.

:on

Four Categories of Production System


Ponotonic :onPonotonic

Partially Commutati$e :ot Partially Commutati$e

#heorem pro$ing Chemical Synthesis

Fobot :a$igation Bridge

!ssues in the design of search programs


#he direction in )hich to conduct the search / for)ard $ersus back)ard reasoning0. o) to select applicable rules / Patching0 o) to represent each node of the search process / kno)ledge representation problem0

Summary
Four steps for designing a program to sol$e a problem%. Define the problem precisely &. 'nalyse the problem (. !dentify and represent the kno)ledge re,uired by the task *. Choose one or more techni,ues for problem sol$ing and apply those techni,ues to the problem.

You might also like