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

School of Computer Engineering

Kalinga Institute of Industrial Technology (KIIT)

Deemed to be University

Bhubaneswar-751024

Answer Schema for Artificial Intelligence (CS-3011) (6th sem)


1.(a) Differentiate between Artificial Intelligence, Machine Learning and Deep Learning.
Artificial Intelligence: It refers to the procedure of programming a computer (machine) to take rational
decision.to make the machine behave in an excellent fashion in lieu of human guidance.
Machine Learning: Data and output is run on the computer to create a program. This program
can be used in traditional programming.ML is a subset of AI.
Deep Learning: associated with a ML algorithm (ANN) which uses the concept of human brain to facilitate
the modeling of arbitrary functions. ANN requires a vast amount of data and this algorithm is highly flexible
when it comes to model multiple outputs simultaneously.

(b) What are the four approaches to define AI?


(Partial Marks can be given)
1.Systems that act like humans
2.Systems that think like humans
3.Systems that think rationally
4.Systems that act rationally

(c) Is the “Scheduling of World Cup Cricket Matches” a search problem or constraint satisfaction
problem? Justify your answer.
(Partial Marks can be given)
“Scheduling of World Cup Cricket Matches” is a CSP problem.
Variable: {Set of Teams}
Domain: {Set of stadiums}
Constrains: {Same Teams cannot have matches at two stadiums at same time.}

(d) Describe the different variants of the hill-climbing algorithm.


(Partial Marks can be given)
Simple hill Climbing: Simple hill climbing is the simplest way to implement a hill climbing
algorithm. It only evaluates the neighbor node state at a time and selects the first one which
optimizes current cost and set it as a current state. It only checks it's one successor state, and if it
finds better than the current state, then move else be in the same state.
Steepest-Ascent hill-climbing: Steepest-ascent hill climbing is different from simple hill
climbing search. Unlike simple hill climbing search, It considers all the successive nodes,
compares them, and choose the node which is closest to the solution.
Stochastic hill Climbing: Stochastic hill climbing does not focus on all the nodes. It selects one
node at random and decides whether it should be expanded or search for a better one.

(e) Define the following terms in Genetic algorithms: (i)Chromosome; (ii) Gene; (iii) Population;
and (iv) Binary Chromosome
(Partial Marks can be given.)
Population − It is a subset of all the possible (encoded) solutions to the given problem. The
population for a GA is analogous to the population for human beings except that instead of human
beings, we have Candidate Solutions representing human beings.
Chromosomes − A chromosome is one such solution to the given problem.
Gene − A gene is one element position of a chromosome.
Allele − It is the value a gene takes for a particular chromosome.
Binary Chromosome: If a chromosome re encoded by binary strings of 0's and 1's referred to as a
Binary chromosome.
(f) Differentiate between forward and backward chaining.
(Any Two valid point can be given Full Marks)

S. Forward Chaining Backward Chaining


No.

1. Forward chaining starts from known facts Backward chaining starts from the goal and works
and applies inference rule to extract more backward through inference rules to find the
data unit it reaches to the goal. required facts that support the goal.

2. It is a bottom-up approach It is a top-down approach

3. Forward chaining is known as data-driven Backward chaining is known as goal-driven


inference technique as we reach to the goal technique as we start from the goal and divide into
using the available data. sub-goal to extract the facts.

4. Forward chaining reasoning applies a Backward chaining reasoning applies a depth-first


breadth-first search strategy. search strategy.

5. Forward chaining tests for all the available Backward chaining only tests for few required
rules rules.

6. Forward chaining is suitable for the planning, Backward chaining is suitable for diagnostic,
monitoring, control, and interpretation prescription, and debugging application.
application.
7. Forward chaining can generate an infinite Backward chaining generates a finite number of
number of possible conclusions. possible conclusions.

8. It operates in the forward direction. It operates in the backward direction.

9. Forward chaining is aimed for any Backward chaining is only aimed for the required
conclusion. data.

