AI Print
AI Print
S’s
Vidhyadhan Commerce college Wadel Road Dhule
Department of Computer Science
Class:- SYBCA SEM -IV Subject BCA 407 Artificial Intelligence
Practical 1. Implementation of uninformed search techniques like, i) Breadth first Search
OUTPUT
S.S. and S. S’s
Vidhyadhan Commerce college Wadel Road Dhule
Department of Computer Science
Class:- SYBCA SEM -IV Subject BCA 407 Artificial Intelligence
Practical 1. Implementation of uninformed search techniques like, i) Breadth first Search
import itertools
def evaluate_subset(subset):
# Placeholder function to evaluate the performance of a feature subset
# Replace this with your own evaluation metric or scoring function
# Calculate the performance metric for the subset and return the score
return len(subset)
def evaluate_branch(subset):
nonlocal best_score
score = evaluate_subset(subset)
if score > best_score:
best_subset.clear()
best_subset.extend(subset)
best_score = score
open_set = set(start_node)
closed_set = set()
g = {} #store distance from starting node
parents = {}# parents contains an adjacency map of all nodes
#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:
#update g(m)
g[m] = g[n] + weight
#change parent of m to n
parents[m] = n
if n == None:
print('Path does not exist!')
return None
path.append(start_node)
path.reverse()
return H_dist[n]
}
aStarAlgo('A', 'G')
Vidhyadhan Commerce college Wadel Road Dhule
Department of Computer Science
Class:- SYBCA SEM -IV Subject BCA 407 Artificial Intelligence
Practical 2. Implementation of informed (Heuristic) search techniques like Hill climbing search
Student Name _____________________________________________________________
x = x0 # initial solution
while True:
if f(best_neighbor) <= f(x): # if the best neighbor is not better than x, stop
return x
cost = {}
if 'AND' in condition:
AND_nodes = condition['AND']
cost[Path_A] = PathA
if 'OR' in condition:
OR_nodes = condition['OR']
cost[Path_B] = PathB
return cost
Main_nodes = list(Conditions.keys())
Main_nodes.reverse()
least_cost= {}
condition = Conditions[key]
H[key] = min(c.values())
return least_cost
Path = Start
if Start in Updated_cost.keys():
Min_cost = min(Updated_cost[Start].values())
key = list(Updated_cost[Start].keys())
values = list(Updated_cost[Start].values())
Index = values.index(Min_cost)
Next = key[Index].split()
if len(Next) == 1:
Start =Next[0]
else:
Start = Next[0]
Start = Next[-1]
return Path
H = {'A': -1, 'B': 5, 'C': 2, 'D': 4, 'E': 7, 'F': 9, 'G': 3, 'H': 0, 'I':0, 'J':0}
Conditions = {
# weight
weight = 1
# Updated cost
print('*'*75)