0% found this document useful (0 votes)
4 views3 pages

Midterm2019 2020

Uploaded by

20208046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Midterm2019 2020

Uploaded by

20208046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Cairo University

Faculty of Computers and Artificial Intelligence


Midterm Exam

Department: Computer Science


Course Name: Soft Computing Date: 17/11/2019
Course Code: CS464 Duration: 1 hour
Instructor(s): Sabah Sayed Pages: 4
Name: ………………………… ID: ………………. Total Marks: /100

Answer all questions


Question 1: Genetic Algorithm [60 marks]
a) [10 marks] Write a basic algorithm for Genetic Algorithm.

Simple_Genetic_Algorithm()
{
Initialize the Population;
Calculate Fitness Function; // Evaluate Individuals …

While(Fitness Value != Optimal Value) // Continue Evolution …


{
Selection; //Natural Selection, Survival Of Fittest …
Crossover; //Reproduction, Propagate favorable characteristics …
Mutation; //Mutation …
Calculate Fitness Function;
}
}

b) [10 marks] State five different representation (encoding) used in a Genetic algorithm and
Discuss how the different representations affect the other operators mainly crossover and
mutation operators.

Binary (Gray) encoding, Integer encoding, character (String) encoding, floating point
encoding, Permutation encoding.
Binary (Gray), Integer, and character (String) encoding have no effect on Mutation or
Crossover but floating point encoding affects on Mutation (Uniform/Non-Uniform Mutation),
and Permutation encoding affects on Mutation(Swap Mutation) and affects on Crossover
(Order1 Crossover).

c) [10 marks] Discuss the different strategies adopted for Replacement.


Three replacement schemas:
1. Generational Replacement (GGA):
Mate enough individuals to generate pop_size offspring each individual survives for
exactly one generation. the entire set of parents is replaced by the offspring
2. Steady-state Replacement (SSGA):
Specific number (K) of individuals are selected for reproduction, and offspring replace
their parents in the next generation
3. Elitist Strategy (Elitism):
It is steady-state replacement, but keep best-so-far individuals. To keep the best solution
so far from being thrown away by crossover or mutation, the elitism option is used to
keep one or more of the best solutions discovered so far and copy them to the next
generation.

Page | 1
d) [10 marks] How to apply the Roulette Wheel Selection and Tournament Selection for:
i. The best individuals have the lowest fitness
Roulette wheel Selection: uses the 1 - fitness or 1/fitness portion in selection
Tournament Selection: selects the individual with minimum fitness

ii. The best individuals have the highest fitness


Roulette wheel Selection: uses the fitness portion in selection
Tournament Selection: selects the individual with maximum fitness

e) [10 marks] The following chromosome has eight genes with values in range [-5,5], Show the
chromosome after performing a uniform mutation on the fourth gene, knowing that the
random numbers generated for the operation: r1 = 0.3, r2 = 1.7.

2.3 -1.1 4 2.5 -2 3.1 1.4 4.9

r1 = 0.3, which is <0.5


Then △ = △L
-5 5
△L = 2.5 – (-5) = 7.5 2.5
r2 = 1.7
so g4 = g4 – 1.7
= 2.5 – 1.7= 0.8

∆L ∆U
2.3 -1.1 4 0.8 -2 3.1 1.4 4.9

f) [10 marks] In the Island GA, One extra operator is added


i. What is this operator? Mention the four properties should be specified in its policy?
Migration
Migration policies specify:
1- A communications topology, which determines the migration paths between islands
2- A migration rate, which determines the frequency of migration
3- A selection mechanism, to decide which individuals will migrate
4- A replacement strategy, to decide which individual of the destination island will be
replaced

ii. Compare between the two classes of Island GA.


Based on the selection and replacement strategies, Island GAs can be grouped into two classes
of algorithms:
– Static island GAs
A topology is used to determine migration paths so the selection and replacement
strategies are Deterministic
• A good migrant replaces a bad individual
• A good migrant replaces a randomly selected individual
• A randomly selected migrant replaces a bad individual
• A randomly selected migrant replaces a randomly selected individual
– Dynamic island GAs
Migration decisions are made probabilistically
• Migration occurs at a probability
• Destination island is probabilistically selected
• Destination islands may use an acceptance strategy
– An immigrant is probabilistically accepted if its fitness is better than the
average fitness of the island

Page | 2
Question 2: Genetic Programming [20 marks]
A program uses genetic programming for solving a problem where an example individual of the
population is: (x  true)  ((x  false)  (¬z → (x  y)))
a) [5 marks] Represent the individual as a parse tree.

 

x true  →

x false ¬ 

z x y

b) [5 marks] State the function and terminal sets presented in this individual.

Function set = {, , ¬, →, }


Terminal set = {x, y, z, true, false}

c) [5 marks] Mention two differences between Genetic Programming and Genetic Algorithm
chromosomes.

1. In GA, chromosomes are linear structures (bit strings, integer string, permutations)
But GP uses tree shaped chromosomes which are non-linear structures.
2. In GA, the size of the chromosomes is fixed but Trees in GP may vary in depth and
width.

d) [5 marks] Is genetic programming better than random generation of programs? Why?


Yes,
The key lies in that GP uses a fitness measure to determine which functions survive to
reproduce in each generation

Question 3: Fuzzy Logic [20 marks]


Consider a problem with two input variables, size and weight, and one output variable, quality, with
the following fuzzy sets:
size: small S {0, 0, 10}, large L {0, 10, 10} in range [0 .. 10]
weight: small S {0, 0, 100}, large L {0, 100, 100} in range [0 .. 100]
quality: bad B {0, 0, 0.5}, medium M {0, 0.5, 1}, good G {0.5, 1, 1} in range [0 .. 1]

The rule base:


R1: if size is S and weight is S then quality is B
R2: if size is S and weight is L then quality is M
R3: if size is L and weight is S then quality is M
R4: if size is L and weight is L then quality is G

Find the crisp value of quality given size= 2 and weight =25

Page | 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy