evosynth 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (390) hide show
  1. data/INSTALL +74 -0
  2. data/LICENSE +22 -0
  3. data/README +57 -0
  4. data/Rakefile +132 -0
  5. data/TODO +88 -0
  6. data/docs/FEATURES +111 -0
  7. data/docs/rdoc/classes/EvoSynth.html +2643 -0
  8. data/docs/rdoc/classes/EvoSynth/Adjustments.html +119 -0
  9. data/docs/rdoc/classes/EvoSynth/Adjustments/AdaptiveAdjustment.html +264 -0
  10. data/docs/rdoc/classes/EvoSynth/Adjustments/PredifinedAdjustment.html +235 -0
  11. data/docs/rdoc/classes/EvoSynth/ArrayGenome.html +313 -0
  12. data/docs/rdoc/classes/EvoSynth/BinaryGenome.html +518 -0
  13. data/docs/rdoc/classes/EvoSynth/Decoder.html +286 -0
  14. data/docs/rdoc/classes/EvoSynth/Evaluator.html +466 -0
  15. data/docs/rdoc/classes/EvoSynth/Evolvers.html +469 -0
  16. data/docs/rdoc/classes/EvoSynth/Evolvers/AdaptiveES.html +448 -0
  17. data/docs/rdoc/classes/EvoSynth/Evolvers/BalancedCoevolutionary.html +439 -0
  18. data/docs/rdoc/classes/EvoSynth/Evolvers/DerandomizedES.html +450 -0
  19. data/docs/rdoc/classes/EvoSynth/Evolvers/Evolver.html +125 -0
  20. data/docs/rdoc/classes/EvoSynth/Evolvers/GeneticAlgorithm.html +467 -0
  21. data/docs/rdoc/classes/EvoSynth/Evolvers/Hillclimber.html +343 -0
  22. data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch.html +422 -0
  23. data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/GreatDelugeAcceptance.html +287 -0
  24. data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/HillclimberAcceptance.html +197 -0
  25. data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/RecordToRecordTravelAcceptance.html +296 -0
  26. data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/SimulatedAnnealingAcceptance.html +286 -0
  27. data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/ThresholdAcceptance.html +287 -0
  28. data/docs/rdoc/classes/EvoSynth/Evolvers/MemeticAlgorithm.html +441 -0
  29. data/docs/rdoc/classes/EvoSynth/Evolvers/PopulationHillclimber.html +375 -0
  30. data/docs/rdoc/classes/EvoSynth/Evolvers/ProfileUsingEvolver.html +205 -0
  31. data/docs/rdoc/classes/EvoSynth/Evolvers/RoundRobinCoevolutionary.html +383 -0
  32. data/docs/rdoc/classes/EvoSynth/Evolvers/RunnableEvolver.html +279 -0
  33. data/docs/rdoc/classes/EvoSynth/Evolvers/RunnableEvolver/Goal.html +193 -0
  34. data/docs/rdoc/classes/EvoSynth/Evolvers/SelfAdaptiveES.html +394 -0
  35. data/docs/rdoc/classes/EvoSynth/Evolvers/SteadyStateGA.html +390 -0
  36. data/docs/rdoc/classes/EvoSynth/GlobalRecombinations.html +119 -0
  37. data/docs/rdoc/classes/EvoSynth/GlobalRecombinations/GlobalArithmeticCrossover.html +204 -0
  38. data/docs/rdoc/classes/EvoSynth/GlobalRecombinations/GlobalUniformCrossover.html +203 -0
  39. data/docs/rdoc/classes/EvoSynth/Individual.html +561 -0
  40. data/docs/rdoc/classes/EvoSynth/MaximizingIndividual.html +266 -0
  41. data/docs/rdoc/classes/EvoSynth/MetaOperators.html +149 -0
  42. data/docs/rdoc/classes/EvoSynth/MetaOperators/ConditionalCombinedOperator.html +278 -0
  43. data/docs/rdoc/classes/EvoSynth/MetaOperators/ProportionalCombinedOperator.html +285 -0
  44. data/docs/rdoc/classes/EvoSynth/MetaOperators/SequentialCombinedOperator.html +290 -0
  45. data/docs/rdoc/classes/EvoSynth/MinimizingIndividual.html +266 -0
  46. data/docs/rdoc/classes/EvoSynth/Mutations.html +251 -0
  47. data/docs/rdoc/classes/EvoSynth/Mutations/BinaryMutation.html +336 -0
  48. data/docs/rdoc/classes/EvoSynth/Mutations/EfficientBinaryMutation.html +345 -0
  49. data/docs/rdoc/classes/EvoSynth/Mutations/ExchangeMutation.html +320 -0
  50. data/docs/rdoc/classes/EvoSynth/Mutations/Functions.html +160 -0
  51. data/docs/rdoc/classes/EvoSynth/Mutations/GaussMutation.html +311 -0
  52. data/docs/rdoc/classes/EvoSynth/Mutations/Identity.html +220 -0
  53. data/docs/rdoc/classes/EvoSynth/Mutations/InversionMutation.html +231 -0
  54. data/docs/rdoc/classes/EvoSynth/Mutations/MixingMutation.html +233 -0
  55. data/docs/rdoc/classes/EvoSynth/Mutations/OneGeneFlipping.html +295 -0
  56. data/docs/rdoc/classes/EvoSynth/Mutations/SelfAdaptiveGaussMutation.html +347 -0
  57. data/docs/rdoc/classes/EvoSynth/Mutations/ShiftingMutation.html +229 -0
  58. data/docs/rdoc/classes/EvoSynth/Mutations/UniformRealMutation.html +264 -0
  59. data/docs/rdoc/classes/EvoSynth/Output.html +212 -0
  60. data/docs/rdoc/classes/EvoSynth/Output/CSVExporter.html +211 -0
  61. data/docs/rdoc/classes/EvoSynth/Output/ConsoleWriter.html +194 -0
  62. data/docs/rdoc/classes/EvoSynth/Output/GnuPlotExporter.html +235 -0
  63. data/docs/rdoc/classes/EvoSynth/Output/GruffExporter.html +219 -0
  64. data/docs/rdoc/classes/EvoSynth/Output/Logger.html +345 -0
  65. data/docs/rdoc/classes/EvoSynth/Population.html +430 -0
  66. data/docs/rdoc/classes/EvoSynth/Problems.html +159 -0
  67. data/docs/rdoc/classes/EvoSynth/Problems/BinaryBenchmarkFuntions.html +258 -0
  68. data/docs/rdoc/classes/EvoSynth/Problems/FloatBenchmarkFuntions.html +406 -0
  69. data/docs/rdoc/classes/EvoSynth/Problems/GraphColouring.html +265 -0
  70. data/docs/rdoc/classes/EvoSynth/Problems/TSP.html +327 -0
  71. data/docs/rdoc/classes/EvoSynth/Profile.html +324 -0
  72. data/docs/rdoc/classes/EvoSynth/Recombinations.html +251 -0
  73. data/docs/rdoc/classes/EvoSynth/Recombinations/ArithmeticCrossover.html +286 -0
  74. data/docs/rdoc/classes/EvoSynth/Recombinations/EdgeRecombination.html +203 -0
  75. data/docs/rdoc/classes/EvoSynth/Recombinations/Identity.html +192 -0
  76. data/docs/rdoc/classes/EvoSynth/Recombinations/KPointCrossover.html +286 -0
  77. data/docs/rdoc/classes/EvoSynth/Recombinations/OnePointCrossover.html +211 -0
  78. data/docs/rdoc/classes/EvoSynth/Recombinations/OrderedRecombination.html +206 -0
  79. data/docs/rdoc/classes/EvoSynth/Recombinations/PartiallyMappedCrossover.html +206 -0
  80. data/docs/rdoc/classes/EvoSynth/Recombinations/UniformCrossover.html +208 -0
  81. data/docs/rdoc/classes/EvoSynth/Selections.html +174 -0
  82. data/docs/rdoc/classes/EvoSynth/Selections/FitnessProportionalSelection.html +206 -0
  83. data/docs/rdoc/classes/EvoSynth/Selections/Identity.html +200 -0
  84. data/docs/rdoc/classes/EvoSynth/Selections/NStageTournamentSelection.html +273 -0
  85. data/docs/rdoc/classes/EvoSynth/Selections/RandomSelection.html +192 -0
  86. data/docs/rdoc/classes/EvoSynth/Selections/RouletteWheelSelection.html +212 -0
  87. data/docs/rdoc/classes/EvoSynth/Selections/SelectBest.html +206 -0
  88. data/docs/rdoc/classes/EvoSynth/Selections/TournamentSelection.html +274 -0
  89. data/docs/rdoc/classes/Examples.html +268 -0
  90. data/docs/rdoc/classes/Examples/Ants.html +198 -0
  91. data/docs/rdoc/classes/Examples/Ants/AntMutation.html +381 -0
  92. data/docs/rdoc/classes/Examples/Ants/Pheromon.html +256 -0
  93. data/docs/rdoc/classes/Examples/CCGAExample.html +305 -0
  94. data/docs/rdoc/classes/Examples/CCGAExample/CCGA2BenchmarkEvaluator.html +165 -0
  95. data/docs/rdoc/classes/Examples/CCGAExample/CCGABenchmarkEvaluator.html +242 -0
  96. data/docs/rdoc/classes/Examples/CCGAExample/CCGAIndividual.html +181 -0
  97. data/docs/rdoc/classes/Examples/CMBExample.html +215 -0
  98. data/docs/rdoc/classes/Examples/CMBExample/CMBEvaluator.html +212 -0
  99. data/docs/rdoc/classes/Examples/EsExample.html +270 -0
  100. data/docs/rdoc/classes/Examples/EsExample/BenchmarkEvaluator.html +162 -0
  101. data/docs/rdoc/classes/Examples/Exporter.html +208 -0
  102. data/docs/rdoc/classes/Examples/Exporter/ExporterEvaluator.html +196 -0
  103. data/docs/rdoc/classes/Examples/GraphColouring.html +199 -0
  104. data/docs/rdoc/classes/Examples/Hacking.html +147 -0
  105. data/docs/rdoc/classes/Examples/Hacking/HackingEvaluator.html +169 -0
  106. data/docs/rdoc/classes/Examples/LocalSearch.html +294 -0
  107. data/docs/rdoc/classes/Examples/LocalSearch/LocalSearchEvaluator.html +198 -0
  108. data/docs/rdoc/classes/Examples/MaxOnes.html +187 -0
  109. data/docs/rdoc/classes/Examples/MaxOnes/MaxOnesEvaluator.html +170 -0
  110. data/docs/rdoc/classes/Examples/Partitionproblem.html +201 -0
  111. data/docs/rdoc/classes/Examples/Partitionproblem/PartitionEvaluator.html +164 -0
  112. data/docs/rdoc/classes/Examples/Partitionproblem/PartitionIndividual.html +334 -0
  113. data/docs/rdoc/classes/Examples/Partitionproblem/PartitionMutation.html +199 -0
  114. data/docs/rdoc/classes/Examples/Partitionproblem/Testdata.html +294 -0
  115. data/docs/rdoc/classes/Examples/SPk.html +139 -0
  116. data/docs/rdoc/classes/Examples/SPk/SPkFitnessEvaluator.html +299 -0
  117. data/docs/rdoc/classes/Examples/TSP.html +187 -0
  118. data/docs/rdoc/created.rid +1 -0
  119. data/docs/rdoc/files/INSTALL.html +253 -0
  120. data/docs/rdoc/files/LICENSE.html +119 -0
  121. data/docs/rdoc/files/README.html +235 -0
  122. data/docs/rdoc/files/docs/FEATURES.html +428 -0
  123. data/docs/rdoc/files/examples/ants_rb.html +133 -0
  124. data/docs/rdoc/files/examples/ccga_example_rb.html +129 -0
  125. data/docs/rdoc/files/examples/cmb_example_rb.html +129 -0
  126. data/docs/rdoc/files/examples/evolution_strategies_rb.html +129 -0
  127. data/docs/rdoc/files/examples/exporter_rb.html +129 -0
  128. data/docs/rdoc/files/examples/graph_colouring_rb.html +129 -0
  129. data/docs/rdoc/files/examples/hacking_rb.html +129 -0
  130. data/docs/rdoc/files/examples/local_search_rb.html +129 -0
  131. data/docs/rdoc/files/examples/max_ones_rb.html +129 -0
  132. data/docs/rdoc/files/examples/partition_rb.html +131 -0
  133. data/docs/rdoc/files/examples/spk_rb.html +129 -0
  134. data/docs/rdoc/files/examples/tsp_rb.html +131 -0
  135. data/docs/rdoc/files/lib/evosynth/core/array_genome_rb.html +119 -0
  136. data/docs/rdoc/files/lib/evosynth/core/binary_genome_rb.html +119 -0
  137. data/docs/rdoc/files/lib/evosynth/core/evaluator_rb.html +129 -0
  138. data/docs/rdoc/files/lib/evosynth/core/individual_rb.html +119 -0
  139. data/docs/rdoc/files/lib/evosynth/core/maximizing_individual_rb.html +119 -0
  140. data/docs/rdoc/files/lib/evosynth/core/minimizing_individual_rb.html +119 -0
  141. data/docs/rdoc/files/lib/evosynth/core/population_rb.html +119 -0
  142. data/docs/rdoc/files/lib/evosynth/core/profile_rb.html +119 -0
  143. data/docs/rdoc/files/lib/evosynth/core/randomizer_rb.html +119 -0
  144. data/docs/rdoc/files/lib/evosynth/core_rb.html +145 -0
  145. data/docs/rdoc/files/lib/evosynth/decoder/binary_to_real_rb.html +119 -0
  146. data/docs/rdoc/files/lib/evosynth/decoder/gray_rb.html +119 -0
  147. data/docs/rdoc/files/lib/evosynth/decoder_rb.html +131 -0
  148. data/docs/rdoc/files/lib/evosynth/evolvers/basic/genetic_algorithm_rb.html +119 -0
  149. data/docs/rdoc/files/lib/evosynth/evolvers/basic/hillclimber_rb.html +119 -0
  150. data/docs/rdoc/files/lib/evosynth/evolvers/basic/memetic_algorithm_rb.html +119 -0
  151. data/docs/rdoc/files/lib/evosynth/evolvers/basic/population_hillclimber_rb.html +119 -0
  152. data/docs/rdoc/files/lib/evosynth/evolvers/basic/steady_state_ga_rb.html +119 -0
  153. data/docs/rdoc/files/lib/evosynth/evolvers/coevolutionary/balanced_coevolutionary_rb.html +119 -0
  154. data/docs/rdoc/files/lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary_rb.html +119 -0
  155. data/docs/rdoc/files/lib/evosynth/evolvers/elitism_rb.html +119 -0
  156. data/docs/rdoc/files/lib/evosynth/evolvers/evolution_strategies/adaptive_es_rb.html +129 -0
  157. data/docs/rdoc/files/lib/evosynth/evolvers/evolution_strategies/derandomized_es_rb.html +129 -0
  158. data/docs/rdoc/files/lib/evosynth/evolvers/evolution_strategies/selfadaptive_es_rb.html +119 -0
  159. data/docs/rdoc/files/lib/evosynth/evolvers/evolver_rb.html +131 -0
  160. data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_great_deluge_rb.html +119 -0
  161. data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_hillclimber_rb.html +119 -0
  162. data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_record_to_record_rb.html +119 -0
  163. data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_simulated_annealing_rb.html +119 -0
  164. data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_threshold_rb.html +119 -0
  165. data/docs/rdoc/files/lib/evosynth/evolvers/local_search/local_search_rb.html +137 -0
  166. data/docs/rdoc/files/lib/evosynth/evolvers/profile_using_evolver_rb.html +119 -0
  167. data/docs/rdoc/files/lib/evosynth/evolvers/runnable_evolver_rb.html +129 -0
  168. data/docs/rdoc/files/lib/evosynth/evolvers_rb.html +153 -0
  169. data/docs/rdoc/files/lib/evosynth/operators/adjustments/adaptive_adjustment_rb.html +119 -0
  170. data/docs/rdoc/files/lib/evosynth/operators/adjustments/predefined_adjustment_rb.html +119 -0
  171. data/docs/rdoc/files/lib/evosynth/operators/adjustments_rb.html +131 -0
  172. data/docs/rdoc/files/lib/evosynth/operators/global_recombinations/global_arithmetic_crossover_rb.html +119 -0
  173. data/docs/rdoc/files/lib/evosynth/operators/global_recombinations/global_uniform_crossover_rb.html +119 -0
  174. data/docs/rdoc/files/lib/evosynth/operators/global_recombinations_rb.html +131 -0
  175. data/docs/rdoc/files/lib/evosynth/operators/meta_operators/conditional_combined_operator_rb.html +119 -0
  176. data/docs/rdoc/files/lib/evosynth/operators/meta_operators/proportional_combined_operator_rb.html +119 -0
  177. data/docs/rdoc/files/lib/evosynth/operators/meta_operators/sequential_combined_operator_rb.html +119 -0
  178. data/docs/rdoc/files/lib/evosynth/operators/meta_operators_rb.html +133 -0
  179. data/docs/rdoc/files/lib/evosynth/operators/mutations/binary_mutation_rb.html +119 -0
  180. data/docs/rdoc/files/lib/evosynth/operators/mutations/efficient_binary_mutation_rb.html +119 -0
  181. data/docs/rdoc/files/lib/evosynth/operators/mutations/exchange_mutation_rb.html +119 -0
  182. data/docs/rdoc/files/lib/evosynth/operators/mutations/flip_functions_rb.html +119 -0
  183. data/docs/rdoc/files/lib/evosynth/operators/mutations/gauss_mutation_rb.html +119 -0
  184. data/docs/rdoc/files/lib/evosynth/operators/mutations/identity_rb.html +119 -0
  185. data/docs/rdoc/files/lib/evosynth/operators/mutations/inversion_mutation_rb.html +119 -0
  186. data/docs/rdoc/files/lib/evosynth/operators/mutations/mixing_mutation_rb.html +119 -0
  187. data/docs/rdoc/files/lib/evosynth/operators/mutations/one_gene_flipping_rb.html +119 -0
  188. data/docs/rdoc/files/lib/evosynth/operators/mutations/self_adaptive_gauss_mutation_rb.html +119 -0
  189. data/docs/rdoc/files/lib/evosynth/operators/mutations/shifting_mutation_rb.html +119 -0
  190. data/docs/rdoc/files/lib/evosynth/operators/mutations/uniform_real_mutation_rb.html +119 -0
  191. data/docs/rdoc/files/lib/evosynth/operators/mutations_rb.html +151 -0
  192. data/docs/rdoc/files/lib/evosynth/operators/recombinations/arithmetic_crossover_rb.html +119 -0
  193. data/docs/rdoc/files/lib/evosynth/operators/recombinations/edge_recombination_rb.html +129 -0
  194. data/docs/rdoc/files/lib/evosynth/operators/recombinations/identity_rb.html +119 -0
  195. data/docs/rdoc/files/lib/evosynth/operators/recombinations/k_point_crossover_rb.html +119 -0
  196. data/docs/rdoc/files/lib/evosynth/operators/recombinations/one_point_crossover_rb.html +119 -0
  197. data/docs/rdoc/files/lib/evosynth/operators/recombinations/ordered_recombination_rb.html +129 -0
  198. data/docs/rdoc/files/lib/evosynth/operators/recombinations/partially_mapped_crossover_rb.html +129 -0
  199. data/docs/rdoc/files/lib/evosynth/operators/recombinations/uniform_crossover_rb.html +119 -0
  200. data/docs/rdoc/files/lib/evosynth/operators/recombinations_rb.html +143 -0
  201. data/docs/rdoc/files/lib/evosynth/operators/selections/best_selection_rb.html +119 -0
  202. data/docs/rdoc/files/lib/evosynth/operators/selections/fitness_proportional_selection_rb.html +119 -0
  203. data/docs/rdoc/files/lib/evosynth/operators/selections/identity_rb.html +119 -0
  204. data/docs/rdoc/files/lib/evosynth/operators/selections/n_stage_tournament_selection_rb.html +119 -0
  205. data/docs/rdoc/files/lib/evosynth/operators/selections/random_selection_rb.html +119 -0
  206. data/docs/rdoc/files/lib/evosynth/operators/selections/roulette_wheel_selection_rb.html +119 -0
  207. data/docs/rdoc/files/lib/evosynth/operators/selections/tournament_selection_rb.html +119 -0
  208. data/docs/rdoc/files/lib/evosynth/operators/selections_rb.html +141 -0
  209. data/docs/rdoc/files/lib/evosynth/operators_rb.html +139 -0
  210. data/docs/rdoc/files/lib/evosynth/output/console_writer_rb.html +129 -0
  211. data/docs/rdoc/files/lib/evosynth/output/exporter/csv_exporter_rb.html +129 -0
  212. data/docs/rdoc/files/lib/evosynth/output/exporter/gnuplot_exporter_rb.html +131 -0
  213. data/docs/rdoc/files/lib/evosynth/output/exporter/gruff_exporter_rb.html +131 -0
  214. data/docs/rdoc/files/lib/evosynth/output/exporter_rb.html +133 -0
  215. data/docs/rdoc/files/lib/evosynth/output/factory_rb.html +129 -0
  216. data/docs/rdoc/files/lib/evosynth/output/logger_rb.html +119 -0
  217. data/docs/rdoc/files/lib/evosynth/output_rb.html +135 -0
  218. data/docs/rdoc/files/lib/evosynth/problems/binary_benchmark_functions_rb.html +119 -0
  219. data/docs/rdoc/files/lib/evosynth/problems/float_benchmark_functions_rb.html +1630 -0
  220. data/docs/rdoc/files/lib/evosynth/problems/graph_colouring_rb.html +129 -0
  221. data/docs/rdoc/files/lib/evosynth/problems/tsp_rb.html +129 -0
  222. data/docs/rdoc/files/lib/evosynth/problems_rb.html +135 -0
  223. data/docs/rdoc/files/lib/evosynth_rb.html +139 -0
  224. data/docs/rdoc/fr_class_index.html +245 -0
  225. data/docs/rdoc/fr_file_index.html +233 -0
  226. data/docs/rdoc/fr_method_index.html +661 -0
  227. data/docs/rdoc/index.html +21 -0
  228. data/docs/rdoc/rdoc-style.css +299 -0
  229. data/examples/ants.rb +237 -0
  230. data/examples/ccga_example.rb +150 -0
  231. data/examples/cmb_example.rb +117 -0
  232. data/examples/evolution_strategies.rb +84 -0
  233. data/examples/exporter.rb +90 -0
  234. data/examples/graph_colouring.rb +72 -0
  235. data/examples/hacking.rb +62 -0
  236. data/examples/local_search.rb +109 -0
  237. data/examples/max_ones.rb +83 -0
  238. data/examples/partition.rb +172 -0
  239. data/examples/spk.rb +106 -0
  240. data/examples/tsp.rb +83 -0
  241. data/lib/evosynth.rb +32 -0
  242. data/lib/evosynth/core.rb +33 -0
  243. data/lib/evosynth/core/array_genome.rb +77 -0
  244. data/lib/evosynth/core/binary_genome.rb +156 -0
  245. data/lib/evosynth/core/evaluator.rb +109 -0
  246. data/lib/evosynth/core/individual.rb +92 -0
  247. data/lib/evosynth/core/maximizing_individual.rb +71 -0
  248. data/lib/evosynth/core/minimizing_individual.rb +71 -0
  249. data/lib/evosynth/core/population.rb +120 -0
  250. data/lib/evosynth/core/profile.rb +110 -0
  251. data/lib/evosynth/core/randomizer.rb +73 -0
  252. data/lib/evosynth/decoder.rb +33 -0
  253. data/lib/evosynth/decoder/binary_to_real.rb +57 -0
  254. data/lib/evosynth/decoder/gray.rb +54 -0
  255. data/lib/evosynth/evolvers.rb +41 -0
  256. data/lib/evosynth/evolvers/basic/genetic_algorithm.rb +92 -0
  257. data/lib/evosynth/evolvers/basic/hillclimber.rb +64 -0
  258. data/lib/evosynth/evolvers/basic/memetic_algorithm.rb +111 -0
  259. data/lib/evosynth/evolvers/basic/population_hillclimber.rb +69 -0
  260. data/lib/evosynth/evolvers/basic/steady_state_ga.rb +85 -0
  261. data/lib/evosynth/evolvers/coevolutionary/balanced_coevolutionary.rb +125 -0
  262. data/lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb +87 -0
  263. data/lib/evosynth/evolvers/elitism.rb +108 -0
  264. data/lib/evosynth/evolvers/evolution_strategies/adaptive_es.rb +104 -0
  265. data/lib/evosynth/evolvers/evolution_strategies/derandomized_es.rb +120 -0
  266. data/lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb +82 -0
  267. data/lib/evosynth/evolvers/evolver.rb +43 -0
  268. data/lib/evosynth/evolvers/local_search/acceptance_great_deluge.rb +60 -0
  269. data/lib/evosynth/evolvers/local_search/acceptance_hillclimber.rb +47 -0
  270. data/lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb +69 -0
  271. data/lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb +59 -0
  272. data/lib/evosynth/evolvers/local_search/acceptance_threshold.rb +60 -0
  273. data/lib/evosynth/evolvers/local_search/local_search.rb +74 -0
  274. data/lib/evosynth/evolvers/profile_using_evolver.rb +77 -0
  275. data/lib/evosynth/evolvers/runnable_evolver.rb +89 -0
  276. data/lib/evosynth/operators.rb +30 -0
  277. data/lib/evosynth/operators/adjustments.rb +26 -0
  278. data/lib/evosynth/operators/adjustments/adaptive_adjustment.rb +55 -0
  279. data/lib/evosynth/operators/adjustments/predefined_adjustment.rb +46 -0
  280. data/lib/evosynth/operators/global_recombinations.rb +26 -0
  281. data/lib/evosynth/operators/global_recombinations/global_arithmetic_crossover.rb +50 -0
  282. data/lib/evosynth/operators/global_recombinations/global_uniform_crossover.rb +49 -0
  283. data/lib/evosynth/operators/meta_operators.rb +36 -0
  284. data/lib/evosynth/operators/meta_operators/conditional_combined_operator.rb +65 -0
  285. data/lib/evosynth/operators/meta_operators/proportional_combined_operator.rb +84 -0
  286. data/lib/evosynth/operators/meta_operators/sequential_combined_operator.rb +73 -0
  287. data/lib/evosynth/operators/mutations.rb +47 -0
  288. data/lib/evosynth/operators/mutations/binary_mutation.rb +100 -0
  289. data/lib/evosynth/operators/mutations/efficient_binary_mutation.rb +105 -0
  290. data/lib/evosynth/operators/mutations/exchange_mutation.rb +107 -0
  291. data/lib/evosynth/operators/mutations/flip_functions.rb +45 -0
  292. data/lib/evosynth/operators/mutations/gauss_mutation.rb +65 -0
  293. data/lib/evosynth/operators/mutations/identity.rb +62 -0
  294. data/lib/evosynth/operators/mutations/inversion_mutation.rb +73 -0
  295. data/lib/evosynth/operators/mutations/mixing_mutation.rb +75 -0
  296. data/lib/evosynth/operators/mutations/one_gene_flipping.rb +89 -0
  297. data/lib/evosynth/operators/mutations/self_adaptive_gauss_mutation.rb +73 -0
  298. data/lib/evosynth/operators/mutations/shifting_mutation.rb +88 -0
  299. data/lib/evosynth/operators/mutations/uniform_real_mutation.rb +59 -0
  300. data/lib/evosynth/operators/recombinations.rb +48 -0
  301. data/lib/evosynth/operators/recombinations/arithmetic_crossover.rb +67 -0
  302. data/lib/evosynth/operators/recombinations/edge_recombination.rb +108 -0
  303. data/lib/evosynth/operators/recombinations/identity.rb +42 -0
  304. data/lib/evosynth/operators/recombinations/k_point_crossover.rb +81 -0
  305. data/lib/evosynth/operators/recombinations/one_point_crossover.rb +56 -0
  306. data/lib/evosynth/operators/recombinations/ordered_recombination.rb +75 -0
  307. data/lib/evosynth/operators/recombinations/partially_mapped_crossover.rb +102 -0
  308. data/lib/evosynth/operators/recombinations/uniform_crossover.rb +54 -0
  309. data/lib/evosynth/operators/selections.rb +31 -0
  310. data/lib/evosynth/operators/selections/best_selection.rb +54 -0
  311. data/lib/evosynth/operators/selections/fitness_proportional_selection.rb +83 -0
  312. data/lib/evosynth/operators/selections/identity.rb +48 -0
  313. data/lib/evosynth/operators/selections/n_stage_tournament_selection.rb +84 -0
  314. data/lib/evosynth/operators/selections/random_selection.rb +44 -0
  315. data/lib/evosynth/operators/selections/roulette_wheel_selection.rb +54 -0
  316. data/lib/evosynth/operators/selections/tournament_selection.rb +71 -0
  317. data/lib/evosynth/output.rb +28 -0
  318. data/lib/evosynth/output/console_writer.rb +45 -0
  319. data/lib/evosynth/output/exporter.rb +27 -0
  320. data/lib/evosynth/output/exporter/csv_exporter.rb +62 -0
  321. data/lib/evosynth/output/exporter/gnuplot_exporter.rb +81 -0
  322. data/lib/evosynth/output/exporter/gruff_exporter.rb +70 -0
  323. data/lib/evosynth/output/factory.rb +38 -0
  324. data/lib/evosynth/output/logger.rb +83 -0
  325. data/lib/evosynth/problems.rb +37 -0
  326. data/lib/evosynth/problems/binary_benchmark_functions.rb +74 -0
  327. data/lib/evosynth/problems/float_benchmark_functions.rb +99 -0
  328. data/lib/evosynth/problems/graph_colouring.rb +89 -0
  329. data/lib/evosynth/problems/tsp.rb +88 -0
  330. data/test/benchmark/decoder_benchmark.rb +75 -0
  331. data/test/benchmark/mutation_benchmark.rb +88 -0
  332. data/test/benchmark/recombination_benchmark.rb +58 -0
  333. data/test/benchmark/selection_benchmark.rb +52 -0
  334. data/test/core/tc_array_genome.rb +154 -0
  335. data/test/core/tc_binary_genome.rb +160 -0
  336. data/test/core/tc_population.rb +154 -0
  337. data/test/core/tc_profile.rb +75 -0
  338. data/test/core/tc_randomizer.rb +165 -0
  339. data/test/coverage.rb +43 -0
  340. data/test/decoder/tc_binary_to_real.rb +52 -0
  341. data/test/decoder/tc_gray.rb +107 -0
  342. data/test/operators/adjustments/tc_adaptive_adjustment.rb +63 -0
  343. data/test/operators/adjustments/tc_predefined_adjustment.rb +49 -0
  344. data/test/operators/global_recombinations/tc_global_arithmetic_crossover.rb +78 -0
  345. data/test/operators/global_recombinations/tc_global_uniform_crossover.rb +90 -0
  346. data/test/operators/meta_operators/tc_conditional_combined_operator.rb +66 -0
  347. data/test/operators/meta_operators/tc_proportional_combined_operator.rb +167 -0
  348. data/test/operators/meta_operators/tc_sequential_combined_operator.rb +98 -0
  349. data/test/operators/mutations/tc_binary_mutation.rb +73 -0
  350. data/test/operators/mutations/tc_efficient_binary_mutation.rb +73 -0
  351. data/test/operators/mutations/tc_exchange_mutation.rb +127 -0
  352. data/test/operators/mutations/tc_gauss_mutation.rb +130 -0
  353. data/test/operators/mutations/tc_identity_mutation.rb +64 -0
  354. data/test/operators/mutations/tc_inversion_mutation.rb +70 -0
  355. data/test/operators/mutations/tc_mixing_mutation.rb +73 -0
  356. data/test/operators/mutations/tc_one_gene_flipping.rb +109 -0
  357. data/test/operators/mutations/tc_self_adaptive_gauss_mutation.rb +72 -0
  358. data/test/operators/mutations/tc_shifting_muation.rb +73 -0
  359. data/test/operators/mutations/tc_uniform_real_mutation.rb +65 -0
  360. data/test/operators/recombinations/tc_arithmetic_crossover.rb +79 -0
  361. data/test/operators/recombinations/tc_edge_recombination.rb +76 -0
  362. data/test/operators/recombinations/tc_identity_recombination.rb +81 -0
  363. data/test/operators/recombinations/tc_k_point_crossover.rb +81 -0
  364. data/test/operators/recombinations/tc_one_point_crossover.rb +80 -0
  365. data/test/operators/recombinations/tc_ordered_recombination.rb +76 -0
  366. data/test/operators/recombinations/tc_partially_mapped_crossover.rb +91 -0
  367. data/test/operators/recombinations/tc_uniform_crossover.rb +84 -0
  368. data/test/operators/selections/tc_best_selection.rb +85 -0
  369. data/test/operators/selections/tc_fitness_proportional_selection.rb +78 -0
  370. data/test/operators/selections/tc_identity.rb +91 -0
  371. data/test/operators/selections/tc_n_stage_tournament.rb +78 -0
  372. data/test/operators/selections/tc_random_selection.rb +70 -0
  373. data/test/operators/selections/tc_roulette_wheel_selection.rb +78 -0
  374. data/test/operators/selections/tc_tournament_selection.rb +83 -0
  375. data/test/problems/tc_binary_benchmark_functions.rb +126 -0
  376. data/test/problems/tc_float_benchmark_functions.rb +100 -0
  377. data/test/test_util/test_helper.rb +128 -0
  378. data/test/ts_adjustments.rb +26 -0
  379. data/test/ts_core.rb +29 -0
  380. data/test/ts_decoder.rb +26 -0
  381. data/test/ts_global_recombinations.rb +26 -0
  382. data/test/ts_meta_operators.rb +27 -0
  383. data/test/ts_mutations.rb +35 -0
  384. data/test/ts_problems.rb +26 -0
  385. data/test/ts_recombinations.rb +32 -0
  386. data/test/ts_selections.rb +31 -0
  387. data/testdata/README +4 -0
  388. data/testdata/bays29.tsp +68 -0
  389. data/testdata/myciel4.col +77 -0
  390. metadata +552 -0
