Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Department of Computer Science & Engineering

Winter Semester, Session: 2021-2022


Subject: Principal of Artificial Intelligence (Open Elective)
Time: 3 Hours
Max. Marks: 100
Instructions: Answer the questions as per the instruction within each section.

Sl. Section-I ( 60 Marks: Attempt All Question) Marks


No.

1. (a) You are given the missionaries and cannibals problem, which states that there
are 3 missionaries and 3 cannibals on one side of a river, along with a boat that
can hold one or two people. The problem is to find a way to get everyone to the
other side of the river without ever leaving a group of missionaries in one place
outnumbered by the number of cannibals in the same place. Discuss the state
space representation of this problem and formulate the same as a search problem.

Initial state is (3 3 L) and the goal state is (0 0 R) [ 1 Mark ]


Operators are: MM: 2 missionaries cross the river
CC: 2 cannibals cross the river
MC: 1 missionary and 1 cannibal cross the river
M: 1 missionary crosses the river
C: 1 cannibal crosses the river [ 1 Mark ]

State space search illustration :


State generation using operators [ 2 Marks ]
Cross the invalid states generated due to constraint ( i.e. missionaries in one
place outnumbered by the number of cannibals) [ 1 Marks]

(b) Why are the AO* algorithm do not use the ‘g’ value, which signifies the actual
cost to reach current node from initial node, to calculate overall cost value of a
node? Consider the search problem represented in figure shown below, where a
is the start node and e is the goal node. The pair [f; h] at each node indicates the
value of the f and h functions for the path ending at that node. Is the heuristic
function h admissible? Explain why or why not?

AO * Algorithm always selects a node which is a part of current best path from
Source, so there is no need to compute g value. [ 2 Marks]

Yes given heuristic function is admissible. [ 0.5 Marks]

Explanation : It never overestimate the distance to goal as per following


g(a,c) =2 , g( c,e) = 1 , g(c,f)= 1 , g(a,b) = 1 , g(b,d) = 1
[ 1 Marks ]

No given heuristic function is not consistent. [ 0.5 Marks]


Explanation : It never overestimate the distance to goal as per following

A heuristic function h(n) is consistent if for every node n and every successor
n’of n generated by action a, the following inequality holds:

h(n) < = c( n,a,n’) + h(n’)

As per given figure in question the above violates for example :

h(a) >= h(b)+ c(a,b) i.e. 3 >= 4 ,which is not true [ 1 Marks]

(c) Analyze the performance of following blind search algorithms in terms of time
and space complexity, completeness and optimality. You may assume average
branching factor as b, solution depth as d, and m as a maximum traversal depth
in case of depth first search to analyze the time and space complexity of
algorithms.
(i) Depth First Search

Time Complexity : O( bm)


Space Complexity : O ( bm)
Optimal : No
Completeness : No
[ 0.5x4=2 Marks ]
(ii) Depth First with iterative Deepening
Time Complexity : O( bd)
Space Complexity : O ( bd)
Optimal : Yes, if cost is unique for each arc/edge
Completeness : Yes

[ 0.5x4=2 Marks ]
Explanation for time and space complexity [1 Marks ]

Time Complexity :
If branching factor is b and solution is at depth d, then nodes at depth d are
generated once, nodes at depth d-1 are generated twice, etc., and node at depth 1
is generated d times. Hence total number of node to be expanded

Total = b^d + 2b^(d-1) + ... + db

<= b^d / (1 - 1/b)^2 = O(b^d).


Space Complexity: Similar to DFS with d depth i.e. O(bd)

2. (a) Can we apply minimax search algorithm for a game in which opponent is
playing sub-optimally? Explain why or why not?

No we cannot apply for such game [ 1 Marks ]


minmax optimality will not be ensured during search for game [ 1 Marks ]
(b) Consider the game tree for tic-tac-toe game shown below. Show how minimax
search algorithm works for selecting best move with respect to maximizing
player.

Static evaluation function value calculation for each leaf node : [3 Marks]

Correct backward propogation of values as shown in figure [ 1 Marks ]

Maximizing player will select ‘A’ as best move based on calculation shown below.

[ 2 Marks ]
(c ) Cross out each leaf value that would be pruned by alpha-beta pruning.

[ 1 Marks] [2 Marks ] [2 Marks ]

