- NAME
- SYNOPSIS
- DESCRIPTION
- METHODS
- entropy( $population)
- genotypic_entropy( $population)
- hamming( $string_a, $string_b )
- consensus( $population, $rough = 0 )
- average( $population )
- random_bitstring( $bits )
- random_number_array( $dimensions [, $min = -1] [, $range = 2] )
- parse_xml( $string )
- decode_string( $chromosome, $gene_size, $min, $range )
- vector_compare( $vector_1, $vector_2 )

- Copyright

# NAME

Algorithm::Evolutionary::Utils - Container module with a hodgepodge of functions

# SYNOPSIS

```
use Algorithm::Evolutionary::Utils qw(entropy);
my $this_entropy = entropy( $population );
#Computes consensus sequence (for binary chromosomes
my $this_consensus = consensus( $population);
```

# DESCRIPTION

Miscellaneous class that contains functions that might be useful somewhere else, especially when computing EA statistics.

# METHODS

## entropy( $population)

Computes the entropy using the well known Shannon's formula: http://en.wikipedia.org/wiki/Information_entropy 'to avoid botching highlighting

## genotypic_entropy( $population)

Computes the entropy using the well known Shannon's formula: http://en.wikipedia.org/wiki/Information_entropy 'to avoid botching highlighting; in this case we use chromosome frequencies instead of fitness.

## hamming( $string_a, $string_b )

Computes the number of positions that are different among two strings

## consensus( $population, $rough = 0 )

Consensus sequence representing the majoritary value for each bit; returns the consensus string. If "rough", then the bit is set only if the difference is bigger than 0.4 (70/30 proportion)

## average( $population )

Computes an average of population fitness

## random_bitstring( $bits )

Returns a random bitstring with the stated number of bits. Useful for testing,mainly

## random_number_array( $dimensions [, $min = -1] [, $range = 2] )

Returns a random bitstring with the stated number of bits. Useful for testing,mainly

## parse_xml( $string )

Parses the string and returns an XML tree

## decode_string( $chromosome, $gene_size, $min, $range )

Decodes to a vector, each one of whose components ranges between $min and $max. Returns that vector.

It does not work for $gene_size too big. Certainly not for 64, maybe for 32

## vector_compare( $vector_1, $vector_2 )

Compares vectors, returns 1 if 1 dominates 2, -1 if it's the other way round, and 0 if neither dominates the other. Both vectors are supposed to be numeric. Returns `undef`

if neither is bigger, and they are not equal.

# Copyright

```
This file is released under the GPL. See the LICENSE file included in this distribution,
or go to http://www.fsf.org/licenses/gpl.txt
CVS Info: $Date: 2010/09/24 08:39:07 $
$Header: /media/Backup/Repos/opeal/opeal/Algorithm-Evolutionary/lib/Algorithm/Evolutionary/Utils.pm,v 3.3 2010/09/24 08:39:07 jmerelo Exp $
$Author: jmerelo $
$Revision: 3.3 $
```