Professional Documents
Culture Documents
Production systems (ps) Provide a scheme for structuring AI programs and performing the search process. A PS consists of A collection of condition action pairs called production rules A database of state information A procedure for invoking the production rules
1
(d) If x is not null and is equal to 9 then print IX and reduce x to 0. (e) If x is not null and is between 5 and 8 then print V and reduce x by 5. (f) If x is not null and is equal to 4 then print IV and reduce x to 0. (g) If x is not null and is between 1 and 3 then print I and reduce x by 1. (h) If x is not null and is equal to 0 then print an end of line and make x null.
3. Control Scheme : Test conditions in an arbitrary order until one is true; execute corresponding action; repeat indefinitely.
;Lisp program to convert integer to Roman numerals (Defun Roman (x)) loop (cond ((null x)(print enter number)(setq x (read))) (greaterp x 39) (print too big)(setq x wil)) ((greaterp x 9) (print x)(setq x (diference x 10))) ((equal x 9) print ix)(setq x 0) ((greaterp x 4) (print v)(setq x (diference x 5))) ((equal x 4) print iv)(setq x 0) ((greaterp x 0) (print I) (setqx (sub1 x ))) ((zerop x) (setq x nil ) ) (Go loop))
6
CONTROL STRATEGIES
Whether the problem is solved or not, how quickly the solution is arrived depends on the control strategy. If more than one rule matches the left side of the current state, which one to choose ?
Requirements of a good control strategy - IT Must Cause Motion Control strategies that do not cause motion will never lead to a solution. Example : In the water jug problem the strategy of choosing the first applicable rule from the top of the list of rules would continuously fill the 4-gallon jug. It would never solve the problem.
8
- Control strategy must be systematic Example : In the water jug problem, choosing a rule at random from among the applicable rules causes motion, but same state may be arrived several times, thus many steps are needed than necessary. A systematic Control Strategy causes global as well as local motion
ALGORITHM : DFS
1.
If the initial state is a goal stats quit and return success. 2. Otherwise do the following until success or failure is signaled. (a) Generate a successor E of the initial state. If there are no more successors, signal failure. (b) Call DFS with E as the initial state (c) If success is returned, signal success otherwise continue in this loop. A depth first search tree (DFS) for water jug problem.
11
ALGORITHM (BFS)
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 E, do : Two Levels of BFS for water jug problem (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
13
Example : Consider a map of cities of France, Transformed into a graph, which is an explicit representation of a state space. The implicit state space would be generated by applying the operators rather than preexisting.
14
15
(defun extract-path (n) (cond ((null n) nil) (t (append (extract-path (get n pointer)) (list n ) )) ) ) defun successors (N) (GET N ADJCNT) (defun ((null L1 L2) (cond ((Null L1) nil ) (( MEMBER (CAR (CDR L1 L2)) (( T cons (car L1) (set-diff (cdr L1) L2))))) for bfs step 5 i.e. (setq L (set-diff L closed)) (setq open (append L (set-diff open L))) is replaced with (setq L (set-diff(set-diff L open) closed)) (setq open (append open L )) (new nodes are put on the end of open)
16
Adjacency data (For each city, the other cities directly, connected to it) (putprop brest (rennes) adhct) (putrop rennes (laen paris brist nantes) adjct) (putprop paris (Calais nancy) Dijon limoges rennes Caen) adjct : Depth-first-search remes aviiur) Given the round about route (rennes caen, calajs nancy strasdooy Dijon lyon 17 grendble avignon)
BFS 1. Never gets trapped exploring a path which does not lead to a solution. 2. Guaranteed to find a solution if it exits. If multiple solutions exists a minimal one will be found 3. Requires more memory (All the tree that has so far been visited must be stored) 4. All nodes in level n must be examined before any node on level n + 1 can be examined 5. Only the best solution is found
DFS May explore a single unfruitful path for a long time. May find a long path when a shorter path exists Requires less memory (Only the nodes on the current path are to be stored) By chance a solution may be found without examining much of the nodes Can stop when any one solution is found
18
19
The number of paths among N different cities is N-1, N-2, 3.2.1 = (N-1) ! The time to examine a single path is proportional to N The total tine to perform the search is proportional to N ! If N = 10, 10! =3, 625, 800 If N = 25, the number will be very large This phenomenon is called combinatorial explosion
20
Generate complete paths keeping track of the shorted path found so far Stop exploring any path, as soon as its partial length exceeds the shortest path found so far The method is efficient but still requires exponential time.
21
HEURISTIC SEARCH
Control strategy to solve hard problems efficiently Need not cause motion and need not be systematic but provides a very good solution; the solution may not be the best A heuristic is a rule of thumb or judgemental technique used in problem solving Heuristic methods lead to a solution some of the time but provide no guarantee of success They reduce the number of a alternatives, and thereby obtain a solution in a tolerable amount of time
22
Some special purpose heuristics Problem :Discovering interesting ideas consider a function Y = f ( x , y) = x + y Heuristic : Two arguments are identical leads to the idea of squaring Y = f (x, y) = x U y The heuristic leads to the idea of identify function
24
25
In a rule based search process, heuristic knowledge can be incorporated In the rules themselves as in a chess playing system not simply the set of legal moves, but a set of sensible moves determined by the rule writer may be described. As a heuristic function that evaluates problem states and determines how desirable they are. The heuristic function is evaluated to a number.
26
PROBLEM CHARACTERISTICS
Heuristic Search is a general method to solve a large class of problems. To choose a specific appropriate method for a problem, it is necessary to analyse the problem along several key dimensions. 1. Is the problem decomposable into a set of independent smaller or easier subproblems?
27
28
29
Available operators:
1. If block x has nothing on it, pick up x and put it on table CLEAR (x) ON (x, TABLE) 2. CLEAR (x) and CLEAR (y) ON (x,y) The goal state can be represented as ON(B,C) and ON(A,B) To achieve ON(B,C) from start state we can apply ON (C,TABLE) and ON(B,C)
30
31
While achieving the second sub-goal, the first sub-goal is not achieved, as the two sub-problems are not independent. They interact and these interactions must be considered in order to arrive at a solution for the entire problem.
32
33
34
suppose we slide 5 into empty cell. To slide 6 into the empty cell, we need to undo the previous step. To undo an incorrect step, you need to record the order in which operations are performed. Mistakes can be recovered but not easily. Slightly more complicated control strategy
35
Probabilities of various outcomes are used to choose a plan Planning can generate a sequence of operators with a good probability of leading to a solution. A number of solution paths have to be explored Hardest problems -Irrecoverable, uncertain outcome Other examples : controlling a robot arm - Obstacles into the path - Gears might stick -Error may cause the arm to knock over a stack of things Helping a lawyer decide how to defend his client against murder case.
38
4. Is a good solution absolute or relative ? Consider the following database of facts 1. Marcus was a man 2. Marcus was a Pompeian 3. Marcus was born in 40 A.D 4. All men are mortal 5. All Pompeian's died when the volcano erupted in 79 A.D 6. No mortal lives longer than 150 years 7. It is now 2003 A.D
39
Consider the question Is Marcus alive? There are two reasoning paths leading to the answer Marcus is dead. Path 1 Axioms used 8. Marcus is mortal 1,4 9. Marcuss age is 1963 years 3,7 10.Marcus is dead 8,9,6 Reasoning path- 2 11.All Pompeian's are dead now 7,5 12.Marcus is dead 11,2
40
Comments : We are interested in only the answer to the question - it does not matter which path we follow If one path leads successfully to the answer, there is no need of exploring the other path
41
Now consider the following table of distances (Km) for traveling sales person problem : New Delhi Bombay Madras Calcutta New Delhi 2200 2350 2800 Bombay 2200 3000 2500 Madras 2350 3000 1200 Calcutta 2800 2500 1200 -
42
The goal is to find the shortest path that visits each city exactly once.
First Path is not definitely the solution. This example illustrates any-path problem or best-path problem.
43
consider the sentence The bank president ate a dish of pasta salad with the fork. In interpreting the sentence, some of the sources of ambiguity are
44
45
food does not contain dog With the fork modifies the verb eat; He ate with vegetables or He ate with friends, then structure would be different. Thus search would be required for complete interpretation for the sentence. For the above NLU problem, no need to record the processing by which the interpretation was found.
46
In the water jug problem, it is not sufficient to say that the final state is (2,0), but the path or a sequence of operations leading to the goal state are required . NLU problem- solution is a state Water jug problem path to a state
47
48
50
Partially commutation (PS) : It is a PS with the property if the sequence of rules transforms state x into state y, then any permutation of these rules also transforms state x into state y. A commutative PS is one that is monotonic and partially commutative. Formally all kinds of problems can be solved by all kinds of system. Practically there is a relationship between the kinds of problems and kinds of systems.
51
Examples :
Monotonic Partially commutative Theorem proving No monotonic Robot navigation blocks word 8-puzzle Bridge
Chemical synthesis
52
Monotonic & partially commutative systems are for ignorable problems Non Monotonic & partially commutative systems are for recoverable problems. Issues in the design of search problems : Search process can be viewed as a traversal of tree.Each node represents a problem state and each arc represents a relationship between the states. In practice, most of the tree need not be explored for reaching a solution. Most search programs represent the tree implicitly in the rules and generate explicitly those parts 53 that they decide to explore.
Issues in search technique : The direction in which to conduct the test forward versus backward reasoning (to search from start state to goal state or from goal to start) How to select applicable rules or how to match rules against states How to represent each node of the search process (knowledge representation problem). The search space may be an arbitrary directed graph rather than a tree as same nodes may be generated as part of several paths.
54
55