(g) Explain the “time complexity” and “space complexity” of Bidirectional Breadth-First Search
algorithm.
(If any one complexity is explained properly can be given as 1 mark. Correct answer without
explanation is eligible for .5 mark)
Assuming that the comparisons for identifying a common state between the two frontiers can be done in
constant time per node, by hashing for example, the time complexity of bidirectional search is O(bd/2) since
each search need only proceed to half the solution depth. Since at least one of the searches must be breadth
first in order to find a common state, the space complexity of bidirectional search is also O(bd/2). As a result,
bidirectional search is space bound in practice.

(h) Explain what a “plateau” is and how it can be a challenge for optimization algorithms.
(Partial Marks can be given)
A plateau is the flat area of the search space in which all the neighbor states of the current state contain the
same value, because of this algorithm does not find any best direction to move. A hill-climbing search
might be lost in the plateau area.

(i) Differentiate between propositional logic and predicate logic.


(Any Two valid point can be given Full Marks)

Propositional Logic Predicate Logic

Predicate logic is an expression consisting of


Propositional logic is the logic that deals
variables with a specified domain. It consists of
1 with a collection of declarative statements
objects, relations and functions between the
which have a truth value, true or false.
objects.
It is the basic and most widely used logic. It is an extension of propositional logic covering
2
Also known as Boolean logic. predicates and quantification.

A proposition has a specific truth value, A predicate’s truth value depends on the
3
either true or false. variables’ value.

Predicate logic helps analyze the scope of the


subject over the predicate. There are three
Scope analysis is not done in propositional quantifiers : Universal Quantifier (∀) depicts for
4
logic. all, Existential Quantifier (∃) depicting there
exists some and Uniqueness Quantifier (∃!)
depicting exactly one.

Propositions are combined with Logical


Operators or Logical Connectives like
Negation(¬), Disjunction(∨), Predicate Logic adds by introducing quantifiers
5
Conjunction(∧), Exclusive OR(⊕), to the existing proposition.
Implication(⇒), Bi-Conditional or Double
Implication(⇔).

6 It is a more generalized representation. It is a more specialized representation.

It can deal with set of entities with the help of


7 It cannot deal with sets of entities.
quantifiers.

(j) What are the different types of planning?


(Only Names can be considered as Full marks)
1. Forward State Space Planning (FSSP)
FSSP behaves in the same way as forwarding state-space search. It says that given an initial state
S in any domain, we perform some necessary actions and obtain a new state S' (which also contains
some new terms), called a progression. It continues until we reach the target position. Action
should be taken in this matter.
Disadvantage: Large branching factor
Advantage: The algorithm is Sound
2. Backward State Space Planning (BSSP)
BSSP behaves similarly to backward state-space search. In this, we move from the target state g
to the sub-goal g, tracing the previous action to achieve that goal. This process is called regression
(going back to the previous goal or sub-goal). These sub-goals should also be checked for
consistency. The action should be relevant in this case.
Disadvantages: not sound algorithm (sometimes inconsistency can be found)
Advantage: Small branching factor (much smaller than FSSP)
Section-B

2.(a) What are the basic building blocks of a Learning Agent? Explain each of them with a neat
block diagram.
(Diagram 2 marks. Component name:1 mark. Explanation 2 marks.)

Learning Agents: A learning agent in AI is the type of agent which can learn from its past
experiences, or it has learning capabilities.It starts to act with basic knowledge and then able to act
and adapt automatically through learning.

A learning agent has mainly four conceptual components, which are:


Learning element: It is responsible for making improvements by learning from environment
Critic: Learning element takes feedback from critic which describes that how well the agent is
doing with respect to a fixed performance standard.
Performance element: It is responsible for selecting external action
Problem generator: This component is responsible for suggesting actions that will lead to new
and informative experiences.
Hence, learning agents are able to learn, analyze performance, and look for new ways to improve
the performance.

(b) For the example below, trace the path and explain the solution step by step for the Greedy Best
Search and A* algorithms.
(Greedy Best Search: 2marks, A*: 3 Marks. If steps are not shown then 1 marks (.5+.5) can be
given)
As heuristic value of ‘Z’ is not given so ‘Z’ is goal node.
For Start node ‘a’ is considered. Other nodes expect ‘Z’ can be taken. But from that node all the
steps must be shown)
Greedy Best Search:
Open: {a (f=11)}
Close: { }
Open: { b(f=8),c(f=8)} // c can also be taken
Close: {a}

Open: {c (f=8), d(f=4)}


Close: {a,b} Path: a→b

Open: { c (f=8), e (f=2), z (f=0)}


Close: {a,b,d} Path a→b→d

Open: { c (f=8), e (f=2)}


Close: {a,b,d,z} // as ‘z’ the goal is in Close so we stop algorithm.

So the final path: a→b→d→z. Cost is (5+5+6=16).

A* :
Open: {a (f=(0)+11=11)}
Close: { }

Open: {b(f=(5)+8=13), c(f=(4)+8=12)}


Close: {a}

Open: {b(f=(5)+8=13), d(f=(4+8)+4=16), e (f=(4+10)+2=16)}


Close: {a, c} Path: a→c
Open: {d(f=(5+5)+4=14), e (f=(4+10)+2=16)}
Close: {a, c, b} Path: a→b

Open: {e (f=(5+5+2)+2=14), zd (f=(5+5+6)+0=16) (through ‘d’)}


Close: {a, c, b, d} Path: a→b→d
Open: {zd (f=(5+5+6)+0=16), ze (f=(5+5+2+5)+0=17 (through ‘e’)}
Close: {a, c, b, d,e} Path: a→b→d→e

Open: {ze (f= (5+5+2+5) +0=17 (through ‘e’)}


Close: {a, c, b, d, e, z} Path: a→b→d→z // as ‘z’ the goal is in Close so we stop algorithm.

So the final path: a→b→d→z. Cost is (5+5+6=16).

3 (a) What is a task environment? How is it represented? For each of the following agents, provide
a PEAS description of the task environment:
(i) Autonomous drone for wild-fire monitoring
(ii) Autonomous robot army at the border

What is a task environment? How is it represented? : 1


Autonomous drone for wild-fire monitoring: 2
Performance: Detecting Fire, Detecting exact coordinate, Houting alarm.
Environment: Forest, Tree, Fire.
Actuator: Alarm, Transmitter, GPS System.
Sensor: Camera, Fire Sensor, heat detector.
Autonomous robot army at the border: 2
Performance: Detecting enemy force, proper monitoring at border, houting alarm at detection of
enemy.
Environment: Border line, Human, Animal.
Actuator: Alarm, Transmitter, GPS System.
Sensor: Camera, Robot Arm, Robot Leg.

(b) Nim is a classic two-player zero-sum game in artificial intelligence. The rules of Nim are
relatively simple:
(i) The game is typically played with several piles of objects, such as coins or sticks (let us
consider stones).
(ii) Players take turns removing one or more objects (assume a maximum of half of the
number of stones from the pile at a given point in time) from a single pile.
(iii) Usually, there is a predetermined maximum value that restricts the number of objects a
player can remove.
(iv) The player who removes the last object from the last remaining pile wins the game.
Illustrate the complete game tree for Nim with MAX playing first and piles of seven (7) stones.
Also, determine the winning player (MAX or MIN) based on the obtained game tree, where the
pay-offs are +1 and -1 if the last stone is removed by the MAX and MIN players, respectively.
(Drawing Tree :4 marks. determine the winning player:1 mark)

4.(a)

Given a floor plan represented as a graph, where rooms are vertices and doors connecting rooms
are edges, find a proper coloring of the rooms with the fewest possible colors such that no two
adjacent rooms (connected by a door) share the same color. [3 marks]

How many solutions are there with red, green, and blue colors? Justify your answer. [2marks]
How many solutions are there with red, green, and blue colors? Justify your answer. [2marks]
Suppose we have given ‘A’ as red.
Then B can be Green or Blue.
• If B is Green then C can be Red or Blue. Total possibility: 2
• If B is Blue then C can be Red or Green. Total possibility: 2
Then D can be Green or Blue. (Independent of ‘B’ and ‘C’). Total possibility: 2.
So total number of possible solution when ‘A’ is red are: 2×2×2=8.
Possible solutions for A=Red
# solution A B C D
1 Red Green Red Green
2 Red Green Blue Green
3 Red Blue Red Green
4 Red Blue Green Green
5 Red Green Red Blue
6 Red Green Blue Blue
7 Red Blue Red Blue
8 Red Blue Green Blue

Similarly, total number of possible solution when ‘A’ is Green are: 2×2×2=8.
total number of possible solution when ‘A’ is Blue are: 2×2×2=8.
---------------------------------------------------------------------------------------------------------------------
Total possible solution is 8+8+8=24.
(b) Illustrate the fitness evaluation, selection, crossover and mutation operations in a Genetic
Algorithm (GA) with suitable examples and diagrams?

fitness evaluation: 1 Mark


selection; 1.5 Mark
crossover: 1.5 Mark
mutation :1 Mark

(Any example can be taken. But all the assumption, fitness function, crossover mechanize
and mutation process must be properly defined. Minimum four population should be used.
Here we have given one of the answer)
Suppose there is equality a + 2b + 3c + 4d = 30, genetic algorithm will be used to find the value
of a, b, c, and d that satisfy the above equation.
fitness evaluation:
First we should formulate the objective function, for this problem the objective is minimizing the
value of function f(x) where f(x) = ((a + 2b + 3c + 4d) - 30). Since there are four variables in the
equation, namely a, b, c, and d, we can compose the chromosome as follow: To speed up the
computation, we can restrict that the values of variables a, b, c, and d are integers between 0 and
30.

Step 1. Initialization
For example we define the number of chromosomes in population are 6, then we generate random
value of gene a, b, c, d for 6 chromosomes
Chromosome[1] = [a;b;c;d] = [12;05;23;08]
Chromosome[2] = [a;b;c;d] = [02;21;18;03]
Chromosome[3] = [a;b;c;d] = [10;04;13;14]
Chromosome[4] = [a;b;c;d] = [20;01;10;06]
Chromosome[5] = [a;b;c;d] = [01;04;13;19]
Chromosome[6] = [a;b;c;d] = [20;05;17;01]

abcd
Step 2. Evaluation
We compute the objective function value for each chromosome produced in initialization step:
F_obj[1] = Abs(( 12 + 2*05 + 3*23 + 4*08 ) - 30)
= Abs((12 + 10 + 69 + 32 ) - 30)
= Abs(123 - 30)
= 93
F_obj[2] = Abs((02 + 2*21 + 3*18 + 4*03) - 30)
= Abs((02 + 42 + 54 + 12) - 30)
= Abs(110 - 30)
= 80
F_obj[3] = Abs((10 + 2*04 + 3*13 + 4*14) - 30)
= Abs((10 + 08 + 39 + 56) - 30)
= Abs(113 - 30)
= 83
F_obj[4] = Abs((20 + 2*01 + 3*10 + 4*06) - 30)
= Abs((20 + 02 + 30 + 24) - 30)
= Abs(76 - 30)
= 46
F_obj[5] = Abs((01 + 2*04 + 3*13 + 4*19) - 30)
= Abs((01 + 08 + 39 + 76) - 30)
= Abs(124 - 30)
= 94
F_obj[6] = Abs((20 + 2*05 + 3*17 + 4*01) - 30)
= Abs((20 + 10 + 51 + 04) - 30)
= Abs(85 - 30)
= 55
Step 3. Selection
1. The fittest chromosomes have higher probability to be selected for the next generation. To
compute fitness probability we must compute the fitness of each chromosome. To avoid divide by
zero problem, the value of F_obj is added by 1.

Fitness[1] = 1 / (1+F_obj[1])
= 1 / 94
= 0.0106
Fitness[2] = 1 / (1+F_obj[2])
= 1 / 81
= 0.0123
Fitness[3] = 1 / (1+F_obj[3])
= 1 / 84
= 0.0119
Fitness[4] = 1 / (1+F_obj[4])
= 1 / 47
= 0.0213
Fitness[5] = 1 / (1+F_obj[5])
= 1 / 95
= 0.0105
Fitness[6] = 1 / (1+F_obj[6])
= 1 / 56
= 0.0179
Total = 0.0106 + 0.0123 + 0.0119 + 0.0213 + 0.0105 + 0.0179
= 0.0845

The probability for each chromosomes is formulated by: P[i] = Fitness[i] / Total
P[1] = 0.0106 / 0.0845
= 0.1254
P[2] = 0.0123 / 0.0845
= 0.1456
P[3] = 0.0119 / 0.0845
= 0.1408
P[4] = 0.0213 / 0.0845
= 0.2521
P[5] = 0.0105 / 0.0845
= 0.1243
P[6] = 0.0179 / 0.0845
= 0.2118

From the probabilities above we can see that Chromosome 4 that has the highest fitness, this
chromosome has highest probability to be selected for next generation chromosomes. For the
selection process we use roulette wheel, for that we should compute the cumulative probability
values:

C[1] = 0.1254
C[2] = 0.1254 + 0.1456
= 0.2710
C[3] = 0.1254 + 0.1456 + 0.1408
= 0.4118
C[4] = 0.1254 + 0.1456 + 0.1408 + 0.2521
= 0.6639
C[5] = 0.1254 + 0.1456 + 0.1408 + 0.2521 + 0.1243
= 0.7882
C[6] = 0.1254

Having calculated the cumulative probability of selection process using roulette-wheel can be done.
The process is to generate random number R in the range 0-1 as follows.
R[1] = 0.201
R[2] = 0.284
R[3] = 0.099
R[4] = 0.822
R[5] = 0.398
R[6] = 0.501

If random number R[1] is greater than C[1] and smaller than C[2] then select Chromosome[2] as a
chromosome in the new population for next generation:
NewChromosome[1] = Chromosome[2]
NewChromosome[2] = Chromosome[3]
NewChromosome[3] = Chromosome[1]
NewChromosome[4] = Chromosome[6]
NewChromosome[5] = Chromosome[3]
NewChromosome[6] = Chromosome[4]
Chromosomes in the population thus became:
Chromosome[1] = [02;21;18;03]
Chromosome[2] = [10;04;13;14]
Chromosome[3] = [12;05;23;08]
Chromosome[4] = [20;05;17;01]
Chromosome[5] = [10;04;13;14]
Chromosome[6] = [20;01;10;06]

In this example, we use one-cut point, i.e. randomly select a position in the parent chromosome then
exchanging sub-chromosome. Parent chromosome which will mate is randomly selected and the
number of mate Chromosomes is controlled using crossover_rate (ρc) parameters.

Chromosome k will be selected as a parent if R[k]<ρc. Suppose we set that the crossover rate is
25%, then Chromosome number k will be selected for crossover if random generated value for
Chromosome k below 0.25. The process is as follows: First we generate a random number R as the
number of population.
R[1] = 0.191
R[2] = 0.259
R[3] = 0.760
R[4] = 0.006
R[5] = 0.159
R[6] = 0.340
For random number R above, parents are Chromosome[1], Chromosome[4] and Chromosome[5]
will be selected for crossover.
Chromosome[1] >< Chromosome[4]
Chromosome[4] >< Chromosome[5]
Chromosome[5] >< Chromosome[1]
After chromosome selection, the next process is determining the position of the crossover point. This
is done by generating random numbers between 1 to (length of Chromosome – 1). In this case,
generated random numbers should be between 1 and 3. After we get the crossover point, parents
Chromosome will be cut at crossover point and its gens will be interchanged. For example we
generated 3 random number and we get:
C[1] = 1
C[2] = 1
C[3] = 2
Then for first crossover, second crossover and third crossover, parent’s gens will be cut at gen
number 1, gen number 1 and gen number 3 respectively, e.g.
Chromosome[1] = Chromosome[1] >< Chromosome[4]
= [02;21;18;03] >< [20;05;17;01]
= [02;05;17;01]
Chromosome[4] = Chromosome[4] >< Chromosome[5]
=20;05;17;01] >< [10;04;13;14]
=[20;04;13;14]

Chromosome[5] = Chromosome[5] >< Chromosome[1]


= [10;04;13;14] >< [02;21;18;03]
= [10;04;18;03]

Thus Chromosome population after experiencing a crossover process:


Chromosome[1] = [02;05;17;01]
Chromosome[2] = [10;04;13;14]
Chromosome[3] = [12;05;23;08]
Chromosome[4] = [20;04;13;14]
Chromosome[5] = [10;04;18;03]
Chromosome[6] = [20;01;10;06]

Step 5. Mutation
Number of chromosomes that have mutations in a population is determined by the mutation_rate
parameter. Mutation process is done by replacing the gen at random position with a new value. The
process is as follows. First we must calculate the total length of gen in the population. In this case the
total length of gen is total_gen = number_of_gen_in_Chromosome * number of population
=4*6
= 24

Mutation process is done by generating a random integer between 1 and total_gen (1 to 24). If
generated random number is smaller than mutation_rate(ρm) variable then marked the position of
gen in chromosomes. Suppose we define ρm 10%, it is expected that 10% (0.1) of total_gen in the
population that will be mutated:
number of mutations = 0.1 * 24
= 2.4
≈2
Suppose generation of random number yield 12 and 18 then the chromosome which have mutation
are Chromosome number 3 gen number 4 and Chromosome 5 gen number 2. The value of mutated
gens at mutation point is replaced by random number between 0-30. Suppose generated random
number are 2 and 5 then Chromosome composition after mutation are:
Chromosome[1] = [02;05;17;01]
Chromosome[2] = [10;04;13;14]
Chromosome[3] = [12;05;23;02]
Chromosome[4] = [20;04;13;14]
Chromosome[5] = [10;05;18;03]
Chromosome[6] = [20;01;10;06]

Finishing mutation process then we have one iteration or one generation of the genetic algorithm.

5.(a) Develop the constraint satisfaction problem and solve the following crypt-arithmetic
problems:
CROSS + ROADS = DANGER [3.5 marks] // detailed steps must be given.
96233 + 62513 = 158746 ('e': 4, 's': 3, 'n': 8, 'd': 1, 'g': 7, 'a': 5, 'o': 2, 'c': 9, 'r': 6)
GREAT + INDIA = BHARAT [1.5 marks]

C1 C2 C3 C4 C5
G R E A T

+ I N D I A

B H A R A T

In this problem
T+A=T// No Change of Carry.
So, A=0.
Maximum value possible for T is 9,
So, C5=0
Now again, A+I=A
So I=0.
Which is not possible,
So No solution is there.
(b) All the assumption, crossover mechanize and mutation process must be properly
defined. Minimum four population should be used. Here we have given one of the answers.
1st iteration 3.5, 2nd iteration 4.5, 3rd iteration 5)
6.(a)
(b) Formulate the First Order Logic (FOL) statement for the following statements :
(i) No child likes broccoli. [1 mark]
(ii) If a triangle is equilateral, then all its sides are equal. [1.5 marks]
(iii) Elodie does not like dragons and caves except Rhaegal the dragon. Rhaegal bums all humans
if Elodie commands Rhaegal. [1.5 marks]
(iv) There is a course that every student is enrolled in. [1marks]

You might also like