This preview shows pages 1–3. Sign up to view the full content.
HW3 solutions Fall 2010
1
Points possible
: 20
1.
Maximize the following function:
F(s1,s2) = 10^9(625(s125)^2) *(1600(s210)^2)*sin((s1)*pi/10)*sin((s2)*pi/10)
The global
maximum
is F(125,115) = 1088359375.
a.
(6 points, 1 for each algorithm)
Write a MATLAB function to implement a Genetic Algorithm
GA.m.
Mark for completion – students should have a GA code that is similar to what is shown in the
pseudocode. Cost for the initial population should be calculated and stored. Some other comments about
other functions:
fitness.m 
to calculate the fitness of individual solutions (this is very simple code that calls your
cost function and, if necessary, converts problem to minimization)
selection_R
.
m 
which
takes
a
population
and
generates
parents
from
it
using
fitness
proportional selection – Note that the selection procedure described in lecture is equivalent to
using a weighted roulette wheel with slots proportional to the fitness of each member;
Check that both parents should be selected according to their proportional fitness. Parent1 should not be
the same as parent 2
(Deduct ½ points)
. Otherwise, the two children generated will be the same,
effectively carrying over 2 of the same individual to the next population. You want to search over a
wider range, so that you are more likely to find the best solution faster.
crossover
.
m 
which performs singlepoint crossover at a randomly
generated point along the
string (14 bit here) and generates
two
children or offspring per pair of parents; and
According to these instructions, the crossover should be implemented as choosing one point along the
entire 14bit string and implementing crossover for the entire sting, not taking into account the two
different numbers (Method 1). However, some students will restrict the crossover point to be between
the 1st and 7th binary digits, then perform multivariate crossover as covered in class (Method 2). Both
methods are OK.
mutation.m 
which mutates
each bit
(bitwise mutation) in the string with a probability of
pMutation
.
Make sure that each bit is mutated with probability pMutation. If not, deduct
½ points
.
Also code your GA.m function to use
Elitism
.
Elitism is when the
m
highest fitness individuals
(
m
<popsize) from the previous generation are always carried forward, undisturbed into the next
generation.
Here, use
m
=1 (only best individual is carried forward).
Code this as you see fit in the
GA.m file.
There are many ways to implement elitism. Students can randomly select a child from the next
generation population and replace it with the elite parent. Students can also select the worst child from
the next generation population and replace it with the elite parent. Both are OK.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentHW3 solutions Fall 2010
2
b.
(1 point)
Run GA 30 times on the fitness function described above with a population size of 20, for
50 generations, using a pCrossover=0.9 and pMutation=1/20=0.05 (you will experiment with GA
parameters in a later homework).
This is probably easiest if you
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '11
 Shoemaker

Click to edit the document details