Algorithm-Evolutionary-Simple

 view release on metacpan or  search on metacpan

script/bitflip.pl  view on Meta::CPAN

use version; our $VERSION = qv('0.0.3');
use Algorithm::Evolutionary::Simple qw( random_chromosome mutate);
use Time::HiRes qw( gettimeofday tv_interval );
use v5.14;

my $length = 16;
my $iterations = 100000;
my $top_length = 2**15;
do {
    my $indi = random_chromosome($length);
    say "perlsimple-BitString, $length, ".time_mutations( $iterations, $indi );
    $length *= 2;
} while $length <= $top_length;

#--------------------------------------------------------------------
sub time_mutations {
    my $number = shift;
    my $indi = shift;
    my $inicioTiempo = [gettimeofday()];
    for (1..$number) {
      $indi = mutate( $indi );

script/onemax-benchmark.pl  view on Meta::CPAN


use version; our $VERSION = qv('0.0.3');
use Algorithm::Evolutionary::Simple qw( random_chromosome max_ones_fast);
use Time::HiRes qw( gettimeofday tv_interval );
use v5.14;

my $length = 16;
my $iterations = 100000;
my $top_length = 2**15;
do {
    say "perlsimple-BitString, $length, ".time_onemax( $iterations );
    $length *= 2;
} while $length <= $top_length;

#--------------------------------------------------------------------
sub time_onemax {
    my $number = shift;
    my $inicioTiempo = [gettimeofday()];
    for (1..$number) {
	my $indi = random_chromosome($length);
	my $fitness = max_ones_fast( $indi );

script/xover.pl  view on Meta::CPAN


use version; our $VERSION = qv('0.0.3');
use Algorithm::Evolutionary::Simple qw( random_chromosome crossover);
use Time::HiRes qw( gettimeofday tv_interval );
use v5.14;

my $length = 16;
my $iterations = 100000;
my $top_length = 2**15;
do {
    say "perlsimple-BitString, $length, ".time_crossover( $iterations );
    $length *= 2;
} while $length <= $top_length;

#--------------------------------------------------------------------
sub time_crossover {
    my $number = shift;
    my $inicioTiempo = [gettimeofday()];
    my $indi = random_chromosome($length);
    my $another_indi = random_chromosome($length);
    for (1..$number) {



( run in 1.006 second using v1.01-cache-2.11-cpan-483215c6ad5 )