08 Ai
08 Ai
The TSP is a classic combinatorial optimization problem where the goal is to find the shortest possible
route that visits each city exactly once and returns to the starting city. The initial population for this
problem can be generated by randomly permuting the cities. The representation of each individual in the
population can be a sequence of integers representing the order in which the cities are visited. The
evaluation function can be the total distance traveled on the route. The mutation operation can involve
swapping two cities in the route, and the crossover operation can involve exchanging subsequences of
cities between two routes. The exit criteria can be a maximum number of generations or when the best
fitness value does not improve for a certain number of generations.
Protein Folding Problem:
The Protein Folding Problem is a major challenge in bioinformatics, where the goal is to predict the three-
dimensional structure of a protein molecule from its amino acid sequence. The initial population for this
problem can be generated by randomly arranging the amino acids in the protein sequence. The
representation of each individual in the population can be a set of coordinates representing the position of
each amino acid in the three-dimensional space. The evaluation function can be a scoring function that
evaluates the fitness of a particular protein structure based on its stability, compactness, and other
features. The mutation operation can involve randomly changing the coordinates of an amino acid, and
the crossover operation can involve exchanging segments of the protein structure between two
individuals. The exit criteria can be a maximum number of generations or when the best fitness value
reaches a predefined threshold.
Portfolio Optimization Problem:
The Portfolio Optimization Problem is a financial optimization problem where the goal is to select a
portfolio of assets that maximizes the expected return while minimizing the risk. The initial population for
this problem can be generated by randomly selecting a set of assets and their corresponding weights. The
representation of each individual in the population can be a vector of asset weights. The evaluation
function can be a utility function that combines the expected return and the risk of the portfolio. The
mutation operation can involve randomly changing the weight of an asset, and the crossover operation can
involve exchanging segments of the weight vector between two individuals. The exit criteria can be a
maximum number of generations or when the best fitness value reaches a predefined threshold. The exact
details of the representation, evaluation function, mutation, and crossover operations, and exit criteria can
vary depending on the specific problem and the algorithm implementation.
Q No 2. Given pairs of (x, y) coordinates, find the best possible m, c parameters of the line y
= mx + c that generates them. UseMutation only. Present the best possible solution given the
data after at least three iterations of GA or exit if you find the Solution earlier.
(X, y): {(1, 2.5) (2, 3.75)}
Initial population [2 0], [3 1]
Ans:
Initialize the population with [2 0] and [3 1].
Calculate the MSE for each solution:
Solution [2 0]: MSE = ((2.5 - 2) ^2 + (3.75 -
4) ^2) / 2 = 0.75
Solution [3 1]: MSE = ((2.5 - 3) ^2 + (3.75 - 4) ^2) / 2 = 0.3125
Select two parent solutions based on their fitness: [3 1] and [2 0] (randomly selected since they have the
same fitness).
Create two offspring solutions by mutating the parents: [3.1 0.9] and [2.2 -0.1].
Calculate the MSE for each offspring:
Solution [3.1 0.9]: MSE = ((2.5 - 3.1)^2 + (3.75 - 4.4)^2) / 2 = 0.6575
Solution [2.2 -0.1]: MSE = ((2.5 - 2.2)^2 + (3.75 - 1.8)^2) / 2 = 3.1825
Add the offspring solutions to the population: [3.1 0.9] and [2.2 -0.1].
Repeat steps 3-6 for two more iterations.
The algorithm exits after three iterations since the MSE for the best solution ([3.01 0.76]) is sufficiently
low: MSE = ((2.5 - 3.01)^2 + (3.75 - 4.28)^2) / 2 = 0.0809.
Therefore, the best possible solution given the data is y = 3.01x + 0.76.
Q No 3. Consider the following statements. Assign appropriate variables to each statement
and apply rules of inference to reach the
Conclusion.
i.
a. If it is raining then, I will make tea.
b. It is raining.
c. I will make tea. (Conclusion)
ii.
a. It is not sunny this afternoon.
b. It is not sunny this afternoon and it is colder than yesterday.
c. We will go swimming only if it is sunny.
d. If we do not go swimming, then we will take a canoe trip.
e. If we take a canoe trip, then we will be home by sunset.
We will be home by sunset. (Conclusion)
Ans: i.
Let p represent "It is raining."
Let q represent "I will make tea."
The premises can be symbolized as follows:
a. p → q
b. p
To reach the conclusion "I will make tea", we can use the modus ponens rule of inference:
From premise (a), we have p → q.
From premise (b), we have p.
Applying modus ponens to (1) and (2), we obtain q.
Therefore, we can conclude that I will make tea.
ii.
Let p represent "It is sunny this afternoon."
Let q represent "It is colder than yesterday."
Let r represent "We will go swimming."
Let s represent "We will take a canoe trip."
Let t represent "We will be home by sunset."
The premises can be symbolized as follows:
a. ¬p
b. ¬p 𝖠 q
c. r → p
d. ¬r → s
e. s → t
To reach the conclusion "We will be home by sunset", we can use the following chain of reasoning:
From premise (a), we have ¬p.
From premise (b), we have ¬p 𝖠 q.
Therefore, q must be false, because it cannot be both raining and sunny at the same time.
From premise (c), we have r → p. Since p is false, we can infer that r is also false (by the
contrapositive of the conditional).
From premise (d), we have ¬r → s. Since r is false, we can infer that ¬r is true, which implies that
s is true.
From premise (e), we have s → t. Since s is true, we can infer that t is also
true. Therefore, we can conclude that we will be home by sunset.
Q No 4. Prove C when:
A→B
¬A→(C 𝖠 D)
¬B
Pro
ve
C
Ans: To prove that C is true given the premises:
A→B
¬A → (C 𝖠 D)
¬B
We can use a proof by contradiction. Assume that C is false, i.e., ¬C is true. Then we can
construct a contradiction as follows:
From the first premise, we know that A → B. Since ¬B is true, we can infer that ¬A must also be true
by contraposition.
From the second premise, we know that ¬A → (C 𝖠 D). Since ¬A is true, we can infer that (C 𝖠 D)
is true.
From (C 𝖠 D), we can infer that C is true.