Академический Документы
Профессиональный Документы
Культура Документы
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
2
Intelligent Agent
Agent Policy Action
State
Reward
Environment
Agent: Intelligent programs Environment: External condition Policy: Defines the agents behavior at a given time A mapping from states to actions Lookup tables or simple function
3
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
Representing states
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.
7
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
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.
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.
10
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 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
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
12
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
2.
3.
4.
Define the problem precisely Analyze the problem Isolate and represent the task knowledge that is necessary to solve the problem Choose the best problem-solving techniques and apply it to the particular problem.
14
15
16
4. Best Techniques.
Choose the best problem solving technique and apply it to the particular problem.
17
3.
4. 5.
Initial States Final States (Goal State) Intermediate states Operators, which indicates action to be performed for making the changes in the initial states to reach the goal state. A complete knowledge of the problem which is needed for applying the operators to make a state change.
18
Solution Stages
1.
2.
3.
Initial state Final state Operators that can be applied Abbreviations State space representation of the given problem Operators and Conditions.
20
1. Assumptions
In order to solve the given problem we can make the following assumptions without affecting the problem.
1.
2. 3.
4.
We can fill the jugs with the help of a pump. We can pour water from any jug to the ground. We can transfer water from one jug to the other. No external measuring devices are available.
22
2. Solution Steps
We can list the steps that may be followed to reach the goal state.
1. 2.
3.
4.
5.
6.
7.
Fill the 3 gallon jug with water Pour the water from 3 gallon jug to 4 gallon jug. Again fill the 3 gallon jug with water Pour the water carefully from 3 gallon jug to 4 gallon jug such that it is just filled. Empty the 4 gallon jug Transfer the water from 3 gallon jug to 4 gallon jug. Stop.
23
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
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 4gallon 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.
25
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.
26
27
State No.
Operator
State (G4,G3)
0 (Initial) 1 2 3 4 5 6 (Final)
--------FILL (G3) TRANSFER (G3, G4) FILL (G3) POUR (G3, G4) EMPTY (G4) TRANSFER (G3,G4)
TRANSFER (G3,G4)
Sl No 1 2 3 4 5 6 7
30
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 Pour all the water from the 3gallon jug into the 4-gallon jug Pour all the water from the 4gallon jug into the 3-gallon jug Pour the 2 gallons from 3gallon jug into the 4-gallon jug Empty the 2 gallons in the 4gallon jug on the ground
(x+y, 0)
10
(0, x+y)
11
(0,2)
(2,0)
12
(2,y)
(0,y)
31
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.
Rule applied 2 9 2 7 5 or 12 9 0r 11
32
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
33
34
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.
35
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.
36
Possible Move
37
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.
38
Define a state space that contains all the possible configurations of the relevant objects. Specify one or more states within that space that describe possible situations from which the problem solving process may start ( initial state)
2.
3.
Specify one or more states that would be acceptable as solutions to the problem. ( goal states)
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?
39
4.
Production Systems
40
Production Systems
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
41
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
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
43
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 problems 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.
44
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.
45
Breadth-First search
Searching 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 dont get goal state
46
1.
Algorithm:
Create a variable called NODE-LIST and set it to initial state Until a goal state is found or NODE-LIST is empty . do
a.
2.
b.
Remove the first element from NODE-LIST and call it E. If NODE-LIST was empty, quit For each way that each rule can match the state described in E do:
i. ii. iii.
Apply the rule to generate a new state If the new state is a goal state, quit and return this state Otherwise, add the new state to the end of NODE-LIST
47
(4,0)
(0,3)
(4,3)
(0,0)
(1,3)
(4,3)
(0,0)
(3,0)
48
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.
49
Problems Of BFS :
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.
If the initial state is a goal state, quit and return success 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.
51
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.
52
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.
53
Drawback of DFS
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.
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
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.
56
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.
57
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
58
1. 2.
3.
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.
59
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.
60
Chess : The material advantage of our side over opponent. TSP: the sum of distances so far Tic-Tac-Toe: ???/
61
4 square problem :
1
2
3
B
B 1
3 2
8 square problem :
1 8 4 2 5 7 3 6 1 8 7 6 2 3 4 5
62
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 problems 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?
63
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
64
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]
Start: ON(C,A) C A B
B
C
Goal: ON(B,C) and ON(A,B)
ON(B,C)
ON(A,B)
CLEAR(A) CLEAR(A)
ON(A,B) ON(A,B) 65
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
66
Conti ..
The recoverability of a problem plays an important role in determining the complexity of the control structure necessary for the problems 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
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.
68
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.
69
4.
5. 6. 7.
Marcus was a man Marcus was a Pompean Marcus was born in 40 AD All men are mortal All Pompeans died when volcano erupted in 79 AD No mortal lives longer than 150 years Now it is 1983 AD Is Marcus alive now?
1. Marcus was a man 4. All men are mortal 8. Marcus was Mortal 3. Marcus was born in 40 AD 7. Now it is 1983 AD 9. Marcus lived 1983 years 6. No mortal lives longer than 150 years 10. Marcus is not alive
Axiom 7
Axiom 5 7, 5
Axiom 2 11,2
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.
73
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
74
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.
75
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
76
2.
Can production systems, like problems, be described by a set of characteristics that shed some light on how they can easily be implemented? 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
77
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.
78
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.
79
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.
80
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.
81
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.
82
83
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)
84
Summary
3.
4.
Define the problem precisely Analyse the problem Identify and represent the knowledge required by the task Choose one or more techniques for problem solving and apply those techniques to the problem.
85
Reference
Artificial Intelligence by Elaine Rich & Kevin
Knight, Third Ed, Tata McGraw Hill
Artificial
Patterson
86