Report - Question 1

Report – Hw4
Question 1
Problem Description:
Develop a function, sum-list, using Genetic Programming with linear representation, according to Withall,
Hinde, & Stone .
Individuals: Integer Vector Individual. The representation of the individual an integer vector which every
4 numbers represents a gene block. Each gene is code line that the first number is the statement and the
3 numbers after are the variables or comparison signs. If a statement needs less than 3 variables then it
ignores the rest of the numbers in the block.
Picture 1: Genome mapping to 'if' example
Evaluator: List Sum Evaluator. The evaluator implements an interpreter to a sub-language. It activates
the interpreter few times with different inputs and compares the results with the true inputs. The fitness
value is the sum of ABS(Program_output – True_output).
Picture 2: List of statement used in the evaluator
Picture 3: Table of variables and comparison types used in the evaluator
Selection: We used Tournament Selection: each time 5 individuals are randomly picked, and the one
with best fitness is chosen.
Population size: 100
Crossover: Uniform Crossover.
Mutation: Integer Vector Simple Mutator. Each number in the vector has a Pm probability to change into
a different number between [0..256]
Generations: 500
Experiment A: Sum List
We tried to develop a program that will calculate the sum of a list. In each individual we added a header that
will initialize the variables and a footer that will return us the sum value.
Then we ran the Algorithm 50 times and these are the results:
Individual program (run no.0):
Assign(109) sum (45) tmp (190)
Add(65) sum (132) list[temp%size] sum (0)
Assign(55) sum (209) tmp (34)
For(70) tmp (138) lsize (1)
Add(65) sum (224) sum (140) list[temp%size]
If(69) size (189) >= (53) sum (72)
We can notice that lines 1-4, 6 are redundant as might occur in a self evolving program.
Summary of 50 runs:
o Generations needed to find optimal (100 evaluations in each generation):
 Max: 500
 Min: 3
 Avg: 127
Success rate: 100%, each run created an individual with fitness 0.
Conclusions and observations:
1. The algorithm converges very quickly to the right program.
2. If we take a look at an individual from the middle of the run we can see that it doesn’t help to have
good fitness, we must have the best fitness in order to have the program we are looking for.