3. (a)You are in charge of scheduling for computer science classes that meet Mondays,
Wednesdays and Fridays. There are 5 classes that meet on these days and 3
professors who will be teaching these classes. You are constrained by the fact
that each professor can only teach one class at a time.
The classes are:
Class 1 - Intro to Programming: meets from 8:00-9:00am
Class 2 - Intro to Artificial Intelligence: meets from 8:30-9:30am
Class 3 - Natural Language Processing: meets from 9:00-10:00am
Class 4 - Computer Vision: meets from 9:00-10:00am
Class 5 - Machine Learning: meets from 9:30-10:30am
The professors are:
Professor A, who is available to teach Classes 3 and 4.
Professor B, who is available to teach Classes 2, 3, 4, and 5.
Professor C, who is available to teach Classes 1, 2, 3, 4, 5.
(i) Formulate this problem as a CSP problem in which there is one variable per
class, stating the domains, and constraints. Constraints should be specified
formally and precisely, but may be implicit rather than explicit.
(ii) Draw the constraint graph associated with your CSP.
(iii)Show the domains of the variables after running arc-consistency on this initial
graph (after having already enforced any unary constraints)
(iv) Give one solution to this CSP.

Variables : C1,C2,C3,C4,C5 [ 0.5 Marks ]

Domains [ 1 Marks]
C1 C
C2 B, C
C3 A, B, C
C4 A, B, C
C5 B, C
Constraints [ 1.5 Marks]
C1 ≠ C2
C2 ≠ C2
C3 ≠ C4
C4 ≠ C5
C2 ≠ C4
C3 ≠ C5
Constraint graph associated with CSP [ 2 Marks]

C2

C1

C5

C4
C3

Arc Consistency : [ 0.5x6=3 Marks ]

C1 → C2 (C) → (B, C)
C2 → C1 (B, C) → C [ ‘C’ Deleted]
C2 → C4 (B) → (A, B, C)
C4 → C2 (A, B, C) → (B) [ ‘B’ Deleted ]

C2 → C3 (B) → (A, B, C)
C3 → C2 (A, C) → (B) [ ‘B’ Deleted ]

C3 → C4 (A, C) → (A, C)
C4 → C3 (A, C) → (A, C)

C4 → C5 (A, C) → (B, C)
C5 → C4 (B, C) → (A, C)

C3 → C5 (A, C) → (B, C)
C5 → C3 (B, C) → (A, C)

C1 = C, C2 = B, C3 = (A, C), C4 = (A, C), C5 = (B, C) [ 1 Marks ]

(b) Draw the constraint hyper graph to solve the following crypt-arithmetic puzzle
using CSP approach.
CROSS + ROADS = DANGER

No two letters can have same value along with following constraints.
S + S = R + 10 X1
X1 + S + D = E + 10 X2
X2 + O + A = G + 10 X3
X3 + R + O = N + 10 X4
X4 + C + R = A + 10 X5
X5 = D [ 2 Marks ]

[ 3 Marks]

D C R A O N G S E

X5 X4 X3 X2 X1
4. (a) What do you mean by conditional independence? (2)

Suppose A is a parent of B, B is parent of C in a Bayesian network then


A and C are conditionally independent if B occurs. [ 2 Marks ]

(b)Consider the Bayesian network shown below, which is showing both the
topology and the conditional probability tables (CPTs). In the CPTs, the letters
B, E, A, J and M stand for Burglary, Earthquake, Alarm, John Calls, and Mary
Calls, respectively.

i)Express the joint distribution P(B,E,A,J,M) in terms of the conditional


probabilities expressed in the Bayesian Network above. Calculate the probability of
same.

P(B)x P(E)x P(A| B,E)) x P(J|A) x P( M|A) [ 1 Marks ]

= 0.000001197 [1 Marks ]

ii) What is the probability of Burglary given JohnCalls true?

P(BJ) = 00086 [ 1.5 Marks ]

P(J) = 0.05212 [ 1.5 Marks]

P(BJ)/ P(J) = 0.016 [ 1 Marks]

iii) What is the probability of Marry Calls given Burglary is true?

P(MB) = 0.0006655 [ 2 Marks]


P(MB)/P(B) = 0.66 [ 1 Marks]
iv) What is the probability of Burglary given John calls and Mary calls true?

P(JMB) = 0.000592 [ 1.5 Marks]


