📄 test_results.txt
字号:
contains. The genomes contain points in its nodes. Two
different runs are made: first with the swap subtree mutator,
second with the destructive mutator.
initializing...evolving for 10 generations.............
the ga generated a tree with 37 nodes, 9 levels deep.
initializing...evolving for 10 generations.............
the ga generated a tree with 35 nodes, 12 levels deep.
Example 17
This program illustrates the use of a 2DArrayGenome with
three alleles. It tries to fill a 2D array with alternating
0s and 1s, and -1s at the corners. You will have to run it
for something like 10000 generations to get the perfect score.
evolving...........................................................................................................................................................................................................
the ga generated:
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1
Example 18
This program is designed to compare the GA types. You can
specify steady-state, incremental, or simple GA and tweak any
of the parameters for each of these GA types. The objective
function tries to match a pattern read in from a file.
input pattern:
* * * * * *
* * * *
* *
* * * * * *
* * * * * *
* *
* *
* *
* * * *
* * * * * * * *
* * * *
* * * * * *
the ga generated:
*
* * * * *
* *
* * * *
* * * * * * * *
* * * * * *
* * *
* *
* * *
* * *
* * * * * * * *
* * * *
* * * * * *
the statistics for the run are:
400 # current generation
0.990521 # current convergence
12000 # number of selections since initialization
10776 # number of crossovers since initialization
2707 # number of mutations since initialization
12000 # number of replacements since initialization
11051 # number of genome evaluations since initialization
201 # number of population evaluations since initialization
211 # maximum score since initialization
88 # minimum score since initialization
182.65 # average of all scores ('on-line' performance)
187.255 # average of maximum scores ('off-line' performance)
178.163 # average of minimum scores ('off-line' performance)
112.9 # mean score in initial population
127 # maximum score in initial population
88 # minimum score in initial population
7.63996 # standard deviation of initial population
-1 # diversity of initial population (0=identical,-1=unset)
207.2 # mean score in current population
211 # maximum score in current population
203 # minimum score in current population
2.49689 # standard deviation of current population
-1 # diversity of current population (0=identical,-1=unset)
20 # how far back to look for convergence
10 # how often to record scores
50 # how often to write scores to file
bog.dat # name of file to which scores are written
the objective function was called 11051 times
best of generation data are in 'bog.dat'
Example 19
This program runs the DeJong test problems.
running DeJong function number 1 ...
the ga generated:
5.11 -5.12 -5.12
the statistics for the run are:
400 # current generation
1 # current convergence
3200 # number of selections since initialization
2481 # number of crossovers since initialization
152 # number of mutations since initialization
2800 # number of replacements since initialization
2524 # number of genome evaluations since initialization
401 # number of population evaluations since initialization
78.5409 # maximum score since initialization
0.342654 # minimum score since initialization
77.4228 # average of all scores ('on-line' performance)
78.0059 # average of maximum scores ('off-line' performance)
77.0203 # average of minimum scores ('off-line' performance)
25.943 # mean score in initial population
76.0281 # maximum score in initial population
0.342654 # minimum score in initial population
14.6341 # standard deviation of initial population
-1 # diversity of initial population (0=identical,-1=unset)
78.5409 # mean score in current population
78.5409 # maximum score in current population
78.5409 # minimum score in current population
7.75982e-06 # standard deviation of current population
-1 # diversity of current population (0=identical,-1=unset)
20 # how far back to look for convergence
10 # how often to record scores
50 # how often to write scores to file
bog.dat # name of file to which scores are written
best-of-generation data are in 'bog.dat'
Example 20
Running Holland's Royal Road test problem with a genome that is
240 bits long (16 blocks). The parameters are as follows:
block size: 8
gap size: 7
m*: 4
u*: 1
u: 0.3
v: 0.02
the ga generated:
111111110111000111111110100000111111111010110101001011111010111111110001010110001010011100111111110010101111111110110001100110011000010011101000101101110010101101000111111111101100111111111100101111111111001100101001100111101111111110001011
the highest level achieved was 1
the statistics for the run are:
10000 # current generation
1 # current convergence
2560000 # number of selections since initialization
2305756 # number of crossovers since initialization
613723 # number of mutations since initialization
2560000 # number of replacements since initialization
2360486 # number of genome evaluations since initialization
10001 # number of population evaluations since initialization
5.78 # maximum score since initialization
-0.06 # minimum score since initialization
5.77284 # average of all scores ('on-line' performance)
5.77559 # average of maximum scores ('off-line' performance)
5.77193 # average of minimum scores ('off-line' performance)
0.541289 # mean score in initial population
1.9 # maximum score in initial population
-0.06 # minimum score in initial population
0.303989 # standard deviation of initial population
-1 # diversity of initial population (0=identical,-1=unset)
5.78002 # mean score in current population
5.78 # maximum score in current population
5.78 # minimum score in current population
2.43425e-05 # standard deviation of current population
-1 # diversity of current population (0=identical,-1=unset)
20 # how far back to look for convergence
20 # how often to record scores
100 # how often to write scores to file
bog.dat # name of file to which scores are written
the parameters for the run are:
minimaxi 1
number_of_generations 10000
generations_to_convergence 20
convergence_percentage 0.99
crossover_probability 0.9
mutation_probability 0.001
population_size 512
score_frequency 20
flush_frequency 100
record_diversity 0
score_filename bog.dat
select_scores 2
number_of_best 1
replacement_percentage 0.5
replacement_number 256
Example 21
This example shows various uses of the allele set object
in combination with the real number genome.
running ga number 1 (alternate min/max values)...
the ga generated:
-10 10 -10 10 -10 10 -10 10
running ga number 2 (continuous descending order)...
the ga generated:
0.843399 0.764509 0.665796 0.605345 0.577764 0.528931 0.500041 0.185518
running ga number 3 (discretized descending order)...
the ga generated:
9.5 9 8 7 6 5 4.5 0
running ga number 4 (maximize each gene)...
the ga generated:
10 100 -5 -0.0001 11000
Example 22
This example shows how to derive your own genetic algorithm
class. Here we use a custom, single-child crossover and a
modified replacement strategy with overlapping populations.
initializing...
evolving..........
dumping the function to file...
initial population is in 'pop.initial.dat'
final population is in 'pop.final.dat'
the function is in 'sinusoid.dat'
parameters were:
minimaxi 1
number_of_generations 500
generations_to_convergence 20
convergence_percentage 0.99
crossover_probability 1
mutation_probability 0.01
population_size 100
score_frequency 10
flush_frequency 100
record_diversity 0
score_filename bog.dat
select_scores 255
number_of_best 1
replacement_percentage 0.25
replacement_number 25
Example 23
This program tries to maximize or minimize, depending on the
command line argument that you give it. Use the command-line
argument 'mm -1' to minimize (the default for this example), or
'mm 1' to maximize. The objective function is a simple
sinusoidal.
printing initial population to file...
printing final population to file...
printing function to file...
Example 24
This example illustrates how to derive your own genetic
algorithm. This genetic algorithm does restricted mating and
uses a selector slightly more finicky than a uniform random
selector. The objective function is a simple sinusoidal.
printing population to file 'population.dat'...
printing function to file 'sinusoid.dat'...
Example 25
This example uses a genetic algorithm with multiple populations.
initializing...evolving.......................................................................................................
best individual is: 11111111111111111111111111111111
100 # current generation
1 # current convergence
13000 # number of selections since initialization
12500 # number of crossovers since initialization
12024 # number of mutations since initialization
12500 # number of replacements since initialization
12650 # number of genome evaluations since initialization
1005 # number of population evaluations since initialization
1 # maximum score since initialization
0 # minimum score since initialization
0.163021 # average of all scores ('on-line' performance)
0.984688 # average of maximum scores ('off-line' performance)
0 # average of minimum scores ('off-line' performance)
0.1125 # mean score in initial population
0.6875 # maximum score in initial population
0 # minimum score in initial population
0.255937 # standard deviation of initial population
-1 # diversity of initial population (0=identical,-1=unset)
0.166667 # mean score in current population
1 # maximum score in current population
0 # minimum score in current population
0.379049 # standard deviation of current population
-1 # diversity of current population (0=identical,-1=unset)
20 # how far back to look for convergence
1 # how often to record scores
0 # how often to write scores to file
generations.dat # name of file to which scores are written
Example 26
The Travelling Salesman Problem (TSP) demo program.
initializing...evolving...10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990 1000 the shortest path found is 22.6503
this is the distance from the sequence
5 6 10 14 18 19 15 11 7 3 2 1 20 0 4 8 12 16 17 13 9
1000 # current generation
1 # current convergence
100000 # number of selections since initialization
100000 # number of crossovers since initialization
10014 # number of mutations since initialization
100000 # number of replacements since initialization
100100 # number of genome evaluations since initialization
1001 # number of population evaluations since initialization
64.3227 # maximum score since initialization
22.6503 # minimum score since initialization
23.1627 # average of all scores ('on-line' performance)
23.2063 # average of maximum scores ('off-line' performance)
23.0545 # average of minimum scores ('off-line' performance)
54.0745 # mean score in initial population
64.3227 # maximum score in initial population
44.4397 # minimum score in initial population
4.07012 # standard deviation of initial population
-1 # diversity of initial population (0=identical,-1=unset)
22.6503 # mean score in current population
22.6503 # maximum score in current population
22.6503 # minimum score in current population
2.66312e-06 # standard deviation of current population
-1 # diversity of current population (0=identical,-1=unset)
20 # how far back to look for convergence
100 # how often to record scores
0 # how often to write scores to file
generations.dat # name of file to which scores are written
Example 27
Deterministic crowding demonstration program.
In addition to the standard GAlib command-line arguments,
you can specify one of the four following functions:
0 - modified Himmelblau's function
1 - Foxholes (25)
2 - Schwefel's nasty (1 glob. Max bei (420.96/420.96)
3 - Mexican Hat (optimum at 0,0)
best individual is 2.9991 2.00104
100 # current generation
1 # current convergence
10000 # number of selections since initialization
5000 # number of crossovers since initialization
242 # number of mutations since initialization
1093 # number of replacements since initialization
5100 # number of genome evaluations since initialization
101 # number of population evaluations since initialization
10 # maximum score since initialization
4.71547 # minimum score since initialization
9.89851 # average of all scores ('on-line' performance)
9.99902 # average of maximum scores ('off-line' performance)
9.2808 # average of minimum scores ('off-line' performance)
8.55092 # mean score in initial population
9.97625 # maximum score in initial population
4.71547 # minimum score in initial population
1.31822 # standard deviation of initial population
-1 # diversity of initial population (0=identical,-1=unset)
9.99594 # mean score in current population
10 # maximum score in current population
9.91794 # minimum score in current population
0.0100791 # standard deviation of current population
-1 # diversity of current population (0=identical,-1=unset)
20 # how far back to look for convergence
100 # how often to record scores
0 # how often to write scores to file
generations.dat # name of file to which scores are written
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -