||Jai Sri Gurudev|| Sri AdichunchanagiriShikshana Trust (R) SJB Institute of Technology No. 67, BGS Health & Education City, Dr. Vishnuvardhan Road Kengeri, Bangalore – 560 060 Department of Information Science and Engineering ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING LABORATORY [ 18CSL76 ] VI I SEMESTER – B. E Staff Name: Dr.Rohini T V and Vishruth B Gowda Section: A & B Batch: A1, A2, A3, B1, B2 and B3 ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 1 PREFACE Artificial intelligence and machine learning deals with design of machines which are capable of learning and performing tasks ranging from ordinary category to expert category. The current manual is prepared to equip students with information required to conduct experiments necessary to understand and implement artificial intelligence and machine learning concepts like A*, Candidate elimination, naïve bayes etc The manual gives necessary information about basic concepts and techniques which could be appli ed to various domains for getting optimal solution This lab also helps student to develop some requisite knowledge to carry out final year project in the area of machine learning, data science, CNN etc. Overall it gives an exposure on hands - on aspects of th e artificial intelligence and machine learning discipline. ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 2 SJB INTITUTE OF TECHNOLOGY Institution ’s Vision To become a recognized technical education centre with a global perspective Institution ’s Mission To provide learning opportunities that foster students ethical values, intelligent development in science & technology and social responsibility so that they become sensible and contributing members of the society. Department of Information Science and Engineering Department Vision We envision our department as a catalyst for developing educated, engaged and employable individuals whose collective energy will be the driving force for prosperity and the quality of life in our diverse world. Department M ission Our mission is to provide quality technical education in the field of information technology and to strive for excellence in the education by developing and sharpening the intellectual and human potential for good industry and community. ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 3 PROGRAM EDUCATIONAL OBJECTIVES (PEO’S) Graduates will - • Possess expertise in problem solving, design and analysis, technical skills for a fruitful career accomplishing professional and social ethics with exposure to modern designing tools and technologies in Information Science and Engineering. • Excel in commun ication, teamwork and multipledomains related to engineering issues accomplishing social responsibilities and management skills. • Outclass in competitive environment through certification courses, gaining leadership qualities and progressive research to become successful entrepreneurs. PROGRAM SPECIFIC OUTCOMES (PSO’S) Graduates will be able to - 1. PSO1: Apply the Knowledge of Information Science to develop software solutions in current research trends and technology. 2. PSO2: Create Social awareness & environmental wisdom along with ethical responsibility to lead a successful career and sustain passion usi ng optimal resources to become an Entrepreneur. ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 4 PROGRAM OUTCOMES - PO’s Engineering graduates will be able to: 1. Engineering knowledge : Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. 2. Problem analysis : Identify, formulate, review research literature, and analyze complex engineeri ng problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. 3. Design/development of solutions : Design solutions for complex engineering problems and design system components or process es that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. 4. Conduct investigations of complex problems : Use research - based knowledge and research method s including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. 5. Modern tool usage : Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modelling to complex engineering activities with an understanding of the limitations. 6. The engineer and society : Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. 7. Environment and sustainability : Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. 8. Ethics : Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. 9. Individual and team work : Function effectively as an individual, and as a membe r or leader in diverse teams, and in multidisciplinary settings. 10. Communication : Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective r eports and design documentation, make effective presentations, and give and receive clear instructions. 11. Project management and finance : Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own w ork, as a member and leader in a team, to manage projects and in multidisciplinary environments. 12. Life - long learning : Recognize the need for, and have the preparation and ability to engage in independent and life - long learning in the broadest context o f technological change ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 5 University Syllabus ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING LABORATORY (Effective from the academic year 20 21 - 20 22 ) SEMESTER – VII Course Code 18CSL76 CIE Marks 40 Number of Contact Hours/Week 0:0:2 SEE Marks 60 Total Number of Lab Contact Hours 36 Exam Hours 03 Credits – 2 Course Learning Objectives: This course (18CSL76) will enable students to: • Implement and evaluate AI and ML algorithms in and Pyt hon programming language. Descriptions (if any): Installation procedure of the required software must be demonstrated, carried out in groups and documented in the journal. Programs List: 1. Implement A* Search algorithm 2. Implement AO* Search algorithm 3. For a given set of training data examples stored in a .CSV file, implement and demonstrate the Candidate - Elimination algorithm to output a description of the set of all hypotheses consistent with the training examples. 4. Write a program to demonstrate the working of the decision tree based ID3 algorithm . Use an appropriate data set for building the decision tree and apply this know ledge to classify a new sample. 5. Build an Artificial Neural Network by implementing the Backpropagation algorithm and test the same using appropriate data sets. 6. Write a program to implement the naïve Bayesian classifier for a sample training data set stored as a .CSV file. Compute the accuracy of the classifier, considering few test data sets. 7. Apply EM algorithm to cluster a set of data stored in a .CSV file. Use the same data set for clustering using k - Means algorithm . Compare the results of these two algor ithms and comment on the quality of clustering. You can add Java/Python ML library classes/API in the program. 8. Write a program to implement k - Nearest Neighbour algorithm to classify the iris data set. Print both correct and wrong predictions. Java/Python M L library classes can be used for this problem. 9. Implement the non - parametric Locally Weighted Regression algorithm in order to fit data points. Select appropriate data set for your experiment and draw graphs Laboratory Outcomes : The student should be able to: • Implement and demonstrate AI and ML algorithms. • Evaluate different algorithms. Conduct of Practical Examination: • Experiment distribution o For laboratories having only one part: Students are allowed to pick one experiment from the lot with equal opportunity. o For laboratories having PART A and PART B: Students are allowed to pick one experiment from PART A and one experiment from PART B, with equal opportunity. ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 6 • Change of experiment is allowed only once and marks allotted for procedure to be made ze ro of the changed part only. • Marks Distribution (Courseed to change in accoradance with university regulations) q) For laboratories having only one part – Procedure + Execution + Viva - Voce: 15+70+15 =100 Marks r) For laboratories having PART A and PART B i. Part A – Procedure + Execution + Viva = 6 + 28 + 6 = 40 Marks ii. Part B – Procedure + Execution + Viva = 9 + 42 + 9 = 60 Marks COURSE OUTCOMES On successful completion of this course students will be able to, CO’s COURSE OUTCOMES PO’s and PSO’s MAPPING CO1 Explore various python libraries useful for real time application and apply appropriate data sets to the ML algorithm PO 1 , PO 4 ,PO5 / PSO 1 CO2 Understand the implementation procedure for the machine learning and artificial intelligence algorithms. PO 1 , PO 2 / PSO1 CO3 Identify, apply and evaluate ML algorithms to solve real world problems. PO 1 , PO 2 ,PO 3 ,PO 4 , PO 5 / PSO1 General Instructions for the Laboratory Do’s ➢ It is mandatory for all the students to attend all practical classes & complete the experiments as per syllabus. ➢ Students should strictly follow the lab timings, dress code with Apron & ID cards. ➢ Should maintain a neat observation book. ➢ Study the theory and logic before executing the pro gram. ➢ Submit the completed lab records of executed programs and update the index book in every lab session. ➢ Should prepare for viva questions regularly. ➢ Handle the computer systems carefully. ➢ Maintain discipline and silence in the lab. Don’ts ➢ Should not ta ke Bags and Mobile phones into the Laboratory. ➢ Do not wear footwear inside the Laboratory ➢ Systems & Components should be handled carefully failing to which penalty will be imposed. ➢ Do not switch off the system abruptly. ➢ Should not chew gum or eat in th e lab. ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 7 LAB INDEX SHEET Sl.No. Experiment Description Page No. 1 Implement A* Search algorithm 8 - 13 2 Implement AO* Search algorithm 14 - 19 3 For a given set of training data examples stored in a .CSV file, implement and demonstrate the Candidate - Elimination algorithm to output a description of the set of all hypotheses consistent with the training examples. 20 - 22 4 Write a program to demonstrate th e working of the decision tree based ID3 algorithm . Use an appropriate data set for building the decision tree and apply this knowledge to classify a new sample. 23 - 26 5 Build an Artificial Neural Network by implementing the Backpropagation algorithm and test the same using appropriate data sets. 27 - 28 6 Write a program to implement the naïve Bayesian classifier for a sample training data set stored as a .CSV file. Compute the accuracy of the classifier, considering few test data sets. 29 - 31 7 Apply EM algorithm to cluster a set of data stored in a .CSV file. Use the same data set for clustering using k - Means algorithm . Compare the results of these two algorithms and comment on the quality of clustering. You can add Java/Python ML library classes/API in the program. 32 - 34 8 Write a program to implement k - Nearest Neighbour algorithm to classify the iris data set. Print both correct and wrong predictions. Java/Python ML library classes can be used for this problem. 35 - 37 9 Implement the non - parametric Locally Weighted Regression algorithm in order to fit data points. Select appropriate da ta set for your experiment and draw graphs 38 - 39 ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 8 1. Implement A* Search algorithm def aStarAlgo(start_node, stop_node): open_set = set(start_node) print('open_set',open_set) closed_set = set() print('set',set) g = {} #store distance from starting node parents = {}# parents contains an adjacency map of all nodes print('parents',parents) #ditanc e of starting node from itself is zero g[start_node] = 0 #start_node is root node i.e it has no parent nodes #so start_node is set to its own parent node parents[start_node] = start_node print('Start_node',start_node ) while len(open_set) > 0: print('open_set1',open_set) n = None print('n',n) #node with lowest f() is found for v in open_set: if n == None or g[v] + heuristic(v) < g[n] + heuristic(n): print('g[v]',g[v]) print('heuristic(v)',heuristic(v)) #print('g[n]',g[n]) #print('heuristic(n)',heuristic(n)) n = v print('v',v) if n == stop_node or Graph_nodes[n] == None: print('n1',n) pa ss else: for (m, weight) in get_neighbors(n): print('m',m) print('weight',weight) print('get_neighbors(n)',get_neighbors(n)) #nodes 'm' not in first and last set are added to first #n is set its parent ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 9 if m not in open_set and m not in closed_set: print('open_set',open_set) print('closed_set',closed_set) open_set.add(m) parents[m] = n print('n1',n) g[m] = g[n] + weight print('g[m]',g[m]) print('g[n]',g[n]) print('weight',weight) #for each node m,compare its distance from start i.e g(m) to the #from start through n node else: if g[m] > g[n] + weight: print('g1[m]',g[m]) #update g(m) g[m] = g[n] + weight #change parent of m to n parents[m] = n print('n2',n) #if m in closed set,remove and add to open if m in closed_set: print('m',m) closed_set.remove(m) open_set.add(m) print('open_set.add(m)',open_set.add(m)) if n == None: print('Path does not exist!') return None # if the current node is the stop_node # then we begin reconstructin the path from it to the start_node if n == stop_node: print('n3',n) path = [] print('path',path) while parents[n] != n: print('n4',n) path.append(n) n = parents[n] print('n5',n) print('parents[n]',parents[n]) path.append(start_node) ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 10 path.reverse() print('path.reverse()',path.reverse()) print('Path found: {}'.format(path)) return path # remove n from the open_list, and add it to closed_list # because all of his neighbors were inspected open_set.remove(n) closed_set.add(n) print(' closed_set.add(n)', closed_set.add(n)) print('Path does not exist!') return None #define fuction to return neighbor and its distance #from the passed node def get_neighbors(v): if v in Graph_nodes: print('v1',v) return Graph_nod es[v] print(Graph_nodes[v]) else: return None #for simplicity we ll consider heuristic distances given #and this function returns heuristic distance for all nodes def heuristic(n): H_dist = { 'S': 7, 'A': 6, 'B': 2, 'C': 1, 'D': 0, } return H_dist[n] print('H_dist[n]',H_dist[n]) #Describe your graph here Graph_nodes = { 'S': [('A', 1), ('B', 4)], 'A': [('B', 2), ('D', 12)], 'B': [('C', 2)], 'C': [('D', 3)], ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 11 } aStarAlgo('S', 'D') Output open_set {'S'} set <class 'set'> parents {} Start_node S open_set1 {'S'} n None g[v] 0 heuristic(v) 7 v S v1 S m A weight 1 v1 S get_neighbors(n) [('A', 1), ('B', 4)] open_set {'S'} closed_set set() n1 S g[m] 1 g[n] 0 weight 1 m B weight 4 v1 S get_neighbors(n) [('A', 1), ('B', 4)] open_set {'A', 'S'} closed_set set() n1 S g[m] 4 g[n] 0 weight 4 closed_set.add(n) None open_set1 {'A', 'B'} n None g[v] 1 heuristic(v) 6 v A g[v] 4 heuristic(v) 2 v B v1 B ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 12 m C weight 2 v1 B get_neighbors(n) [('C', 2)] open_set {'A', 'B'} closed_set {'S'} n1 B g[m] 6 g[n] 4 weight 2 closed_set.add(n) None open_set1 {'A', 'C'} n None g[v] 1 heuristic(v) 6 v A v1 A m B weight 2 v1 A get_neighbors(n) [('B', 2), ('D', 12)] g1[m] 4 n2 A m B open_set.add(m) None m D weight 12 v1 A get_neighbors(n) [('B', 2), ('D', 12)] open_set {'A', 'B', 'C'} closed_set {'S'} n1 A g[m] 13 g[n] 1 weight 12 closed_set.add(n) None open_set1 {'C', 'D', 'B'} n None g[v] 6 heuristic(v) 1 v C g[v] 3 heuristic(v) 2 v B v1 B m C ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 13 weight 2 v1 B get_neighbors(n) [('C', 2)] g1[m] 6 n2 B closed_set.add(n) None open_set1 {'C', 'D'} n None g[v] 5 heuristic(v) 1 v C v1 C m D weight 3 v1 C get_neighbors(n) [('D', 3)] g1[m] 13 n2 C closed_set.add(n) None open_set1 {'D'} n None g[v] 8 heuristic(v) 0 v D n1 D n3 D path [] n4 D n5 C parents[n] B n4 C n5 B parents[n] A n4 B n5 A parents[n] S n4 A n5 S parents[n] S path.reverse() None Path found: ['D', 'C', 'B', 'A', 'S'] ['D', 'C', 'B', 'A', 'S'] ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 14 2. Implement AO* Search algorithm class Graph: def __init__( self, graph, heuristicNodeList, startNode): #instantiate graph object with graph topology, heuristic values, start node self.graph = graph self.H=heuristicNodeList self.start=startNode self.parent={} self.status={} self.solutionGraph={} def applyAOStar(self): # starts a recursive AO* algorithm self.aoStar(self.start, False) def getNeighbors(self, v): # gets the Neighbors of a given node return self.graph.get(v,'') d ef getStatus(self,v): # return the status of a given node return self.status.get(v,0) def setStatus(self,v, val): # set the status of a given node self.status[v]=val def getHeuristicNodeValue(self, n): return se lf.H.get(n,0) # always return the heuristic value of a given node def setHeuristicNodeValue(self, n, value): self.H[n]=value # set the revised heuristic value of a given node def printSolution(self): print( "FOR GRAPH SOLUTION, TRAVERSE THE GRAPH FROM THE START NODE:",self.start) print(" ------------------------------------------------------------ ") print(self.solutionGraph) print(" ---------------------------------------------- -------------- ") def computeMinimumCostChildNodes(self, v): # Computes the Minimum Cost of child nodes of a given node v minimumCost=0 cost ToChildNodeListDict={} costToChildNodeListDict[minimumCost]=[] flag=True for nodeInfoTupleList in self.getNeighbors(v): # iterate over all the set of child node/s ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 15 cost=0 nodeList=[] for c, weight in nodeInfoTupleList: cost=cost+self.getHeuristicNodeValue(c)+weight nodeList.append(c) if flag==True: # initialize Minimum Cost with the cost of first set of child node/s minimumCost=cost costToChildNodeListDict [minimumCost]=nodeList # set the Minimum Cost child node/s flag=False else: # checking the Minimum Cost nodes with the current Minimum Cos t if minimumCost>cost: minimumCost=cost costToChildNode ListDict[minimumCost]=nodeList # set the Minimum Cost child node/s return minimumCost, costToChildNodeListDict[minimumCost] # return Minimum Cost and Minimum Cost child node/s def aoStar(self, v, backTracking): # AO* algorithm for a start node and backTracking status flag print("HEURISTIC VALUES :", self .H) print("SOLUTION GRAPH :", self.solutionGraph) print("PROCESSING NODE :", v) print(" ----------------------------------------------------------------------------------------- ") if self.getStatus(v) >= 0: # if status node v >= 0, compute Minimum Cost nodes of v minimumCost, childNodeList = self.computeMinimumCostChildNodes(v) self.setHeuristicNodeValue(v, minimumCost) self.setStatus(v,len(childNodeList)) solved=Tr ue # check the Minimum Cost nodes of v are solved for childNode in childNodeList: self.parent[childNode]=v if self.getStatus(childNode)!= - 1: solved=solved & False if solved==True: # if the Minimum Cost nodes of v are solved, set the current node status as solved( - 1) self.setStatus(v, - 1) self.solutionGraph[v]=childNodeList # update the solution graph with the solved nodes which may be a part of solution if v!=self.start: # check the current node is the start node for backtracking the current node value self.aoStar(self.parent[v], True) # backt racking the current node value with backtracking status set to true ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 16 if backTracking==False: # check the current call is not for backtracking for childNode in childNodeList: # for each Minimum Cost child node self.setStatus(childNode,0) # set the status of child node to 0(needs exploration) self.aoStar(childNode, False) # Minimum Cost child node is further explored with backtracking status as false h1 = {'A': 1, 'B': 6, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 5, 'H': 7, 'I': 7, 'J': 1, 'T': 3} graph1 = { 'A': [[('B', 1), ('C', 1)], [('D', 1)]], 'B': [[('G', 1)], [('H', 1)]], 'C': [[('J', 1)]], 'D': [[('E', 1), ('F', 1)]], 'G': [[('I', 1)]] } G1= G raph(graph1, h1, 'A') G1.applyAOStar() G1.printSolution() h2 = {'A': 1, 'B': 6, 'C': 12, 'D': 10, 'E': 4, 'F': 4, 'G': 5, 'H': 7} # Heuristic values of Nodes graph2 = { # Graph of Nodes and Edges 'A': [[('B', 1), ('C', 1)], [('D', 1)]], # Neighbors of Node 'A', B, C & D with repective weights 'B': [[('G', 1)], [('H', 1)]], # Neighbors are included in a li st of lists 'D': [[('E', 1), ('F', 1)]] # Each sublist indicate a "OR" node or "AND" nodes } G2 = Graph(graph2, h2, 'A') # Instantiate Graph object with graph, heuristic values and start Node G2.applyAOStar() # Run the AO* algorithm G2.printSolution() # Print the solution graph as output of the AO* algorithm search Output HEURISTIC VALUES : {'A': 1, 'B': 6, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 5, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 10, 'B': 6, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 5, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : B ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 10, 'B': 6, 'C ': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 5, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : A ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 17 ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 10, 'B': 6, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 5, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : G ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 10, 'B': 6, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 8, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : B ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 10, 'B': 8, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 8, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 12, 'B': 8, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 8, 'H': 7, 'I': 7, 'J': 1, 'T': 3} SOLUTION GRAPH : {} PROCESSING NODE : I ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 12, 'B': 8, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 8, 'H': 7, 'I': 0, 'J': 1, 'T': 3} SOLUTION GRAPH : {'I': []} PROCESSING NODE : G ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 12, 'B ': 8, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 1, 'T': 3} SOLUTION GRAPH : {'I': [], 'G': ['I']} PROCESSING NODE : B ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A ': 12, 'B': 2, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 1, 'T': 3} SOLUTION GRAPH : {'I': [], 'G': ['I'], 'B': ['G']} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- HE URISTIC VALUES : {'A': 6, 'B': 2, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 1, 'T': 3} SOLUTION GRAPH : {'I': [], 'G': ['I'], 'B': ['G']} PROCESSING NODE : C ------------------------------------------------------------------------ ---------- ------- HEURISTIC VALUES : {'A': 6, 'B': 2, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 1, 'T': 3} SOLUTION GRAPH : {'I': [], 'G': ['I'], 'B': ['G']} PROCESSING NODE : A ---------------------------------------------------- ------------------------------ ------- ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 18 HEURISTIC VALUES : {'A': 6, 'B': 2, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 1, 'T': 3} SOLUTION GRAPH : {'I': [], 'G': ['I'], 'B': ['G']} PROCESSING NODE : J ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 6, 'B': 2, 'C': 2, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 0, 'T': 3} SOLUTION GRAPH : {'I': [], 'G': ['I'], 'B': ['G'], 'J ': []} PROCESSING NODE : C ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 6, 'B': 2, 'C': 1, 'D': 12, 'E': 2, 'F': 1, 'G': 1, 'H': 7, 'I': 0, 'J': 0, 'T': 3} SOLUTION GRAPH : {'I': [ ], 'G': ['I'], 'B': ['G'], 'J': [], 'C': ['J']} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- FOR GRAPH SOLUTION, TRAVERSE THE GRAPH FROM THE START NODE: A ---------------------------------- -------------------------- {'I': [], 'G': ['I'], 'B': ['G'], 'J': [], 'C': ['J'], 'A': ['B', 'C']} ------------------------------------------------------------ HEURISTIC VALUES : {'A': 1, 'B': 6, 'C': 12, 'D': 10, 'E': 4, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 11, 'B': 6, 'C': 12, 'D': 10, 'E': 4, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {} PROCESSING NODE : D ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 11, 'B': 6, 'C': 12, 'D': 10, 'E': 4, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 11, 'B': 6, 'C': 12, 'D': 10, 'E': 4, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {} PROCESSING NODE : E --------------------------------- ------------------------------------------------- ------- HEURISTIC VALUES : {'A': 11, 'B': 6, 'C': 12, 'D': 10, 'E': 0, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {'E': []} PROCESSING NODE : D ----------------------------------------------------------- ----------------------- ------- HEURISTIC VALUES : {'A': 11, 'B': 6, 'C': 12, 'D': 6, 'E': 0, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {'E': []} PROCESSING NODE : A ARTIFICIAL INTELLIGENCE & MACHINE LEARNING LAB 18 CS L 76 Department of Information Science and Engineering, SJBIT P a g e 19 ---------------------------------------------------------------------------------- ---- --- HEURISTIC VALUES : {'A': 7, 'B': 6, 'C': 12, 'D': 6, 'E': 0, 'F': 4, 'G': 5, 'H': 7} SOLUTION GRAPH : {'E': []} PROCESSING NODE : F ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A' : 7, 'B': 6, 'C': 12, 'D': 6, 'E': 0, 'F': 0, 'G': 5, 'H': 7} SOLUTION GRAPH : {'E': [], 'F': []} PROCESSING NODE : D ---------------------------------------------------------------------------------- ------- HEURISTIC VALUES : {'A': 7, 'B': 6, 'C': 12, 'D': 2, 'E': 0, 'F': 0, 'G': 5, 'H': 7} SOLUTION GRAPH : {'E': [], 'F': [], 'D': ['E', 'F']} PROCESSING NODE : A ---------------------------------------------------------------------------------- ------- FOR GRAPH SOLUTION, T RAVERSE THE GRAPH FROM THE START NODE: A ------------------------------------------------------------ {'E': [], 'F': [], 'D': ['E', 'F'], 'A': ['D']} ------------------------------------------------------------