P(JM) = 0.002084 [1.5 Marks]
P(JMB)/P(JM) = 0.28 [1 Marks]

Section-II( 40 Marks: Attempt Any FOUR Question)


5. (a)Compute max-min composition (PoQ) of following fuzzy relations

[ 05x6=3 Marks]
[1 Marks]

(b) Perform following Fuzzy Arithmetic operations (as given inputs in Figure).

(i) Addition
(ii) Subtraction

, x=2α+3
, x=7-2α

, x=2α+6
, x=10-2α
= x=2α+3
= x=7-2α
= x=2α+6
= x=10-2α
(i) Addition

( 2α+3 + 2α+6 = 4α+9 [ 1 Marks ]

7-2α + 10-2α = 17-4α [1 Marks ]

[1 Marks]

α
0 9 17
0.25 10 16
0.5 11 15
0.75 12 14
1 13 13

(ii) Subtraction

( 2α+3 – 10+2α = 4α-7 [ 1 Marks ]

7-2α - 2α-6 = 1-4α [1 Marks ]

[ 1 Marks ]

α
0 -7 1
0.25 -6 0
0.5 -5 -1
0.75 -4 -2
1 -3 -3
6. (a) Imagine that you are given the following set of training examples. Each feature
can take on one of three nominal values: a, b, or c.
P(+)=2/5=0.4
P(-)=3/5=0.6
Test sample, F1=a, F2=c, F3=c
P(+)=0.4*1/2*1/2*1/2=0.05 [ 2 Marks]
P(-)=0.6*1/3*2/3*1/3=0.044 [2 Marks]
P(+) is higher than P(-), So, test sample is more near to Positive (+) class.[1 Marks ]

(b) Consider a set of five training examples given as ((xi, yi), ci) values, where xi
and yi are the two attribute values (positive integers) and ci is the binary class
label: {((1, 1), −1), ((1, 7), +1), ((3, 3), +1), ((5, 4), −1), ((2, 5), −1)}.
Classify a test example at coordinates (3, 6) using a k-NN classifier with k = 3 and
Manhattan distance defined by d((u, v), (p, q)) = |u − p| + |v − q|. Your answer
should be either +1 or -1.

Individual point distance calculation from test sample. [0.5x5 =2.5 Marks ]

Xi Yi Ci |u-p|+|v-q| K=3
1 1 -1 2+5=7
1 7 +1 2+1=3 3rd nearest
3 3 +1 0+3=3 2nd nearest
5 4 -1 2+2=4
2 5 -1 1+1=2 1st nearest

Writing 3 nearest neighbor obtained [0.5x3=1.5 Marks ]

As number of (+) Label > (-) Label of nearest neighbors , so classified as (+)
[ 1 Marks ]

7. Consider the following initial and goal states of a Block-World problem in FOL and (10)
show how the TWEAK method would solve this problem.
Start: ON(C,A) ʌ ONTABLE(B) ʌ CLEAR(C) ʌ ONTABLE(A) ʌ CLEAR(B)
Goal: ON(A,B) ʌ ON(B,C) ʌ ONTABLE(C) ʌ CLEAR(A)

Please see attached annexure .


8. Suppose a genetic algorithm uses chromosomes of the form x = abcdefgh with a
fixed length of eight genes. Each gene can be any digit between 0 and 9. Let the
fitness of individual x be calculated as: f(x) = (a + b) − (c + d) + (e + f) − (g + h) ,
and let the initial population consist of four individuals with the following
chromosomes:
x1 = 6 5 4 1 3 5 3 2 , x2 = 8 7 1 2 6 6 0 1 , x3 = 2 3 9 2 1 2 8 5 , x4 = 4 1 8 5 2 0 9 4
(i) Evaluate the fitness of each individual, showing all your workings, and arrange (4)
them in order with the fittest first and the least fit last.
(ii) Cross the fittest two individuals using one–point crossover at the middle point. (2)
(iii) Cross the second and third fittest individuals using a two–point crossover (2)
(points b and f).
iv) Cross the first and third fittest individuals (ranked 1st and 3rd) using a uniform (2)
crossover.

X1 = 65413532
X2 = 87126601
X3 = 23921285
X4 = 41852094
(i) Fitness value
F(x1)=(6+5)-(4+1)+(3+5)-(3+2) = 9 65 4135 32

F(x2)=(8+7)-(1+2)+(6+6)-(0+1) = 23 23 9212 85

F(x3)=(2+3)-(9+2)+(1+2)-(8+5) = -16
F(x4)=(4+1)-(8+5)+(2+0)-(9+4) = -19
[ 1x4 = 4 Marks ]
(ii) One point cross over fittest two individuals
X2= 8712 | 6601
X1= 6541 | 3532

O1= 87123532 [ 1 Marks ]


O2= 65416601 [ 1 Marks ]
(iii)Cross the second and third fittest individuals using a two point crossover
(points b and f).
X1 = 65 | 4135 | 32
X3 = 23 | 9212 | 85

O3 = 65921232 [1 Marks ]
O4 = 23413585 [1 Marks ]
(iv) Cross the first and third fittest individuals using a uniform crossover.
X2 = 87126601
X3 = 23921285
Random exchange :
O5 = 83126605 [ 1 Marks]
O6 = 27921281 [1 Marks ]
9. (a) Consider the following data set with three binary input attributes (A1, A2, and
A3) and one binary output, y.What is the variable at the root of the decision tree? ?
Decision Tree
instanc A1 A2 A3 y
e
1 1 0 0 0
2 1 0 1 0
3 0 1 0 0
4 1 1 1 1
5 1 1 0 1

[ 1 Marks ]

S1 <- [2->0, 2->1], Entropy=1


S0 <- [1->0], Entropy=0
Gain(S,A1)=0.9709506 – (4/5)*1 – (1/5)*0 = 0.1709506 [ 1 Marks ]

S1 <- [1->0, 2->1], Entropy = 0.918295


S0 <- [2->0], Entropy = 0
Gain(S,A2)=0.9709506 – (3/5)* 0.918295 – (2/5)*0 = 0.4199736 [ 1 Marks]

S1 <- [1->0, 1->1], Entropy = 1


S0 <- [2->0, 1->1], Entropy = 0.918295
Gain(S,A3) = 0.9709506 – (3/5)* 0.918295 – (2/5)*1 = 0.01993 [ 1 Marks ]

Hence A2 is chosen as root of tree because having highest information gain.


[ 1 Marks]

(b) Can you represent the following boolean function with a single logistic threshold
unit(i.e., a single unit from a neural network)? If yes, show the weights. If not,
explain why not in 1-2 sentences.

Yes we can represent given boolean fiunction using single logistic thershold
[1 Marks]
Explanation : Given Boolean function is linearly seperable with illustation
[ 1 Marks]
Drawing of neural network with following values of wrights and bias

W1= 1, W2=-1, B=-0.5 [ 3 Marks]


10. (a) A knowledge base contains the following statements.
Marcus was a man. Marcus was Pompeian. All Pompeian were Roman. Caesar
was a Ruler. All Romans were either loyal to Caesar or hated him. Everyone is
loyal to someone. Pepole only try to assassinate Rulers they are not loyal to.
Marcus tried to assassinate Caesar. Represent these statements using FOPL.

Man( Marcus)
Pompeian ( Marcus) [ 0.5 Marks]

∀x Pompeian (x)  Roman(x) [1 Marks]

Ruler ( Ceaser) [ 0.5 Marks]

∀ x Roman(x)  Loyalto( x, Ceaser) v Hated ( x, Ceaser) [1 Marks]

∀x: ∃y : Loyalto(x,y) [ 0.5 Marks]

∀x: ∀y: Person(x) ∧ Ruler(y) ∧ trytoassasinate(x,y)  ¬ Loyalto(x,y) [1 Marks]

trytoassasinate( Marcus, Ceaser) [ 0.5 Marks]

(b) What are the shortcoming of hill climbing algorithms? How does simulated
annealing improve hill climbing

The following are shortcoming of hill climbing.

1. Local Maxima: When all moves appears worse( i.e reaches at local
maxima but not global maxima )
2. Plateau : When all move appears same ( i.e. reaches in flat plane)

Above cases algorithm fails. [ 1.5x2=3 Marks ]

Simulated Annealing allows to move in case of local maxima using probability as


follows. if new state is not better than the current state , then make it the current
state with probability p’. If the random generated value between [0,1] is less than p’
then move accepted otherwise not.
[ 2 Marks]

You might also like