Class: EvoSynth::Evolvers::LocalSearch

Inherits:
Object
  • Object
show all
Includes:
Evolver
Defined in:
lib/evosynth/evolvers/local_search/local_search.rb,
lib/evosynth/evolvers/local_search/acceptance_threshold.rb,
lib/evosynth/evolvers/local_search/acceptance_hillclimber.rb,
lib/evosynth/evolvers/local_search/acceptance_great_deluge.rb,
lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb,
lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb

Overview

LOKALE-SUCHE (Weicker Page 155)

Defined Under Namespace

Classes: GreatDelugeAcceptance, HillclimberAcceptance, RecordToRecordTravelAcceptance, SimulatedAnnealingAcceptance, ThresholdAcceptance

Constant Summary collapse

DEFAULT_ACCEPTANCE =
HillclimberAcceptance.new

Instance Attribute Summary

Attributes included from RunnableEvolver

#generations_computed

Instance Method Summary collapse

Methods included from ProfileUsingEvolver

#init_profile, #use_profile

Methods included from RunnableEvolver

#run_until, #run_until_fitness_reached, #run_until_generations_reached

Constructor Details

#initialize(profile) ⇒ LocalSearch

Returns a new instance of LocalSearch.


42
43
44
45
46
47
48
# File 'lib/evosynth/evolvers/local_search/local_search.rb', line 42

def initialize(profile)
	init_profile :individual, :mutation, :evaluator, :acceptance => DEFAULT_ACCEPTANCE

	use_profile profile

	@evaluator.calculate_and_set_initial_fitness(@individual)
end

Instance Method Details

#best_solutionObject


54
55
56
# File 'lib/evosynth/evolvers/local_search/local_search.rb', line 54

def best_solution
	@individual
end

#next_generationObject


66
67
68
69
70
# File 'lib/evosynth/evolvers/local_search/local_search.rb', line 66

def next_generation
	child = @mutation.mutate(@individual)
	@evaluator.calculate_and_set_fitness(child)
	@individual = child if @acceptance.accepts(@individual, child, @generations_computed)
end

#return_resultObject


62
63
64
# File 'lib/evosynth/evolvers/local_search/local_search.rb', line 62

def return_result
	@individual
end

#to_sObject


50
51
52
# File 'lib/evosynth/evolvers/local_search/local_search.rb', line 50

def to_s
	"local search <mutation: #{@mutation}, individual: #{@individual}>"
end

#worst_solutionObject


58
59
60
# File 'lib/evosynth/evolvers/local_search/local_search.rb', line 58

def worst_solution
	@individual
end