0% found this document useful (0 votes)
42 views2 pages

COMP3600 Intelligent Systems HW3

This document describes a homework assignment to implement a genetic algorithm to solve the mathematical equality problem of a + 2b + 3c + 4d = 30. Students are asked to write a Python program that initializes a population of 10 random chromosomes representing values for variables a, b, c, and d. The program should include functions to calculate fitness by minimizing (a + 2b + 3c + 4d - 30), perform single-point crossover and mutation on chromosomes, run the genetic algorithm for 5 iterations while tracking the best solution and new populations, and plot chromosomes versus their fitness.

Uploaded by

Peter
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)
42 views2 pages

COMP3600 Intelligent Systems HW3

This document describes a homework assignment to implement a genetic algorithm to solve the mathematical equality problem of a + 2b + 3c + 4d = 30. Students are asked to write a Python program that initializes a population of 10 random chromosomes representing values for variables a, b, c, and d. The program should include functions to calculate fitness by minimizing (a + 2b + 3c + 4d - 30), perform single-point crossover and mutation on chromosomes, run the genetic algorithm for 5 iterations while tracking the best solution and new populations, and plot chromosomes versus their fitness.

Uploaded by

Peter
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/ 2

Sultan Qaboos University

College of Science - Department of Computer


Science COMP3600: Intelligent Systems- Fall- 2022

Home Work Assignment 3


Due date: Sunday 20/11/2022, 23:55 pm (through Moodle)

Genetic Algorithm for Solving Simple Mathematical Equality Problem:

Suppose there is equality a + 2b + 3c + 4d = 30, genetic algorithm can be used to find the value
of a, b, c, and d that satisfy this equation. 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, chromosomes can be composed as

Chromosome[1] = [a;b;c;d] = [02; 21; 18; 03]


Chromosome[2] = [a;b;c;d] = [20; 05; 17; 01]

To speed up the computation, the integer values of variables a, b, c, and d are restricted between
0 and 30. The selection process should be achieved by using the cumulative probability, random
number (r) and roulette wheel. To perform cross, use one point crossover as below

= Chromosome[1] >< Chromosome[2]


= [02; 21; 18; 03] >< [20; 05; 17; 01]
Offsprings = [02; 05; 17; 01] and [20; 21; 18; 03]

Mutation process is done by replacing a gene value at any random position in a chromosome
with a new value as

[02; 05; 17; 01] -> [27; 05; 17; 01]

Implement the algorithm in Python programming language with the following setting:

 [1 Point] Add comments in the program.


 [2 Points] Use an appropriate data structure for chromosomes.
 [2 Point] Randomly initialize ten chromosomes, and set crossover and mutation
probabilities 0.6 and 0.2, respectively.
 [5 Points] A function to compute fitness.
 [5 Points] A function to perform crossover and mutation.
 [5 Points] Perform at-least five iterations, and show new population of each iteration and
the best solution (chromosome) with its fitness (improved).
 [5 Points] Plot chromosomes versus their corresponding fitness, which have been
generated in all iterations.

You might also like