Problems, Problem Spaces and Search: Dr. Suthikshn Kumar
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
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.
!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.
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
/7, 1Dy0
%%
/7,&0
/&,70
%&
/&,y0
/7,y0
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
/*,70
/7,(0
/*,(0
/7,70
/%,(0
/*,(0
/7,70
/(,70
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 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.
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.
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"
G:/B,C0
CK2'F/'0 CK2'F/'0
G:/',B0 G:/',B0
#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.
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
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
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
:on
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.