Algorithm-Evolve
view release on metacpan or search on metacpan
lib/Algorithm/Evolve/Util.pm view on Meta::CPAN
Returns the number of positions in which the two genes agree. Does not enforce
that they have the same size, even though the result is somewhat meaningless
in that case.
String gene comparison is done in a non-unicode-friendly way. To override this
and use a (slower) unicode-friendly string comparison, set
C<$Algorithm::Evolve::Util::UNICODE_STRINGS> to a true value.
In array genes, the comparison of individual elements is done with C<eq>.
Note that this is the Hamming metric, and not the edit distance metric. Edit
distance may be an interesting fitness to use as well. There are at least two
modules (L<Text::Levenshtein|Text::Levenshtein> and
L<Text::LevenshteinXS|Text::LevenshteinXS>) that I know of which calculate the
edit distance of two strings.
=item C<str_mutate( $string1 [, $num [, \@alphabet ]] )>
=item C<arr_mutate( \@array1 [, $num [, \@alphabet ]] )>
Returns a random mutation of the gene according to the given alphabet
(defaulting to {0,1}). If C<$num> is less than 1, it performs I<probabilistic
mutation>, with each position having a C<$num> probability of being mutated. If
C<$num> is greater than or equal to 1, it performs I<N-point mutation>: exactly
C<$num> positions are chosen at random and mutated. C<$num> defaults to 1. A
( run in 0.588 second using v1.01-cache-2.11-cpan-de7293f3b23 )