Algorithm-Evolutionary-Utils

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


2010-11-24  Juan Julian Merelo Guervos  <jmerelo@usuario-desktop>

	* lib/Algorithm/Evolutionary/Wheel.pm (spin): Changed spin
	implementation to make it faster and more efficient. It was
	sucking time out of mastermind EAs

2010-09-25  Juan J. Merelo  <jmerelo@sheldon>

	* lib/Algorithm/Evolutionary/Fitness/Rastrigin.pm (Rastrigin):
	Fixed formula

	* lib/Algorithm/Evolutionary.pm: Starting 0.74_1 with cosmetic
	changes and an attempt to fix sporadic test errors.  

2010-09-24  Juan Julian Merelo Guervos  <jmerelo@usuario-desktop>

	* lib/Algorithm/Evolutionary/Fitness/Rastrigin.pm (Rastrigin): Added first floating-point fitness func.

	* lib/Algorithm/Evolutionary/Utils.pm (random_number_array): Added this function

lib/Algorithm/Evolutionary/Utils.pm  view on Meta::CPAN

		     random_bitstring random_number_array average 
		     parse_xml decode_string vector_compare);

use Carp;
use String::Random;
use XML::Parser;
use Statistics::Basic qw(mean);

=head2 entropy( $population)

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

=cut

sub entropy {
  my $population = shift;
  my %frequencies;
  map( (defined $_->{'_fitness'})?$frequencies{$_->{'_fitness'}}++:1, @$population );
  my $entropy = 0;
  my $gente = scalar(@$population); # Population size
  for my $f ( keys %frequencies ) {
    my $this_freq = $frequencies{$f}/$gente;
    $entropy -= $this_freq*log( $this_freq );
  }
  return $entropy;
}

=head2 genotypic_entropy( $population)

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

=cut

sub genotypic_entropy {
  my $population = shift;
  my %frequencies;
  map( $frequencies{$_->{'_str'}}++, @$population );



( run in 0.281 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )