Module: Evolvable

Extended by:
Forwardable
Defined in:
lib/evolvable.rb,
lib/evolvable/gene.rb,
lib/evolvable/goal.rb,
lib/evolvable/genome.rb,
lib/evolvable/version.rb,
lib/evolvable/mutation.rb,
lib/evolvable/evolution.rb,
lib/evolvable/selection.rb,
lib/evolvable/count_gene.rb,
lib/evolvable/evaluation.rb,
lib/evolvable/population.rb,
lib/evolvable/serializer.rb,
lib/evolvable/search_space.rb,
lib/evolvable/equalize_goal.rb,
lib/evolvable/maximize_goal.rb,
lib/evolvable/minimize_goal.rb,
lib/evolvable/point_crossover.rb,
lib/evolvable/gene_combination.rb,
lib/evolvable/rigid_count_gene.rb,
lib/evolvable/uniform_crossover.rb,
lib/evolvable/error/undefined_method.rb

Overview

The Evolvable module makes it possible to implement evolutionary behaviors for any class by defining a .search_space class method and #value instance method. To evolve instances, initialize a population with .new_population and use the Evolvable::Population#evolve instance method.

  1. Include the Evolvable module in the class you want to evolve.
  2. Define .search_space and any gene classes that you reference.
  3. Define #value.
  4. Initialize a population with .new_population and use #evolve.

Defined Under Namespace

Modules: ClassMethods, Errors, Gene Classes: CountGene, EqualizeGoal, Evaluation, Evolution, GeneCombination, GeneSpace, Genome, Goal, MaximizeGoal, MinimizeGoal, Mutation, PointCrossover, Population, RigidCountGene, SearchSpace, Selection, Serializer, UniformCrossover

Constant Summary collapse

VERSION =
'1.1.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#generation_indexObject

Returns the value of attribute generation_index.


199
200
201
# File 'lib/evolvable.rb', line 199

def generation_index
  @generation_index
end

#genomeObject

Returns the value of attribute genome.


199
200
201
# File 'lib/evolvable.rb', line 199

def genome
  @genome
end

#idObject

Returns the value of attribute id.


199
200
201
# File 'lib/evolvable.rb', line 199

def id
  @id
end

#populationObject

Returns the value of attribute population.


199
200
201
# File 'lib/evolvable.rb', line 199

def population
  @population
end

#valueObject

Implementing this method is required for evaluation and selection.


199
200
201
202
203
# File 'lib/evolvable.rb', line 199

attr_accessor :id,
:population,
:genome,
:generation_index,
:value

Class Method Details

.included(base) ⇒ Object


40
41
42
# File 'lib/evolvable.rb', line 40

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#after_initializeObject

Runs an evolvable is initialized. Ueful for implementing custom initialization logic.


193
# File 'lib/evolvable.rb', line 193

def after_initialize; end

#find_geneObject


224
225
226
227
228
# File 'lib/evolvable.rb', line 224

def_delegators :genome,
:find_gene,
:find_genes,
:find_genes_count,
:genes

#find_genesObject


224
225
226
227
228
# File 'lib/evolvable.rb', line 224

def_delegators :genome,
:find_gene,
:find_genes,
:find_genes_count,
:genes

#find_genes_countObject


224
225
226
227
228
# File 'lib/evolvable.rb', line 224

def_delegators :genome,
:find_gene,
:find_genes,
:find_genes_count,
:genes

#genesObject


224
225
226
227
228
# File 'lib/evolvable.rb', line 224

def_delegators :genome,
:find_gene,
:find_genes,
:find_genes_count,
:genes

#population_indexObject

Deprecated.

Will be removed in version 2.0. Use instead.


210
211
212
# File 'lib/evolvable.rb', line 210

def population_index
  generation_index
end