Environmental Engineering Reference
In-Depth Information
The function breed.m is referenced in the main loop. It contains all the code
necessary to determine fitness—the array score holds the result of Eq. 7.2 for
every member of the population. There are a number of features of the function
that increase its execution speed. For example, Matlab allows contextual decla-
ration of arrays but intial declaration of arrays, here using the Matlab function
zeros , will result infaster program execution. Similarly it would be possible to
implement the pseudo-code for determining the new genes in a number of loops,
but Matlab's execution of loops is notoriously slow, so as many as possible of the
operations are vectorised as was the determination of the derivative for the blade
starting calculations in Chap. 6 . Consistent with this approach is the determination
of the indices for the basis vectors as a random permutation of the existing blades:
basis index ¼ randperm num indiv
ð
Þ;
which makes every member of the current generation a ''parent'' of one and only
one potential member of the next. An alternative would be to randomly
choose the indices from the current population but that would require looping.
Tests of the two alternatives did not show any significant differences in the final
results so the simpler implementation was retained.
Search WWH ::




Custom Search