@@ -0,0 +1,73 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+
27
+ # Uniform distributed (between 0.0 and 1.0) pseudo-random number generator of EvoSynth,
28
+ # overwrite this function if you want to change the uniform distributed random number
29
+ # generator of EvoSynth.
30
+ #
31
+ # This a fascade to Kernel.rand. For a complete documentation see the Ruby documentation of rand().
32
+
33
+ def EvoSynth.rand(*args)
34
+ Kernel.rand(*args)
35
+ end
36
+
37
+ # Returns a pseudo-random boolean value (true or false).
38
+
39
+ def EvoSynth.rand_bool
40
+ EvoSynth.rand(2) > 0
41
+ end
42
+
43
+ # :call-seq:
44
+ # EvoSynth.nrand #=> pseudo-random normal distributed random number
45
+ # EvoSynth.nrand(3.2) #=> pseudo-random normal distributed random number around 3.2
46
+ # EvoSynth.nrand(2.4, 1.5) #=> pseudo-random normal distributed random number around 2.4 with sigma = 1.5
47
+ #
48
+ # Normal distributed pseudo-random number generator of EvoSynth. Uses the polar form of
49
+ # the Box-Mueller transformation to transform two Uniform distributed random numbers into
50
+ # one normal distributed random number (see: http://www.taygeta.com/random/gaussian.html=).
51
+
52
+ def EvoSynth.nrand(mu = 0.0, sigma = 1.0)
53
+ x1, x2, w, = 0.0, 0.0, 0.0, 0.0
54
+
55
+ begin
56
+ x1 = 2.0 * EvoSynth.rand - 1.0
57
+ x2 = 2.0 * EvoSynth.rand - 1.0
58
+ w = x1 ** 2.0 + x2 ** 2.0;
59
+ end while ( w >= 1.0 )
60
+
61
+ w = Math.sqrt( (-2.0 * Math.log( w ) ) / w )
62
+ mu + (x2 * w * sigma)
63
+ end
64
+
65
+ # Set the seed of the uniform distributed random number generator of EvoSynth.
66
+ #
67
+ # This a fascade to Kernel.srand, for a complete documentation see the Ruby documentation of srand().
68
+
69
+ def EvoSynth.srand(*args)
70
+ Kernel.srand(*args)
71
+ end
72
+
73
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+
27
+ # This module contains all genome decoders (genotype <-> phenotype conversion).
28
+ module Decoder
29
+ end
30
+ end
31
+
32
+ require 'evosynth/decoder/gray'
33
+ require 'evosynth/decoder/binary_to_real'
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+ module Decoder
27
+
28
+ # :call-seq:
29
+ # Decoder.binary_to_real([1,1,0,1]) -> Float (between -1.0 and 1.0)
30
+ # Decoder.binary_to_real([1,1,0,1], 0.0) -> Float (between 0.0 and 1.0)
31
+ # Decoder.binary_to_real([1,1,0,1], -5.12, 5.12) -> Float (between -5.12 and 5.12)
32
+ #
33
+ # This converts a given array of binary values (either 1/0 or true/false) into
34
+ # a Float in a given range.
35
+
36
+ def Decoder.binary_to_real(binary, min_bound = -1.0, max_bound = 1.0)
37
+ binary = binary.map do |bin|
38
+ case bin
39
+ when false then 0
40
+ when true then 1
41
+ else bin
42
+ end
43
+ end
44
+
45
+ max_bound, min_bound = min_bound, max_bound if min_bound > max_bound
46
+
47
+ range_size = max_bound.to_f - min_bound.to_f
48
+ integer = Integer("0b#{binary.join}")
49
+ max_integer = Integer("0b" + ("1" * binary.size))
50
+
51
+ float = integer * (range_size / max_integer) + min_bound;
52
+ float
53
+ end
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+ module Decoder
27
+
28
+ # Converts a binary gray code bitstring (either 1/0 or true/false) into a standard binary bitstring.
29
+
30
+ def Decoder.gray_to_binary(gray)
31
+ rev_stdbin = Array.new(gray.size)
32
+ gray.reverse!
33
+
34
+ rev_stdbin[gray.size - 1] = gray[gray.size - 1]
35
+ (gray.size - 2).downto(0) { |index| rev_stdbin[index] = rev_stdbin[index + 1] ^ gray[index] }
36
+
37
+ rev_stdbin.reverse
38
+ end
39
+
40
+ # Converts a standard binary bitstring (either 1/0 or true/false) into a gray code bitstring.
41
+
42
+ def Decoder.binary_to_gray(binary)
43
+ gray = Array.new(binary)
44
+
45
+ popped = gray.pop
46
+ gray.unshift(popped ^ popped)
47
+ gray.each_index { |index| gray[index] = binary[index] ^ gray[index]}
48
+
49
+ gray
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ require 'evosynth/evolvers/evolver'
26
+ require 'evosynth/evolvers/elitism'
27
+
28
+ require 'evosynth/evolvers/basic/hillclimber'
29
+ require 'evosynth/evolvers/basic/population_hillclimber'
30
+ require 'evosynth/evolvers/basic/genetic_algorithm'
31
+ require 'evosynth/evolvers/basic/steady_state_ga'
32
+ require 'evosynth/evolvers/basic/memetic_algorithm'
33
+
34
+ require 'evosynth/evolvers/evolution_strategies/adaptive_es'
35
+ require 'evosynth/evolvers/evolution_strategies/selfadaptive_es'
36
+ require 'evosynth/evolvers/evolution_strategies/derandomized_es'
37
+
38
+ require 'evosynth/evolvers/local_search/local_search'
39
+
40
+ require 'evosynth/evolvers/coevolutionary/round_robin_coevolutionary'
41
+ require 'evosynth/evolvers/coevolutionary/balanced_coevolutionary'
@@ -0,0 +1,92 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+ module Evolvers
27
+
28
+ # GENETISCHER-ALGORITHMUS (Weicker Page 85)
29
+
30
+ class GeneticAlgorithm
31
+ include EvoSynth::Evolvers::Evolver
32
+
33
+ DEFAULT_SELECTION = EvoSynth::Selections::FitnessProportionalSelection.new
34
+ DEFAULT_RECOMBINATION = EvoSynth::Recombinations::OnePointCrossover.new
35
+ DEFAULT_RECOMBINATION_PROBABILITY = 0.75
36
+ DEFAULT_CHILD_FACTOR = 0.5
37
+
38
+ def initialize(profile)
39
+ init_profile :population,
40
+ :evaluator,
41
+ :mutation,
42
+ :parent_selection => DEFAULT_SELECTION,
43
+ :recombination => DEFAULT_RECOMBINATION,
44
+ :recombination_probability => DEFAULT_RECOMBINATION_PROBABILITY,
45
+ :child_factor => DEFAULT_CHILD_FACTOR
46
+
47
+ use_profile profile
48
+
49
+ @population.each { |individual| @evaluator.calculate_and_set_initial_fitness(individual) }
50
+ end
51
+
52
+ def to_s
53
+ "basic genetic algoritm <mutation: #{@mutation}, parent selection: #{@parent_selection}, recombination: #{@recombination}>"
54
+ end
55
+
56
+ def best_solution
57
+ @population.best
58
+ end
59
+
60
+ def worst_solution
61
+ @population.worst
62
+ end
63
+
64
+ def return_result
65
+ @population
66
+ end
67
+
68
+ def next_generation
69
+ selected_pop = @parent_selection.select(@population, @population.size * @child_factor)
70
+ @population.clear
71
+
72
+ selected_pop.each_index do |index_one|
73
+ index_two = (index_one + 1) % selected_pop.size
74
+
75
+ if EvoSynth.rand < @recombination_probability
76
+ child_one, child_two = @recombination.recombine(selected_pop[index_one], selected_pop[index_two])
77
+ else
78
+ child_one = selected_pop[index_one]
79
+ child_two = selected_pop[index_two]
80
+ end
81
+
82
+ @population.add(@mutation.mutate(child_one))
83
+ @population.add(@mutation.mutate(child_two))
84
+ end
85
+
86
+ @population.each { |individual| @evaluator.calculate_and_set_fitness(individual) }
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,64 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+ module Evolvers
27
+
28
+ # BINÄRES-HILLCLIMBING (Weicker Page 49)
29
+
30
+ class Hillclimber
31
+ include EvoSynth::Evolvers::Evolver
32
+
33
+ def initialize(profile)
34
+ init_profile :individual, :mutation, :evaluator
35
+ use_profile profile
36
+
37
+ @evaluator.calculate_and_set_initial_fitness(@individual)
38
+ end
39
+
40
+ def to_s
41
+ "hillclimber <mutation: #{@mutation}, individual: #{@individual}>"
42
+ end
43
+
44
+ def best_solution
45
+ @individual
46
+ end
47
+
48
+ def worst_solution
49
+ @individual
50
+ end
51
+
52
+ def return_result
53
+ @individual
54
+ end
55
+
56
+ def next_generation
57
+ child = @mutation.mutate(@individual)
58
+ @evaluator.calculate_and_set_fitness(child)
59
+ @individual = child if child > @individual
60
+ end
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,111 @@
1
+ # Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation
5
+ # files (the "Software"), to deal in the Software without
6
+ # restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the
9
+ # Software is furnished to do so, subject to the following
10
+ # conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ # OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ module EvoSynth
26
+ module Evolvers
27
+
28
+ # MEMETISCHER-ALGORITHMUS (Weicker Page 165)
29
+ # see also: http://en.wikipedia.org/wiki/Memetic_algorithm for later improvments
30
+
31
+ class MemeticAlgorithm
32
+ include EvoSynth::Evolvers::Evolver
33
+
34
+ DEFAULT_CHILD_FACTOR = 0.5
35
+ DEFAULT_RECOMBINATION_PROBABILITY = 1.0
36
+ DEFAULT_RECOMBINATION = EvoSynth::Recombinations::KPointCrossover.new(2)
37
+ DEFAULT_INDIVIDUAL_LEARNING_GOAL = ->(gen, best) { gen >= 10 }
38
+ DEFAULT_INDIVIDUAL_LEARNING_PROBABILITY = 0.75
39
+ DEFAULT_SELECTION = EvoSynth::Selections::FitnessProportionalSelection.new
40
+ DEFAULT_SUBEVOLVER_CREATOR = ->(profile) { EvoSynth::Evolvers::LocalSearch.new(profile) }
41
+
42
+ def initialize(profile)
43
+ init_profile :population,
44
+ :evaluator,
45
+ :mutation,
46
+ :recombination => DEFAULT_RECOMBINATION,
47
+ :parent_selection => DEFAULT_SELECTION,
48
+ :enviromental_selection => DEFAULT_SELECTION,
49
+ :child_factor => DEFAULT_CHILD_FACTOR,
50
+ :recombination_probability => DEFAULT_RECOMBINATION_PROBABILITY,
51
+ :subevolver_creator => DEFAULT_SUBEVOLVER_CREATOR,
52
+ :individual_learning_goal => DEFAULT_INDIVIDUAL_LEARNING_GOAL,
53
+ :individual_learning_probability => DEFAULT_INDIVIDUAL_LEARNING_PROBABILITY
54
+
55
+ use_profile profile
56
+
57
+ @population.each { |individual| @evaluator.calculate_and_set_initial_fitness(individual) }
58
+ end
59
+
60
+ def to_s
61
+ "memetic algoritm"
62
+ end
63
+
64
+ def best_solution
65
+ @population.best
66
+ end
67
+
68
+ def worst_solution
69
+ @population.worst
70
+ end
71
+
72
+ def return_result
73
+ @population
74
+ end
75
+
76
+ def next_generation
77
+ selected_population = @parent_selection.select(@population, @population.size * @child_factor)
78
+ child_population = EvoSynth::Population.new
79
+
80
+ selected_population.each_index do |index_one|
81
+ index_two = (index_one + 1) % selected_population.size
82
+
83
+ if EvoSynth.rand < @recombination_probability
84
+ child_one, child_two = @recombination.recombine(selected_population[index_one], selected_population[index_two])
85
+ else
86
+ child_one = selected_population[index_one]
87
+ child_two = selected_population[index_two]
88
+ end
89
+
90
+ child_population.add(@mutation.mutate(child_one))
91
+ child_population.add(@mutation.mutate(child_two))
92
+ end
93
+
94
+ child_population.map! do |child|
95
+ if EvoSynth.rand < @individual_learning_probability
96
+ @profile.individual = child
97
+ subevolver = @subevolver_creator.call(@profile)
98
+ subevolver.run_until &@individual_learning_goal
99
+ else
100
+ child
101
+ end
102
+ end
103
+
104
+ child_population.each { |individual| @evaluator.calculate_and_set_fitness(individual) }
105
+ @population = @enviromental_selection.select(child_population, @population.size)
106
+ end
107
+
108
+ end
109
+
110
+ end
111
+ end