VIEWS: 293 PAGES: 11 CATEGORY: College POSTED ON: 9/8/2012
IGNOU MCSE-003 Solved Assignment 2011-2012 Course Code:MCSE-003 Course Title: Artificial Intelligence and Knowledge Management Assignment:MCA(5) Question 1: Discuss state space representation for the following well-known problems: (i) Water-Jug Problem, (ii) Human Cannibal River-Crossing Problem. (i) Water-Jug Problem (ii) The water jug problem is defined as follows: (iii) Assume that you have two jugs, Jug-A and Jug-B each of which holds a certain number of gallons. Initially, both gallons are full, but we have an infinite supply of water. Our task is to measure exactly X gallons. (iv) As an example: Jug-A holds 4 gallons, and Jug-B holds 3 gallons. We wish to obtain exactly 1 gallon. (v) We can look at a state as a pair of numbers, where the first represents the number of gallons of water currently in Jug-A and the second represents the number of gallons in Jug-B. (vi) Possible legal operators are: filling Jug-A, filling Jug-B, emptying Jug-A onto the ground, emptying Jug-B onto the ground, pouring Jug-A into Jug-B (until either Jug-A is empty or Jug-B is full), or pouring Jug-B into Jug-A (until either Jug-B is empty or Jug-A is full). (vii) Formulate this in writing as a search problem. Specify what the initial state looks like, what the goal state looks like, and how the operators change the states. (viii) Implement this search problem using depth first search and breadth first search. (ix) Your program should accept three integer values as parameters (the size of each jug and the gallons we need for the goal). It should also accept a parameter telling it which type of search to perform. (x) Your program should output the path to the goal as a sequence of states. It should also output the number of states that it visited, (i.e. placed on the stack or queue), the number of states that it expanded, and the average branching factor of all states that it expanded (average number of children that a node had). (Think about checking for repeated states or placing a maximum depth on paths for dfs.) (xi) I prefer your code to be in C/C++ so that (if I wish) I can run the executable on a UNIX or Linux machine (or Windows, for those of you who are used to VC++). However, any other language/platform is acceptable as long as you check with me in advance. Hand in a copy of your source code as well as both dfs and bfs output runs on a few problems, including the one above as well as a 9 gallon jug and 4 gallon jug where you wish to have 6 gallons. For this second problem, if you find that one (or both) of these two uninformed search methods takes too long because it explores too many search nodes, you may stop the program and output how many nodes were explored. This could occur if you do not check for repeated states.) Sl Current state Next State Descritpion No 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 (4, y-(4-x)) Pour water from and y >0 the 3 –gallon jug into the 4 –gallon jug until the 4- gallon jug is full 8 (x, y) if x+y >= (x-(3-y), 3) Pour water from 3 and x>0 the 4-gallon jug into the 3-gallon jug until the 3- gallon jug is full 9 (x, y) if x+y <=4 (x+y, 0) Pour all the water and y>0 from the 3-gallon jug into the 4- gallon jug 10 (x, y) if x+y <= (0, x+y) Pour all the water 3 and x>0 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 (xii) Human Cannibal River-Crossing Problem. A. Three missionaries and three cannibals come to a river. A rowboat that seats two is available. If the cannibals ever outnumber the missionaries on either bank of the river, the missionaries will be eaten. How shall they cross the river?'' Obviously the puzzler is expected to devise a strategy of rowing the boat back and forth that gets them all across and avoids the disaster. Amarel considered several representations of the problem and discussed criteria whereby the following representation is preferred for purposes of AI, because it leads to the smallest state space that must be explored to find the solution. A state is a triple comprising the numbers of missionaries, cannibals and boats on the starting bank of the river. The initial state is 331, the desired final state is 000, and one solution is given by the sequence (331,220,321,300,311,110,221,020,031,010,021,000). The boat is a rowboat. (Or the boat is a motorboat). This elaboration by itself should not affect the reasoning. By default, a tool is usable. Later elaborations make use of specific properties of rowboats. • There are four missionaries and four cannibals. The problem is now unsolvable. • There is an oar on each bank. One person can cross in the boat with just one oar, but two oars are needed if the boat is to carry two people. • One of the missionaries is Jesus Christ. Four can cross. Here we are using cultural literacy. However, a human will not have had to have read Mark 6: 48–49 to have heard of Jesus walking on water. • Three missionaries with a lone cannibal can convert him into a missionary. Since the order in which people are listed is of no significance, three missionaries and one cannibal can also be represented as 'CMMM' , 'MCMM' , etc. Should we leave this freedom of representation or is it better to fix a definite order? The latter is clearly preferable. We should anticipate the use of our Refal representations in patterns. With an arbitrary order of symbols, we shall use the pattern e1'M'e2 to determine whether there are missionaries on a given bank. This pattern includes an open e-variable which means a scan of the expression. If we agree to list missionaries before cannibals, the same can be done with the simpler pattern 'M'e1 . To find out whether there is at least one cannibal we use e1'C' , and to find out whether both kinds of humans are there, 'M'e1'C' We now turn to the set of possible moves. A move is a crossing of the river in a boat. Since the boat can take no more than two people, and cannot go by itself, there are five possible moves which we will represent by their sequential numbers in the following table: Move The boat takes: 1 two missionaries 2 two cannibals 3 a missionary and a cannibal 4 a missionary 5 a cannibal Not all moves are physically possible in every state. For instance, if the boat is on the left bank and there is only one missionary on this bank, then move 1 is impossible. But even if a move is possible, we must still check that it is admissible, i.e., does not result in manslaughter. Since a move is a transformation of the current state, we define The output is: The initial state: L (MMMCCC)() CC crossing to R bank: state R (MMMC)(CC) C crossing to L bank: state L (MMMCC)(C) CC crossing to R bank: state R (MMM)(CCC) C crossing to L bank: state L (MMMC)(CC) MM crossing to R bank: state R (MC)(MMCC) MC crossing to L bank: state L (MMCC)(MC) MM crossing to R bank: state R (CC)(MMMC) C crossing to L bank: state L (CCC)(MMM) CC crossing to R bank: state R (C)(MMMCC) M crossing to L bank: state L (MC)(MMCC) Question 2: Answer the following questions: (a) Represent the following statement as a associating network: “IGNOU is an open university established by an act of parliament. It has many divisions and schools of studies. Each school and division is headed by a Director”. "IGNOU is an open university established by an act of parliament. It has various schools of studies and Divisions to support academic activities at the Head Quarters. IGNOU's regional centers are spread all over the country to manage the academic and administrative activities. Each School and Division is headed by a Director and each Regional Centre is headed by Regional Directors." A:Network representations provide a means of structuring and exhibiting the structure in knowledge. In a network, pieces of knowledge are clustered together into coherent semantic groups. Networks also provide a more natural way to map to and from natural language than do other representation schemes. Network representations give a pictorial presentations of objects, their attributes and the relationships that exist between them and other entities. In this section, we describe general associative networks (also known as semantic networks) and conceptual graphs and give some of their properties. Associative networks are directed graphs with labeled nodes and arcs or arrows. The language used in constructing a network is based on selected domain primitives for objects and relationsa as well as some general primitives. A fragment of a simple network is illustrated below figured. In the figure, a class of objects known as bird is depicted. The class some properties and a specific memebers. Associative networks were introduced by Quallian(1968) to model the semantics of English sentences and words. He called his structures semantic networks to signify words by the paths connecting them. The connections were determined through a kind of “spreading activatioon” between the two words. Quillian's model of semantic networks has a certain intuitive appeal in that related information is clustered and bound together through relational links. The knowledge required for the performance of some tasks is typically contained within a narrow domain or a semantic vicinity of the taks. This type of organization in some way, resembles the way knowledge is stored and retrived in humans. The graphical portrayal of knowledge can also be some what more expensive than other representation schemes. This probably accounts for the popularity and the diversity of representation models for which they have been employed. They have, for example, been used in a variety of systems such as natural language understanding, information retrieval, deductive data bases, learning systems, computer vision, and in speech generation systems. (b) Show the conceptual dependency representation of the following sentence: “John wanted Marry to go to store”. Conceptual dependency theory offers a number of important benefits. By providing a iconal theory ofnatural language semantics, it reduces problems of ambiguity. Second, the Representation itself directly captures much of natural language semantics, by attempting to provide a canonical form for the meaning of sentences. That is, all sentences that have the same meaning will be represented internally by syntactically identical, not just semantically equivalent, graphs. This cauonical representation is an effort to simplify the mferences required for understanding. For example, we can demonstrate that two inferences mean the same thing with a simple match of conceptual dependency graphs; a representation that did not provide a canonical form might require extensive operations on differently structured graphs. Unfortunately, it is questionable whether a program may be written to reliably reduce sentences to canonical form. As Woods (1985) and others have pointed out, reduction to a canonical form is provably uncomputable for monoids, a type ofalgebraic group that is far simpler than natural language. There is also no evidence that humans store their knowledge in any such sort of canonical form. Tom believes that Jane likes pizza (b) Obtain CNF and DNF for the following given formula: ~ (A → (~ Bintersection C )) Obtain a disjunctive normal form for the formula ~ (A → (~ B ∧ C)). Consider A → (~B ∧ C) = ~ A ∨ (~B ∧ C) (Using (E→ F) = (~ E ∨ F)) Hence, ~ (A → (~ B ∧ C)) = ~ (~ A ∨ (~B ∧ C)) = ~ (~ A) ∧ (~ (~ B ∧ C)) (Using ~ ( E ∨ F) = ~ E ∧ ~ F) = A ∧ (B ∨ (~ C)) (Using ~ (~ E) = E and ~ (E ∧ F ) = ~ E ∨ ~ F = (A ∧ B) ∨ (A ∧ (~ C)) (Using E ∧ (F ∨ G) = (E ∧ F) ∨ (E ∧ G)) However, if we are to obtain CNF of ~ A (→ (~ B ∧ C)), in the last but one step, we obtain ~ (A → (~ B ∧ C)) = A ∧ (B ∨ ~ C), which is in CNF, because, each of A and ( B ∨ ~ C) is a disjunct. (d) Discuss Rule-Based Representation of knowledge. unit1 blk 4 Ans. Contains facts about the world Can be observed directly or derived from a rule Contains temporary knowledge –knowledge about this problem-solving session May be modified by the rules. Traditionally stored as a <object, attribute, value> triplet Examples: <CAR, COLOR, RED>: “The color of my car is red” <TEMPERATURE, OVER, 20>: “The temperature is over 20 C” Contains rules, each rule a step in a problem solving process. Rules are persistent knowledge about the domain. Typically only modified from the outside of the system, e.g. by an expert on the domain. Change The syntax is IF <conditions> THEN <actions> Question 3: Discuss the Physical Symbol System Hypothesis. Also, critically examine its validity, relevance and significance. Ans: The hypotheses states: "A physical symbol system has the necessary and sufficient means for intelligent action." A physical symbol system "consists of a set of entities, called symbols, which are physical patterns that can occur as components of another type of entity called an expression (or symbol structure). Thus, a symbol structure is composed of a number of instances (or tokens) of symbols related in some physical way (such as one token being next to another). At any instant of time the system will contain a collection of these symbol structures. Besides these structures, the system also contains a collection of processes that operate on expressions to produce other expressions: processes of creation, modification, reproduction and destruction. A physical symbol system is a machine that produces through time an evolving collection of symbol structures. Such a system exists in a world of objects wider than just these symbolic expressions themselves." "Two notions are central to this structure of expressions, symbols, and objects: designation and interpretation." "Designation. An expression designates an object if, given the expression, the system can either affect the object itself or behave in ways dependent on the object. ... In either case, access to the object via the expression has been obtained, which is the essence of designation." "Interpretation. The system can interpret an expression if the expression designates a process and if, given the expression, the system can carry out the process. ...Interpretation implies a special form of dependent action: given an expression the system can perform the indicated process, which is to say, it can evoke and execute its own processes from expressions that designate them." "Additional requirements involve completeness and closure. (1) A symbol may be used to designate any expression whatsoever. That is, given a symbol, it is not prescribed a priori what expressions it can designate. This arbitrariness pertains only to symbols; the symbol tokens and their mutual relations determine what object is designated by a complex expression. (2) There exist expressions that designate every process of which the machine is capable. (3) There exist processes for creating any expression and for modifying any expression in arbitrary ways. (4) Expressions are stable; once created they will continue to exist until explicitly modified or deleted. (5) The number of expressions that the system can hold is essentially unbounded." A physical symbol system defined as above is in the class of computational models defined by a Turing Machine. That is, it has a finite set of symbols which can be composed to form a potentially infinite set of expressions. And, at any point in time the system contains a collection of such symbol structures (cf. the contents of the tape). Further, this collection of symbol structures can be modified over time (cf. the rewriting of the tape). However, Newell and Simon emphasize two additional ideas; those of designation and interpretation. Both of these notions are further specifications on the role that symbol structures or expressions play within a symbol system. Designation is the idea that expressions can refer to something else. That is, a symbol is just a symbol is just a symbol is just a symbol Gertrude Stein unless there is some sense in which the symbol serves the function of reference. This is needed because the concern is not simply with a device that computes, but rather with a device that behaves with reference to a world that is external to itself. A symbolic expression designates some object if the system's behavior with respect to this outer world is dependent on the object which is referenced. Intuitively, the idea is that intelligent action is realized in relation to some external world. Thus, to reason about how to act in this world requires that the system of symbol structures in some senserepresent aspects of this external world. Interpretation is a further extension of this idea of the representational power of symbol structures. Here the idea is that a symbol structure or expression can in fact refer to a computational process that the system can interpret and carry out. This idea is familiar to us in the guise of a computer program. Viewed statically, a computer program is just a collection of expressions. But, if it is a valid program, then this set of expressions can be read and "turned into" a process that carries out the instructions represented by the program. This gives the system the ability to compose a potentially infinite set of programs that yield a potentially infinite set of processes for computing results from its possible inputs. Question 4: Give Frame-Based Representation for the following facts: “Ramesh is a 52 year old Professor of Mathematics in Delhi University. The name of his wife, son and daughter are respectively Seema, Yash and Kavita”. Also, Give Semantic Net representation of the facts given in this question. Ans: blk 4 expert system unit and two doc Question 5: Write A* algorithm. How is A* algorithm different from AO*? Out of the two which one is better and why? A* uses a best-first search and finds a least-cost path from a given initial node to one goal node (out of one or more possible goals). As A* traverses the graph, it follows a path of the lowest knownheuristic cost, keeping a sorted priority queue of alternate path segments along the way. It uses a distance-plus-cost heuristic function (usually denoted ) to determine the order in which the search visits nodes in the tree. The distance-plus-cost heuristic is a sum of two functions: the path-cost function, which is the cost from the starting node to the current node (usually denoted ) an admissible "heuristic estimate" of the distance to the goal (usually denoted ). The part of the function must be an admissible heuristic; that is, it must not overestimate the distance to the goal. Thus, for an application like routing, might represent the straight-line distance to the goal, since that is physically the smallest possible distance between any two points or nodes. If the heuristic h satisfies the additional condition for every edge x, y of the graph (where d denotes the length of that edge), then h is called monotone, or consistent. In such a case, A* can be implemented more efficiently—roughly speaking, no node needs to be processed more than once (see closed set below)—and A* is equivalent to running Dijkstra's algorithm with the reduced cost . A* and AO* are the two classical heuristic best-first al-gorithms for searching OR and AND/OR graphs (Hart,Nilsson, & Raphael 1968; Martelli&Montanari 1973;Pearl 1983). The A* algorithm is taught in every AI class,and has been studied thoroughly both theoretically and em- pirically. The AO* algorithm, on the other hand, has found less uses in AI, and while prominent in early AI texts (Nils-son 1980) it has disappeared from current ones (Russell & Norvig 1994). In the last few years, however, there has been a renewed interest in the AO* algorithm in planning re- search where problems involving uncertainty and feedback can be formulated as search problems over AND/OR graphs (Bonet&Geffner 2000). In this work, we carry out what is probably the first in-depth empirical evaluation of AO* in relation with other AND/OR graph search algorithms. We compare AO* with an old but general algorithm, Value Iteration (Bellman 1957; Bertsekas 1995), and a new algorithm, Learning in Depth- First Search, and its variant Bounded LDFS (Bonet& Geffner 2005). While VI performs a sequence of Bellman updates over all states in parallel until convergence, LDFS performs selective Bellman updates on top of successive depth-first searches, very much as Learning RTA* (Korf 1990) and RTDP (Barto,Bradtke, & Singh 1995) perform Bellman updates on top of successive greedy (real-time) searches. In the absence of accepted benchmarks for evaluating AND/OR graph search algorithms, we introduce four para- metric domains, and consider a large number of instances, some involving millions of states. In all cases we focus on the computation of solutions with minimum cost in the worst case using three different and general admissible heuristic functions. We find roughly that while AO* does better than VI in the presence of informed heuristics, LDFS, with or without heuristics, tends to do better than both. AO* is limited to handling AND/OR graphs without cy-cles. The difficulties arising from cycles can be illustrated by means of a simple graph with two states and two ac-tions: an action a with cost 5 maps the initial state s0 non- deterministically into either a goal state sG or s0 itself, and a second action b with cost 10 maps s0 deterministically into sG . Clearly, the problem has cost 10 and b is the only (opti- mal) solution, yet the simple cost revision step in AO* does not yield this result. Thus, for domains where such cycles appear, we evaluate a recent variant of AO*, CFCrev∗ , intro- duced in ( imen &Torras 2000) that is not affected by this eproblem. We could have used LAO* as well (Hansen &Zil-berstein 2001), but this would be an overkill as LAO* is de- signed to minimize expected cost in probabilistic AND/OR graphs (MDPs) where solutions themselves can be cyclic, something that cannot occur in Additive or Max AND/OR graphs. Further algorithms for cyclic graphs are discussed in (Mahanti, Ghose, &Sadhukhan 2003). LDFS has no lim-itations of this type; unlike AO*, it is not affected by the presence of cycles in the graph, and unlike Value Iteration, it is not affected either by the presence of dead- ends in the state space if the problem is solvable. The paper is organized as follows: we consider first the models, then the algorithms, the experimental set up and the results, and close with a brief discussion. AO* 1. Place the start node s on open. 2. Using the search tree constructed thus far, compute the most promising solution tree T 3. Select a node n that is both on open and a part of T. Remove n from open and place it on closed. 4. If n is a terminal goal node, label n as solved. If the solution of n results in any of n’s ancestors being solved, label all the ancestors as solved. If the start node s is solved, exit with success where T is the solution tree. Remove from open all nodes with a solved ancestor. 5. If n is not a solvable node (operators cannot be applied), label n as unsolvable. If the start node is labeled as unsolvable, exit with failure. If any of n’s ancestors become unsolvable because n is, label them unsolvable as well. Remove from open all nodes with unsolvable ancestors. 6. Otherwise, expand node n generating all of its successors. For each such successor node that contains more than one sub problem, generate their successors to give individual sub problems. Attach to each newly generated node a back pointer to its predecessor. Compute the cost estimate h* for each newly generated node and place all such nodes that do not yet have descendents on open. Next, recomputed the values of h* at n and each ancestor of n. 7. Return to step 2. Question 6: Write the following programmes: (a) Write a LISP programme to convert temperature in Centigrade to equivalent temperature in Fahrenheit. This function, given a specific degree in Farhrenheit, presents the user with equivalent Celsius degree. (defun convert () (format t "Enter Fahrenheit ") (LET (fahr) (SETQ fahr (read fahr)) (APPEND '(celsisus is) (*(- fahr 32)(/ 5 9)) ) ) ) (b) Write a LISP function that counts the number of atoms in a list. Ans: Ans. COUNT-ATOMS Define function that counts the atoms in a list (at all levels) > (defun count-atoms(L) (cond ((null l) 0) ((atom l) 1) (t (+ (count-atoms (car l)) (count-atoms (cdr l)))))) COUNT-ATOMS > (count-atoms '(a b c)) 3 > (count-atoms '(a (b c))) 3 > (count-atoms '(((a)))) 1