evosynth 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +74 -0
- data/LICENSE +22 -0
- data/README +57 -0
- data/Rakefile +132 -0
- data/TODO +88 -0
- data/docs/FEATURES +111 -0
- data/docs/rdoc/classes/EvoSynth.html +2643 -0
- data/docs/rdoc/classes/EvoSynth/Adjustments.html +119 -0
- data/docs/rdoc/classes/EvoSynth/Adjustments/AdaptiveAdjustment.html +264 -0
- data/docs/rdoc/classes/EvoSynth/Adjustments/PredifinedAdjustment.html +235 -0
- data/docs/rdoc/classes/EvoSynth/ArrayGenome.html +313 -0
- data/docs/rdoc/classes/EvoSynth/BinaryGenome.html +518 -0
- data/docs/rdoc/classes/EvoSynth/Decoder.html +286 -0
- data/docs/rdoc/classes/EvoSynth/Evaluator.html +466 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers.html +469 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/AdaptiveES.html +448 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/BalancedCoevolutionary.html +439 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/DerandomizedES.html +450 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/Evolver.html +125 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/GeneticAlgorithm.html +467 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/Hillclimber.html +343 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch.html +422 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/GreatDelugeAcceptance.html +287 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/HillclimberAcceptance.html +197 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/RecordToRecordTravelAcceptance.html +296 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/SimulatedAnnealingAcceptance.html +286 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/LocalSearch/ThresholdAcceptance.html +287 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/MemeticAlgorithm.html +441 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/PopulationHillclimber.html +375 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/ProfileUsingEvolver.html +205 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/RoundRobinCoevolutionary.html +383 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/RunnableEvolver.html +279 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/RunnableEvolver/Goal.html +193 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/SelfAdaptiveES.html +394 -0
- data/docs/rdoc/classes/EvoSynth/Evolvers/SteadyStateGA.html +390 -0
- data/docs/rdoc/classes/EvoSynth/GlobalRecombinations.html +119 -0
- data/docs/rdoc/classes/EvoSynth/GlobalRecombinations/GlobalArithmeticCrossover.html +204 -0
- data/docs/rdoc/classes/EvoSynth/GlobalRecombinations/GlobalUniformCrossover.html +203 -0
- data/docs/rdoc/classes/EvoSynth/Individual.html +561 -0
- data/docs/rdoc/classes/EvoSynth/MaximizingIndividual.html +266 -0
- data/docs/rdoc/classes/EvoSynth/MetaOperators.html +149 -0
- data/docs/rdoc/classes/EvoSynth/MetaOperators/ConditionalCombinedOperator.html +278 -0
- data/docs/rdoc/classes/EvoSynth/MetaOperators/ProportionalCombinedOperator.html +285 -0
- data/docs/rdoc/classes/EvoSynth/MetaOperators/SequentialCombinedOperator.html +290 -0
- data/docs/rdoc/classes/EvoSynth/MinimizingIndividual.html +266 -0
- data/docs/rdoc/classes/EvoSynth/Mutations.html +251 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/BinaryMutation.html +336 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/EfficientBinaryMutation.html +345 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/ExchangeMutation.html +320 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/Functions.html +160 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/GaussMutation.html +311 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/Identity.html +220 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/InversionMutation.html +231 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/MixingMutation.html +233 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/OneGeneFlipping.html +295 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/SelfAdaptiveGaussMutation.html +347 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/ShiftingMutation.html +229 -0
- data/docs/rdoc/classes/EvoSynth/Mutations/UniformRealMutation.html +264 -0
- data/docs/rdoc/classes/EvoSynth/Output.html +212 -0
- data/docs/rdoc/classes/EvoSynth/Output/CSVExporter.html +211 -0
- data/docs/rdoc/classes/EvoSynth/Output/ConsoleWriter.html +194 -0
- data/docs/rdoc/classes/EvoSynth/Output/GnuPlotExporter.html +235 -0
- data/docs/rdoc/classes/EvoSynth/Output/GruffExporter.html +219 -0
- data/docs/rdoc/classes/EvoSynth/Output/Logger.html +345 -0
- data/docs/rdoc/classes/EvoSynth/Population.html +430 -0
- data/docs/rdoc/classes/EvoSynth/Problems.html +159 -0
- data/docs/rdoc/classes/EvoSynth/Problems/BinaryBenchmarkFuntions.html +258 -0
- data/docs/rdoc/classes/EvoSynth/Problems/FloatBenchmarkFuntions.html +406 -0
- data/docs/rdoc/classes/EvoSynth/Problems/GraphColouring.html +265 -0
- data/docs/rdoc/classes/EvoSynth/Problems/TSP.html +327 -0
- data/docs/rdoc/classes/EvoSynth/Profile.html +324 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations.html +251 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/ArithmeticCrossover.html +286 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/EdgeRecombination.html +203 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/Identity.html +192 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/KPointCrossover.html +286 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/OnePointCrossover.html +211 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/OrderedRecombination.html +206 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/PartiallyMappedCrossover.html +206 -0
- data/docs/rdoc/classes/EvoSynth/Recombinations/UniformCrossover.html +208 -0
- data/docs/rdoc/classes/EvoSynth/Selections.html +174 -0
- data/docs/rdoc/classes/EvoSynth/Selections/FitnessProportionalSelection.html +206 -0
- data/docs/rdoc/classes/EvoSynth/Selections/Identity.html +200 -0
- data/docs/rdoc/classes/EvoSynth/Selections/NStageTournamentSelection.html +273 -0
- data/docs/rdoc/classes/EvoSynth/Selections/RandomSelection.html +192 -0
- data/docs/rdoc/classes/EvoSynth/Selections/RouletteWheelSelection.html +212 -0
- data/docs/rdoc/classes/EvoSynth/Selections/SelectBest.html +206 -0
- data/docs/rdoc/classes/EvoSynth/Selections/TournamentSelection.html +274 -0
- data/docs/rdoc/classes/Examples.html +268 -0
- data/docs/rdoc/classes/Examples/Ants.html +198 -0
- data/docs/rdoc/classes/Examples/Ants/AntMutation.html +381 -0
- data/docs/rdoc/classes/Examples/Ants/Pheromon.html +256 -0
- data/docs/rdoc/classes/Examples/CCGAExample.html +305 -0
- data/docs/rdoc/classes/Examples/CCGAExample/CCGA2BenchmarkEvaluator.html +165 -0
- data/docs/rdoc/classes/Examples/CCGAExample/CCGABenchmarkEvaluator.html +242 -0
- data/docs/rdoc/classes/Examples/CCGAExample/CCGAIndividual.html +181 -0
- data/docs/rdoc/classes/Examples/CMBExample.html +215 -0
- data/docs/rdoc/classes/Examples/CMBExample/CMBEvaluator.html +212 -0
- data/docs/rdoc/classes/Examples/EsExample.html +270 -0
- data/docs/rdoc/classes/Examples/EsExample/BenchmarkEvaluator.html +162 -0
- data/docs/rdoc/classes/Examples/Exporter.html +208 -0
- data/docs/rdoc/classes/Examples/Exporter/ExporterEvaluator.html +196 -0
- data/docs/rdoc/classes/Examples/GraphColouring.html +199 -0
- data/docs/rdoc/classes/Examples/Hacking.html +147 -0
- data/docs/rdoc/classes/Examples/Hacking/HackingEvaluator.html +169 -0
- data/docs/rdoc/classes/Examples/LocalSearch.html +294 -0
- data/docs/rdoc/classes/Examples/LocalSearch/LocalSearchEvaluator.html +198 -0
- data/docs/rdoc/classes/Examples/MaxOnes.html +187 -0
- data/docs/rdoc/classes/Examples/MaxOnes/MaxOnesEvaluator.html +170 -0
- data/docs/rdoc/classes/Examples/Partitionproblem.html +201 -0
- data/docs/rdoc/classes/Examples/Partitionproblem/PartitionEvaluator.html +164 -0
- data/docs/rdoc/classes/Examples/Partitionproblem/PartitionIndividual.html +334 -0
- data/docs/rdoc/classes/Examples/Partitionproblem/PartitionMutation.html +199 -0
- data/docs/rdoc/classes/Examples/Partitionproblem/Testdata.html +294 -0
- data/docs/rdoc/classes/Examples/SPk.html +139 -0
- data/docs/rdoc/classes/Examples/SPk/SPkFitnessEvaluator.html +299 -0
- data/docs/rdoc/classes/Examples/TSP.html +187 -0
- data/docs/rdoc/created.rid +1 -0
- data/docs/rdoc/files/INSTALL.html +253 -0
- data/docs/rdoc/files/LICENSE.html +119 -0
- data/docs/rdoc/files/README.html +235 -0
- data/docs/rdoc/files/docs/FEATURES.html +428 -0
- data/docs/rdoc/files/examples/ants_rb.html +133 -0
- data/docs/rdoc/files/examples/ccga_example_rb.html +129 -0
- data/docs/rdoc/files/examples/cmb_example_rb.html +129 -0
- data/docs/rdoc/files/examples/evolution_strategies_rb.html +129 -0
- data/docs/rdoc/files/examples/exporter_rb.html +129 -0
- data/docs/rdoc/files/examples/graph_colouring_rb.html +129 -0
- data/docs/rdoc/files/examples/hacking_rb.html +129 -0
- data/docs/rdoc/files/examples/local_search_rb.html +129 -0
- data/docs/rdoc/files/examples/max_ones_rb.html +129 -0
- data/docs/rdoc/files/examples/partition_rb.html +131 -0
- data/docs/rdoc/files/examples/spk_rb.html +129 -0
- data/docs/rdoc/files/examples/tsp_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/core/array_genome_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/binary_genome_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/evaluator_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/core/individual_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/maximizing_individual_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/minimizing_individual_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/population_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/profile_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core/randomizer_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/core_rb.html +145 -0
- data/docs/rdoc/files/lib/evosynth/decoder/binary_to_real_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/decoder/gray_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/decoder_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/basic/genetic_algorithm_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/basic/hillclimber_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/basic/memetic_algorithm_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/basic/population_hillclimber_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/basic/steady_state_ga_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/coevolutionary/balanced_coevolutionary_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/elitism_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/evolution_strategies/adaptive_es_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/evolution_strategies/derandomized_es_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/evolution_strategies/selfadaptive_es_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/evolver_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_great_deluge_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_hillclimber_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_record_to_record_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_simulated_annealing_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/local_search/acceptance_threshold_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/local_search/local_search_rb.html +137 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/profile_using_evolver_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/evolvers/runnable_evolver_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/evolvers_rb.html +153 -0
- data/docs/rdoc/files/lib/evosynth/operators/adjustments/adaptive_adjustment_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/adjustments/predefined_adjustment_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/adjustments_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/operators/global_recombinations/global_arithmetic_crossover_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/global_recombinations/global_uniform_crossover_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/global_recombinations_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/operators/meta_operators/conditional_combined_operator_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/meta_operators/proportional_combined_operator_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/meta_operators/sequential_combined_operator_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/meta_operators_rb.html +133 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/binary_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/efficient_binary_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/exchange_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/flip_functions_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/gauss_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/identity_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/inversion_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/mixing_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/one_gene_flipping_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/self_adaptive_gauss_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/shifting_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations/uniform_real_mutation_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/mutations_rb.html +151 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/arithmetic_crossover_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/edge_recombination_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/identity_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/k_point_crossover_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/one_point_crossover_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/ordered_recombination_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/partially_mapped_crossover_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations/uniform_crossover_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/recombinations_rb.html +143 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/best_selection_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/fitness_proportional_selection_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/identity_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/n_stage_tournament_selection_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/random_selection_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/roulette_wheel_selection_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections/tournament_selection_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/operators/selections_rb.html +141 -0
- data/docs/rdoc/files/lib/evosynth/operators_rb.html +139 -0
- data/docs/rdoc/files/lib/evosynth/output/console_writer_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/output/exporter/csv_exporter_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/output/exporter/gnuplot_exporter_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/output/exporter/gruff_exporter_rb.html +131 -0
- data/docs/rdoc/files/lib/evosynth/output/exporter_rb.html +133 -0
- data/docs/rdoc/files/lib/evosynth/output/factory_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/output/logger_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/output_rb.html +135 -0
- data/docs/rdoc/files/lib/evosynth/problems/binary_benchmark_functions_rb.html +119 -0
- data/docs/rdoc/files/lib/evosynth/problems/float_benchmark_functions_rb.html +1630 -0
- data/docs/rdoc/files/lib/evosynth/problems/graph_colouring_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/problems/tsp_rb.html +129 -0
- data/docs/rdoc/files/lib/evosynth/problems_rb.html +135 -0
- data/docs/rdoc/files/lib/evosynth_rb.html +139 -0
- data/docs/rdoc/fr_class_index.html +245 -0
- data/docs/rdoc/fr_file_index.html +233 -0
- data/docs/rdoc/fr_method_index.html +661 -0
- data/docs/rdoc/index.html +21 -0
- data/docs/rdoc/rdoc-style.css +299 -0
- data/examples/ants.rb +237 -0
- data/examples/ccga_example.rb +150 -0
- data/examples/cmb_example.rb +117 -0
- data/examples/evolution_strategies.rb +84 -0
- data/examples/exporter.rb +90 -0
- data/examples/graph_colouring.rb +72 -0
- data/examples/hacking.rb +62 -0
- data/examples/local_search.rb +109 -0
- data/examples/max_ones.rb +83 -0
- data/examples/partition.rb +172 -0
- data/examples/spk.rb +106 -0
- data/examples/tsp.rb +83 -0
- data/lib/evosynth.rb +32 -0
- data/lib/evosynth/core.rb +33 -0
- data/lib/evosynth/core/array_genome.rb +77 -0
- data/lib/evosynth/core/binary_genome.rb +156 -0
- data/lib/evosynth/core/evaluator.rb +109 -0
- data/lib/evosynth/core/individual.rb +92 -0
- data/lib/evosynth/core/maximizing_individual.rb +71 -0
- data/lib/evosynth/core/minimizing_individual.rb +71 -0
- data/lib/evosynth/core/population.rb +120 -0
- data/lib/evosynth/core/profile.rb +110 -0
- data/lib/evosynth/core/randomizer.rb +73 -0
- data/lib/evosynth/decoder.rb +33 -0
- data/lib/evosynth/decoder/binary_to_real.rb +57 -0
- data/lib/evosynth/decoder/gray.rb +54 -0
- data/lib/evosynth/evolvers.rb +41 -0
- data/lib/evosynth/evolvers/basic/genetic_algorithm.rb +92 -0
- data/lib/evosynth/evolvers/basic/hillclimber.rb +64 -0
- data/lib/evosynth/evolvers/basic/memetic_algorithm.rb +111 -0
- data/lib/evosynth/evolvers/basic/population_hillclimber.rb +69 -0
- data/lib/evosynth/evolvers/basic/steady_state_ga.rb +85 -0
- data/lib/evosynth/evolvers/coevolutionary/balanced_coevolutionary.rb +125 -0
- data/lib/evosynth/evolvers/coevolutionary/round_robin_coevolutionary.rb +87 -0
- data/lib/evosynth/evolvers/elitism.rb +108 -0
- data/lib/evosynth/evolvers/evolution_strategies/adaptive_es.rb +104 -0
- data/lib/evosynth/evolvers/evolution_strategies/derandomized_es.rb +120 -0
- data/lib/evosynth/evolvers/evolution_strategies/selfadaptive_es.rb +82 -0
- data/lib/evosynth/evolvers/evolver.rb +43 -0
- data/lib/evosynth/evolvers/local_search/acceptance_great_deluge.rb +60 -0
- data/lib/evosynth/evolvers/local_search/acceptance_hillclimber.rb +47 -0
- data/lib/evosynth/evolvers/local_search/acceptance_record_to_record.rb +69 -0
- data/lib/evosynth/evolvers/local_search/acceptance_simulated_annealing.rb +59 -0
- data/lib/evosynth/evolvers/local_search/acceptance_threshold.rb +60 -0
- data/lib/evosynth/evolvers/local_search/local_search.rb +74 -0
- data/lib/evosynth/evolvers/profile_using_evolver.rb +77 -0
- data/lib/evosynth/evolvers/runnable_evolver.rb +89 -0
- data/lib/evosynth/operators.rb +30 -0
- data/lib/evosynth/operators/adjustments.rb +26 -0
- data/lib/evosynth/operators/adjustments/adaptive_adjustment.rb +55 -0
- data/lib/evosynth/operators/adjustments/predefined_adjustment.rb +46 -0
- data/lib/evosynth/operators/global_recombinations.rb +26 -0
- data/lib/evosynth/operators/global_recombinations/global_arithmetic_crossover.rb +50 -0
- data/lib/evosynth/operators/global_recombinations/global_uniform_crossover.rb +49 -0
- data/lib/evosynth/operators/meta_operators.rb +36 -0
- data/lib/evosynth/operators/meta_operators/conditional_combined_operator.rb +65 -0
- data/lib/evosynth/operators/meta_operators/proportional_combined_operator.rb +84 -0
- data/lib/evosynth/operators/meta_operators/sequential_combined_operator.rb +73 -0
- data/lib/evosynth/operators/mutations.rb +47 -0
- data/lib/evosynth/operators/mutations/binary_mutation.rb +100 -0
- data/lib/evosynth/operators/mutations/efficient_binary_mutation.rb +105 -0
- data/lib/evosynth/operators/mutations/exchange_mutation.rb +107 -0
- data/lib/evosynth/operators/mutations/flip_functions.rb +45 -0
- data/lib/evosynth/operators/mutations/gauss_mutation.rb +65 -0
- data/lib/evosynth/operators/mutations/identity.rb +62 -0
- data/lib/evosynth/operators/mutations/inversion_mutation.rb +73 -0
- data/lib/evosynth/operators/mutations/mixing_mutation.rb +75 -0
- data/lib/evosynth/operators/mutations/one_gene_flipping.rb +89 -0
- data/lib/evosynth/operators/mutations/self_adaptive_gauss_mutation.rb +73 -0
- data/lib/evosynth/operators/mutations/shifting_mutation.rb +88 -0
- data/lib/evosynth/operators/mutations/uniform_real_mutation.rb +59 -0
- data/lib/evosynth/operators/recombinations.rb +48 -0
- data/lib/evosynth/operators/recombinations/arithmetic_crossover.rb +67 -0
- data/lib/evosynth/operators/recombinations/edge_recombination.rb +108 -0
- data/lib/evosynth/operators/recombinations/identity.rb +42 -0
- data/lib/evosynth/operators/recombinations/k_point_crossover.rb +81 -0
- data/lib/evosynth/operators/recombinations/one_point_crossover.rb +56 -0
- data/lib/evosynth/operators/recombinations/ordered_recombination.rb +75 -0
- data/lib/evosynth/operators/recombinations/partially_mapped_crossover.rb +102 -0
- data/lib/evosynth/operators/recombinations/uniform_crossover.rb +54 -0
- data/lib/evosynth/operators/selections.rb +31 -0
- data/lib/evosynth/operators/selections/best_selection.rb +54 -0
- data/lib/evosynth/operators/selections/fitness_proportional_selection.rb +83 -0
- data/lib/evosynth/operators/selections/identity.rb +48 -0
- data/lib/evosynth/operators/selections/n_stage_tournament_selection.rb +84 -0
- data/lib/evosynth/operators/selections/random_selection.rb +44 -0
- data/lib/evosynth/operators/selections/roulette_wheel_selection.rb +54 -0
- data/lib/evosynth/operators/selections/tournament_selection.rb +71 -0
- data/lib/evosynth/output.rb +28 -0
- data/lib/evosynth/output/console_writer.rb +45 -0
- data/lib/evosynth/output/exporter.rb +27 -0
- data/lib/evosynth/output/exporter/csv_exporter.rb +62 -0
- data/lib/evosynth/output/exporter/gnuplot_exporter.rb +81 -0
- data/lib/evosynth/output/exporter/gruff_exporter.rb +70 -0
- data/lib/evosynth/output/factory.rb +38 -0
- data/lib/evosynth/output/logger.rb +83 -0
- data/lib/evosynth/problems.rb +37 -0
- data/lib/evosynth/problems/binary_benchmark_functions.rb +74 -0
- data/lib/evosynth/problems/float_benchmark_functions.rb +99 -0
- data/lib/evosynth/problems/graph_colouring.rb +89 -0
- data/lib/evosynth/problems/tsp.rb +88 -0
- data/test/benchmark/decoder_benchmark.rb +75 -0
- data/test/benchmark/mutation_benchmark.rb +88 -0
- data/test/benchmark/recombination_benchmark.rb +58 -0
- data/test/benchmark/selection_benchmark.rb +52 -0
- data/test/core/tc_array_genome.rb +154 -0
- data/test/core/tc_binary_genome.rb +160 -0
- data/test/core/tc_population.rb +154 -0
- data/test/core/tc_profile.rb +75 -0
- data/test/core/tc_randomizer.rb +165 -0
- data/test/coverage.rb +43 -0
- data/test/decoder/tc_binary_to_real.rb +52 -0
- data/test/decoder/tc_gray.rb +107 -0
- data/test/operators/adjustments/tc_adaptive_adjustment.rb +63 -0
- data/test/operators/adjustments/tc_predefined_adjustment.rb +49 -0
- data/test/operators/global_recombinations/tc_global_arithmetic_crossover.rb +78 -0
- data/test/operators/global_recombinations/tc_global_uniform_crossover.rb +90 -0
- data/test/operators/meta_operators/tc_conditional_combined_operator.rb +66 -0
- data/test/operators/meta_operators/tc_proportional_combined_operator.rb +167 -0
- data/test/operators/meta_operators/tc_sequential_combined_operator.rb +98 -0
- data/test/operators/mutations/tc_binary_mutation.rb +73 -0
- data/test/operators/mutations/tc_efficient_binary_mutation.rb +73 -0
- data/test/operators/mutations/tc_exchange_mutation.rb +127 -0
- data/test/operators/mutations/tc_gauss_mutation.rb +130 -0
- data/test/operators/mutations/tc_identity_mutation.rb +64 -0
- data/test/operators/mutations/tc_inversion_mutation.rb +70 -0
- data/test/operators/mutations/tc_mixing_mutation.rb +73 -0
- data/test/operators/mutations/tc_one_gene_flipping.rb +109 -0
- data/test/operators/mutations/tc_self_adaptive_gauss_mutation.rb +72 -0
- data/test/operators/mutations/tc_shifting_muation.rb +73 -0
- data/test/operators/mutations/tc_uniform_real_mutation.rb +65 -0
- data/test/operators/recombinations/tc_arithmetic_crossover.rb +79 -0
- data/test/operators/recombinations/tc_edge_recombination.rb +76 -0
- data/test/operators/recombinations/tc_identity_recombination.rb +81 -0
- data/test/operators/recombinations/tc_k_point_crossover.rb +81 -0
- data/test/operators/recombinations/tc_one_point_crossover.rb +80 -0
- data/test/operators/recombinations/tc_ordered_recombination.rb +76 -0
- data/test/operators/recombinations/tc_partially_mapped_crossover.rb +91 -0
- data/test/operators/recombinations/tc_uniform_crossover.rb +84 -0
- data/test/operators/selections/tc_best_selection.rb +85 -0
- data/test/operators/selections/tc_fitness_proportional_selection.rb +78 -0
- data/test/operators/selections/tc_identity.rb +91 -0
- data/test/operators/selections/tc_n_stage_tournament.rb +78 -0
- data/test/operators/selections/tc_random_selection.rb +70 -0
- data/test/operators/selections/tc_roulette_wheel_selection.rb +78 -0
- data/test/operators/selections/tc_tournament_selection.rb +83 -0
- data/test/problems/tc_binary_benchmark_functions.rb +126 -0
- data/test/problems/tc_float_benchmark_functions.rb +100 -0
- data/test/test_util/test_helper.rb +128 -0
- data/test/ts_adjustments.rb +26 -0
- data/test/ts_core.rb +29 -0
- data/test/ts_decoder.rb +26 -0
- data/test/ts_global_recombinations.rb +26 -0
- data/test/ts_meta_operators.rb +27 -0
- data/test/ts_mutations.rb +35 -0
- data/test/ts_problems.rb +26 -0
- data/test/ts_recombinations.rb +32 -0
- data/test/ts_selections.rb +31 -0
- data/testdata/README +4 -0
- data/testdata/bays29.tsp +68 -0
- data/testdata/myciel4.col +77 -0
- metadata +552 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<!--
|
5
|
+
|
6
|
+
EvoSynth Documentation
|
7
|
+
|
8
|
+
-->
|
9
|
+
<head>
|
10
|
+
<title>EvoSynth Documentation</title>
|
11
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
12
|
+
</head>
|
13
|
+
<frameset rows="20%, 80%">
|
14
|
+
<frameset cols="25%,35%,45%">
|
15
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
16
|
+
<frame src="fr_class_index.html" name="Classes" />
|
17
|
+
<frame src="fr_method_index.html" name="Methods" />
|
18
|
+
</frameset>
|
19
|
+
<frame src="files/README.html" name="docwin" />
|
20
|
+
</frameset>
|
21
|
+
</html>
|
@@ -0,0 +1,299 @@
|
|
1
|
+
body {
|
2
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
3
|
+
font-size: 90%;
|
4
|
+
margin: 0;
|
5
|
+
margin-left: 40px;
|
6
|
+
padding: 0;
|
7
|
+
background: white;
|
8
|
+
color: black;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1, h2, h3, h4 {
|
12
|
+
margin: 0;
|
13
|
+
background: transparent;
|
14
|
+
}
|
15
|
+
|
16
|
+
h1 {
|
17
|
+
font-size: 150%;
|
18
|
+
}
|
19
|
+
|
20
|
+
h2,h3,h4 {
|
21
|
+
margin-top: 1em;
|
22
|
+
}
|
23
|
+
|
24
|
+
:link, :visited {
|
25
|
+
background: #eef;
|
26
|
+
color: #039;
|
27
|
+
text-decoration: none;
|
28
|
+
}
|
29
|
+
|
30
|
+
:link:hover, :visited:hover {
|
31
|
+
background: #039;
|
32
|
+
color: #eef;
|
33
|
+
}
|
34
|
+
|
35
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
36
|
+
td > :link, td > :visited {
|
37
|
+
background: transparent;
|
38
|
+
color: #039;
|
39
|
+
text-decoration: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
/* and inside a section title */
|
43
|
+
.section-title > :link, .section-title > :visited {
|
44
|
+
background: transparent;
|
45
|
+
color: #eee;
|
46
|
+
text-decoration: none;
|
47
|
+
}
|
48
|
+
|
49
|
+
/* === Structural elements =================================== */
|
50
|
+
|
51
|
+
.index {
|
52
|
+
margin: 0;
|
53
|
+
margin-left: -40px;
|
54
|
+
padding: 0;
|
55
|
+
font-size: 90%;
|
56
|
+
}
|
57
|
+
|
58
|
+
.index :link, .index :visited {
|
59
|
+
margin-left: 0.7em;
|
60
|
+
}
|
61
|
+
|
62
|
+
.index .section-bar {
|
63
|
+
margin-left: 0px;
|
64
|
+
padding-left: 0.7em;
|
65
|
+
background: #ccc;
|
66
|
+
font-size: small;
|
67
|
+
}
|
68
|
+
|
69
|
+
#classHeader, #fileHeader {
|
70
|
+
width: auto;
|
71
|
+
color: white;
|
72
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
73
|
+
margin: 0;
|
74
|
+
margin-left: -40px;
|
75
|
+
border-bottom: 3px solid #006;
|
76
|
+
}
|
77
|
+
|
78
|
+
#classHeader :link, #fileHeader :link,
|
79
|
+
#classHeader :visited, #fileHeader :visited {
|
80
|
+
background: inherit;
|
81
|
+
color: white;
|
82
|
+
}
|
83
|
+
|
84
|
+
#classHeader td, #fileHeader td {
|
85
|
+
background: inherit;
|
86
|
+
color: white;
|
87
|
+
}
|
88
|
+
|
89
|
+
#fileHeader {
|
90
|
+
background: #057;
|
91
|
+
}
|
92
|
+
|
93
|
+
#classHeader {
|
94
|
+
background: #048;
|
95
|
+
}
|
96
|
+
|
97
|
+
.class-name-in-header {
|
98
|
+
font-size: 180%;
|
99
|
+
font-weight: bold;
|
100
|
+
}
|
101
|
+
|
102
|
+
#bodyContent {
|
103
|
+
padding: 0 1.5em 0 1.5em;
|
104
|
+
}
|
105
|
+
|
106
|
+
#description {
|
107
|
+
padding: 0.5em 1.5em;
|
108
|
+
background: #efefef;
|
109
|
+
border: 1px dotted #999;
|
110
|
+
}
|
111
|
+
|
112
|
+
#description h1, #description h2, #description h3,
|
113
|
+
#description h4, #description h5, #description h6 {
|
114
|
+
color: #125;
|
115
|
+
background: transparent;
|
116
|
+
}
|
117
|
+
|
118
|
+
#validator-badges {
|
119
|
+
text-align: center;
|
120
|
+
}
|
121
|
+
|
122
|
+
#validator-badges img {
|
123
|
+
border: 0;
|
124
|
+
}
|
125
|
+
|
126
|
+
#copyright {
|
127
|
+
color: #333;
|
128
|
+
background: #efefef;
|
129
|
+
font: 0.75em sans-serif;
|
130
|
+
margin-top: 5em;
|
131
|
+
margin-bottom: 0;
|
132
|
+
padding: 0.5em 2em;
|
133
|
+
}
|
134
|
+
|
135
|
+
/* === Classes =================================== */
|
136
|
+
|
137
|
+
table.header-table {
|
138
|
+
color: white;
|
139
|
+
font-size: small;
|
140
|
+
}
|
141
|
+
|
142
|
+
.type-note {
|
143
|
+
font-size: small;
|
144
|
+
color: #dedede;
|
145
|
+
}
|
146
|
+
|
147
|
+
.section-bar {
|
148
|
+
color: #333;
|
149
|
+
border-bottom: 1px solid #999;
|
150
|
+
margin-left: -20px;
|
151
|
+
}
|
152
|
+
|
153
|
+
.section-title {
|
154
|
+
background: #79a;
|
155
|
+
color: #eee;
|
156
|
+
padding: 3px;
|
157
|
+
margin-top: 2em;
|
158
|
+
margin-left: -30px;
|
159
|
+
border: 1px solid #999;
|
160
|
+
}
|
161
|
+
|
162
|
+
.top-aligned-row {
|
163
|
+
vertical-align: top
|
164
|
+
}
|
165
|
+
|
166
|
+
.bottom-aligned-row {
|
167
|
+
vertical-align: bottom
|
168
|
+
}
|
169
|
+
|
170
|
+
#diagram img {
|
171
|
+
border: 0;
|
172
|
+
}
|
173
|
+
|
174
|
+
/* --- Context section classes ----------------------- */
|
175
|
+
|
176
|
+
.context-row { }
|
177
|
+
|
178
|
+
.context-item-name {
|
179
|
+
font-family: monospace;
|
180
|
+
font-weight: bold;
|
181
|
+
color: black;
|
182
|
+
}
|
183
|
+
|
184
|
+
.context-item-value {
|
185
|
+
font-size: small;
|
186
|
+
color: #448;
|
187
|
+
}
|
188
|
+
|
189
|
+
.context-item-desc {
|
190
|
+
color: #333;
|
191
|
+
padding-left: 2em;
|
192
|
+
}
|
193
|
+
|
194
|
+
/* --- Method classes -------------------------- */
|
195
|
+
|
196
|
+
.method-detail {
|
197
|
+
background: #efefef;
|
198
|
+
padding: 0;
|
199
|
+
margin-top: 0.5em;
|
200
|
+
margin-bottom: 1em;
|
201
|
+
border: 1px dotted #ccc;
|
202
|
+
}
|
203
|
+
|
204
|
+
.method-heading {
|
205
|
+
color: black;
|
206
|
+
background: #ccc;
|
207
|
+
border-bottom: 1px solid #666;
|
208
|
+
padding: 0.2em 0.5em 0 0.5em;
|
209
|
+
}
|
210
|
+
|
211
|
+
.method-signature {
|
212
|
+
color: black;
|
213
|
+
background: inherit;
|
214
|
+
}
|
215
|
+
|
216
|
+
.method-name {
|
217
|
+
font-weight: bold;
|
218
|
+
}
|
219
|
+
|
220
|
+
.method-args {
|
221
|
+
font-style: italic;
|
222
|
+
}
|
223
|
+
|
224
|
+
.method-description {
|
225
|
+
padding: 0 0.5em 0 0.5em;
|
226
|
+
}
|
227
|
+
|
228
|
+
/* --- Source code sections -------------------- */
|
229
|
+
|
230
|
+
:link.source-toggle, :visited.source-toggle {
|
231
|
+
font-size: 90%;
|
232
|
+
}
|
233
|
+
|
234
|
+
div.method-source-code {
|
235
|
+
background: #262626;
|
236
|
+
color: #ffdead;
|
237
|
+
margin: 1em;
|
238
|
+
padding: 0.5em;
|
239
|
+
border: 1px dashed #999;
|
240
|
+
overflow: auto;
|
241
|
+
}
|
242
|
+
|
243
|
+
div.method-source-code pre {
|
244
|
+
color: #ffdead;
|
245
|
+
}
|
246
|
+
|
247
|
+
/* --- Ruby keyword styles --------------------- */
|
248
|
+
|
249
|
+
.standalone-code {
|
250
|
+
background: #221111;
|
251
|
+
color: #ffdead;
|
252
|
+
overflow: auto;
|
253
|
+
}
|
254
|
+
|
255
|
+
.ruby-constant {
|
256
|
+
color: #7fffd4;
|
257
|
+
background: transparent;
|
258
|
+
}
|
259
|
+
|
260
|
+
.ruby-keyword {
|
261
|
+
color: #00ffff;
|
262
|
+
background: transparent;
|
263
|
+
}
|
264
|
+
|
265
|
+
.ruby-ivar {
|
266
|
+
color: #eedd82;
|
267
|
+
background: transparent;
|
268
|
+
}
|
269
|
+
|
270
|
+
.ruby-operator {
|
271
|
+
color: #00ffee;
|
272
|
+
background: transparent;
|
273
|
+
}
|
274
|
+
|
275
|
+
.ruby-identifier {
|
276
|
+
color: #ffdead;
|
277
|
+
background: transparent;
|
278
|
+
}
|
279
|
+
|
280
|
+
.ruby-node {
|
281
|
+
color: #ffa07a;
|
282
|
+
background: transparent;
|
283
|
+
}
|
284
|
+
|
285
|
+
.ruby-comment {
|
286
|
+
color: #b22222;
|
287
|
+
font-weight: bold;
|
288
|
+
background: transparent;
|
289
|
+
}
|
290
|
+
|
291
|
+
.ruby-regexp {
|
292
|
+
color: #ffa07a;
|
293
|
+
background: transparent;
|
294
|
+
}
|
295
|
+
|
296
|
+
.ruby-value {
|
297
|
+
color: #7fffd4;
|
298
|
+
background: transparent;
|
299
|
+
}
|
data/examples/ants.rb
ADDED
@@ -0,0 +1,237 @@
|
|
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'
|
26
|
+
require 'set'
|
27
|
+
require 'matrix'
|
28
|
+
|
29
|
+
|
30
|
+
module Examples
|
31
|
+
module Ants
|
32
|
+
|
33
|
+
class Pheromon
|
34
|
+
attr_accessor :matrix
|
35
|
+
|
36
|
+
def initialize(node_count, evaporation_weight = 0.7)
|
37
|
+
@evaporation_weight = evaporation_weight
|
38
|
+
@matrix = Matrix.zero(node_count).collect { |i| i + 1.0 }
|
39
|
+
end
|
40
|
+
|
41
|
+
def update(ants)
|
42
|
+
@matrix = @matrix.collect { |i| i * @evaporation_weight }
|
43
|
+
columns = @matrix.column_vectors
|
44
|
+
columns.map! { |col| col.to_a }
|
45
|
+
|
46
|
+
ants.each do |ant|
|
47
|
+
ant.genome.each_with_index do |node, index|
|
48
|
+
break if (index + 1) >= ant.genome.size
|
49
|
+
columns[node][ant.genome[index + 1]] += 100.0 / ant.fitness
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
columns.map! { |col| Vector.elements(col) }
|
54
|
+
@matrix = Matrix.columns(columns)
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_s
|
58
|
+
@matrix.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
# TODO: this mutation should be refactored
|
64
|
+
|
65
|
+
class AntMutation
|
66
|
+
|
67
|
+
def initialize(tsp, pheromon, start, exploration_weight = 0.5, distance_weight = 2.0)
|
68
|
+
@tsp = tsp
|
69
|
+
@pheromon = pheromon
|
70
|
+
@start = start
|
71
|
+
@exploration_weight = exploration_weight
|
72
|
+
@distance_weight = distance_weight
|
73
|
+
end
|
74
|
+
|
75
|
+
def mutate(ant)
|
76
|
+
mutated = ant.deep_clone
|
77
|
+
mutated.genome[1..mutated.genome.size-1] = []
|
78
|
+
mutated.genome = rand_route
|
79
|
+
mutated
|
80
|
+
end
|
81
|
+
|
82
|
+
def to_s
|
83
|
+
"simple ant mutation <start: #{@start}, exploration_weight: #{@exploration_weight}>"
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_next_node(existing_route, pheromon, last_node)
|
87
|
+
best_pr = 0.0
|
88
|
+
best_node = nil
|
89
|
+
route = existing_route.to_set
|
90
|
+
raise "shit!" if last_node.nil?
|
91
|
+
distances = @tsp.matrix.row(last_node).to_a
|
92
|
+
|
93
|
+
distances.each_with_index do |distance, node_index|
|
94
|
+
unless route.include?(node_index)
|
95
|
+
pr = pheromon.matrix[last_node, node_index]
|
96
|
+
pr *= (1.0 / distance) ** @distance_weight
|
97
|
+
pr /= get_sum(existing_route, pheromon, last_node)
|
98
|
+
pr *= EvoSynth.rand
|
99
|
+
else
|
100
|
+
pr = 0.0
|
101
|
+
end
|
102
|
+
|
103
|
+
if pr >= best_pr
|
104
|
+
best_node = node_index
|
105
|
+
best_pr = pr
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
best_node
|
110
|
+
end
|
111
|
+
|
112
|
+
def get_sum(existing_route, pheromon, last_node)
|
113
|
+
sum = 0.0
|
114
|
+
route = existing_route.to_set
|
115
|
+
distances = @tsp.matrix.row(last_node).to_a
|
116
|
+
|
117
|
+
distances.each_with_index do |distance, node_index|
|
118
|
+
next if route.include?(node_index)
|
119
|
+
sum += pheromon.matrix[last_node, node_index] * (distance ** @distance_weight)
|
120
|
+
end
|
121
|
+
|
122
|
+
sum
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_nearest_node(existing_route, last_node)
|
126
|
+
best_distance = Float::MAX
|
127
|
+
best_node = nil
|
128
|
+
route = existing_route.to_set
|
129
|
+
raise "shit-2!" if last_node.nil?
|
130
|
+
distances = @tsp.matrix.row(last_node).to_a
|
131
|
+
|
132
|
+
distances.each_with_index do |distance_to_node, node_index|
|
133
|
+
next if route.include?(node_index)
|
134
|
+
|
135
|
+
if best_distance > distance_to_node
|
136
|
+
best_distance = distance_to_node
|
137
|
+
best_node = node_index
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
best_node
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def rand_route
|
147
|
+
genome = EvoSynth::ArrayGenome.new
|
148
|
+
genome << @start
|
149
|
+
|
150
|
+
(@tsp.size - 1).times do
|
151
|
+
puts genome.inspect if genome.last.nil?
|
152
|
+
|
153
|
+
if EvoSynth.rand < @exploration_weight
|
154
|
+
genome << get_next_node(genome, @pheromon, genome.last)
|
155
|
+
else
|
156
|
+
genome << get_nearest_node(genome, genome.last)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
genome
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
def Ants.evolver_profile(tsp, pheromon)
|
167
|
+
ant_mutation = Ants::AntMutation.new(tsp, pheromon, 1, 0.2)
|
168
|
+
|
169
|
+
population = EvoSynth::Population.new(10) do
|
170
|
+
ant = EvoSynth::MinimizingIndividual.new(EvoSynth::ArrayGenome.new)
|
171
|
+
ant_mutation.mutate(ant)
|
172
|
+
end
|
173
|
+
|
174
|
+
combined_mutation = EvoSynth::MetaOperators::ProportionalCombinedOperator.new
|
175
|
+
combined_mutation.add(EvoSynth::Mutations::InversionMutation.new, 0.25)
|
176
|
+
combined_mutation.add(ant_mutation, 0.75)
|
177
|
+
|
178
|
+
EvoSynth::Profile.new(
|
179
|
+
:mutation => combined_mutation,
|
180
|
+
:parent_selection => EvoSynth::Selections::FitnessProportionalSelection.new,
|
181
|
+
:population => population,
|
182
|
+
:recombination => EvoSynth::Recombinations::PartiallyMappedCrossover.new,
|
183
|
+
:evaluator => tsp
|
184
|
+
)
|
185
|
+
end
|
186
|
+
|
187
|
+
# try to load the testcase
|
188
|
+
|
189
|
+
tsp = nil
|
190
|
+
begin
|
191
|
+
tsp = EvoSynth::Problems::TSP.new('testdata/bays29.tsp')
|
192
|
+
rescue
|
193
|
+
puts "Could not load test data. Please see testdata/README for instructions..."
|
194
|
+
exit(0)
|
195
|
+
end
|
196
|
+
puts "read testdata/bays29.tsp - matrix contains #{tsp.size} nodes..."
|
197
|
+
|
198
|
+
# we need to "get into" the used evolver to update the pheromon
|
199
|
+
# each iteration of the
|
200
|
+
|
201
|
+
PHEROMON = Ants::Pheromon.new(tsp.size)
|
202
|
+
|
203
|
+
class EvoSynth::Evolvers::GeneticAlgorithm
|
204
|
+
alias :ant_next_generation :next_generation
|
205
|
+
|
206
|
+
def next_generation
|
207
|
+
ant_next_generation
|
208
|
+
PHEROMON.update(@population);
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# setup the profile, optimal solution and run the evolver:
|
213
|
+
|
214
|
+
profile = Ants.evolver_profile(tsp, PHEROMON)
|
215
|
+
|
216
|
+
opt_tour = [1,28,6,12,9,5,26,29,3,2,20,10,4,15,18,17,14,22,11,19,25,7,23,27,8,24,16,13,21].map! { |num| num -= 1 }
|
217
|
+
optimal = EvoSynth::MinimizingIndividual.new(EvoSynth::ArrayGenome.new(opt_tour))
|
218
|
+
profile.evaluator.calculate_and_set_fitness(optimal)
|
219
|
+
puts "Optimal Individual for this problem: #{optimal}"
|
220
|
+
|
221
|
+
puts "Best Individual before evolution: #{profile.population.best}"
|
222
|
+
|
223
|
+
evolver = EvoSynth::Evolvers::GeneticAlgorithm.new(profile)
|
224
|
+
EvoSynth::Evolvers.add_weak_elistism(evolver)
|
225
|
+
evolver.add_observer(EvoSynth::Output.create_console_logger(25,
|
226
|
+
"generations" => ->{ evolver.generations_computed },
|
227
|
+
"bestfitness" => ->{ evolver.best_solution.fitness },
|
228
|
+
"worstfitness" => ->{ evolver.worst_solution.fitness }
|
229
|
+
))
|
230
|
+
|
231
|
+
result = evolver.run_until_generations_reached(500)
|
232
|
+
puts evolver
|
233
|
+
|
234
|
+
puts "\nBest Individual after evolution: #{result.best}"
|
235
|
+
puts "oooops" if result.best.genome.size != result.best.genome.uniq.size
|
236
|
+
end
|
237
|
+
end
|