View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
J. J. Merelo-Guervós > Algorithm-Evolutionary-Fitness-v3.102 > Algorithm::Evolutionary::Fitness::Any



Annotate this POD

View/Report Bugs
Module Version: 3.2   Source  


Algorithm::Evolutionary::Fitness::Any - Façade for any function so that it can be used as fitness


   use Algorithm::Evolutionary::Utils qw( string_decode )

   sub squares {
     my $chrom = shift;
     my @values = string_decode( $chrom, 10, -1, 1 );
     return $values[0] * $values[1];

   my $any_eval = new Algorithm::Evolutionary::Fitness::Any \&squares;


Turns any subroutine or closure into a fitness function. Useful mainly if you want results cached; it's not really needed otherwise.


new( $function )

Assigns default variables

apply( $individual )

Applies the instantiated problem to a chromosome. It is actually a wrapper around _apply.

_apply( $individual )

This is the one that really does the stuff. It applies the defined function to each individual. Itis cached for efficiency.

Copyright ^

  This file is released under the GPL. See the LICENSE file included in this distribution,
  or go to
syntax highlighting: