++ed by:

1 PAUSE user
1 non-PAUSE user.

J. J. Merelo-Guervós
and 1 contributors


Algorithm::Evolutionary::Op::Easy - evolutionary algorithm, single generation, with variable operators.


  my $easyEA = Algorithm::Evolutionary::Op::Base->fromXML( $ref->{initial}{section}{pop}{op} );
  # Parsed XML fragment, see samples

  for ( my $i = 0; $i < $ref->{initial}{section}{pop}{op}{param}{maxgen}{value}; $i++ ) {
    print "<", "="x 20, "Generation $i", "="x 20, ">\n"; 
    $easyEA->apply(\@pop ); 
    for ( @pop ) { 
      print $_->asString, "\n"; 

  #Define a default algorithm with predefined evaluation function,
  #Mutation and crossover. Default selection rate is 0.4
  my $algo = new Algorithm::Evolutionary::Op::Easy( $eval ); 

  #Define an easy single-generation algorithm with predefined mutation and crossover
  my $m = new Algorithm::Evolutionary::Op::Bitflip; #Changes a single bit
  my $c = new Algorithm::Evolutionary::Op::Crossover; #Classical 2-point crossover
  my $generation = new Algorithm::Evolutionary::Op::Easy( $rr, 0.2, [$m, $c] );

Base Class



"Easy" to use, single generation of an evolutionary algorithm. Takes an arrayref of operators as input, or defines bitflip-mutation and 2-point crossover as default. The apply method applies a single iteration of the algorithm to the population it takes as input


new( $eval_func, [$operators_arrayref] )

Creates an algorithm that optimizes the handled fitness function and reference to an array of operators. If this reference is null, an array consisting of bitflip mutation and 2 point crossover is generated. Which, of course, might not what you need in case you don't have a binary chromosome.

set( $hashref, codehash, opshash )

Sets the instance variables. Takes a ref-to-hash (for options), codehash (for fitness) and opshash (for operators)

apply( $population )

Applies the algorithm to the population; checks that it receives a ref-to-array as input, croaks if it does not. Returns a sorted, culled, evaluated population for next generation.


Algorithm::Evolutionary::Op::CanonicalGA. Algorithm::Evolutionary::Op::FullAlgorithm.


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: 2012/11/10 10:21:08 $ 
  $Header: /media/Backup/Repos/opeal/opeal/Algorithm-Evolutionary/lib/Algorithm/Evolutionary/Op/Easy.pm,v 3.5 2012/11/10 10:21:08 jmerelo Exp $ 
  $Author: jmerelo $ 
  $Revision: 3.5 $
  $Name $