Step |
Procedure |
1 |
ANJI requires JRE
(Java Runtime Environment) version 1.4.2 or greater installed.
The appropriate JRE can be downloaded here:
http://java.sun.com/j2se/downloads |
2 |
Make sure that the
java executable is in your system PATH. |
3 |
Extract files from
anji_2_01.zip into a local directory. This will create
a new directory named anji_2_01/. |
4 |
Windows:
1) Open a command shell (from the Start menu select Run...,
type "cmd", select OK).
2) Navigate to the anji_2_01/ directory.
3) Type "evolve.bat xor.properties" and press Enter.
Unix:
1) Open a command shell.
2) Navigate to the anji_2_01/ directory.
3) Type "evolve.sh xor.properties" and press Enter. |
5 |
The format of the
output is determined by the log4j configuration in xor.properties.
For more information regarding log4j, visit:
http://logging.apache.org/log4j/docs/manual.html
The default display property for log4j is to print to
screen. ANJI will first display copyright and version, then print all
the properties for the run. Then, for each generation, information such
as the following will be displayed:
INFO Generation 0: start
INFO connection->neuron id map size == 2
INFO neurons->connection id map size == 16
INFO species count: 3
INFO # chromosomes with max fitness: 0
INFO champ: id=98 score=0.5592439375 size=7
INFO Generation 0: end [10:10:55 - 10:10:56] [391]
|
The id map
info indicates the number of unique topological features for that generation.
With very high mutation rates, these mappings can get very large and cause
memory overloads.
The species count indicates the number of species in
that generation. The next line indicates how many chromosomes have attained
maximum fitness. The next line displays the size and
chromosome id of the best performer in this generation,
its score as computed by the fitness function (in this case the real mean
squared error for the network outputs based on the four sets of XOR inputs).
The last line indicates the time range and length of the generation in
milliseconds.
The information that displays or prints to file for a run is configurable.
Again, visit the link in this section for more information.
|
6 |
Once a solution has
been found, you should see output similar to the following:
INFO Generation 30: start
INFO connection->neuron id map size == 23
INFO neurons->connection id map size == 191
INFO species count: 35
INFO max: id=3892 score=1.0 size=13
INFO # chromosomes with max fitness: 1
INFO champ: id=3892 score=1.0 size=13
INFO Generation 30: end [10:11:07 - 10:11:07] [437]
INFO generation of first solution == 30
INFO champ # connections == 7
INFO champ # hidden nodes == 2
INFO Run: end [10:10:55 - 10:11:08] [12250]
|
In this case, the
first solution to have solved XOR (determined by the fitness.threshold
parameter) was Generation 30.. The number of connections and hidden neurons
in the champion also are listed. Finally, the start and end time, and
length of the run are displayed.
|
7 |
In the previous example,
the champion chromosome had ID 3892. To verify that the champion has solved
XOR, run the following from the anji_2_01 directory: Windows:
Type
"activate.bat xor.properties 3892" and press Enter.
Unix:
Type "activate.sh xor.properties 3892" and press Enter. |
9 |
You should see output
similar to the following:
INFO loaded properties from xor.properties
INFO Properties: random.seed == null [1124289108796]
INFO Properties: persistence.class == com.anji.persistence.FilePersistence
INFO Properties: base.dir == ./db
INFO Properties: ann.type == anji
INFO Properties: recurrent.cycles == 1
INFO Properties: recurrent == disallowed
INFO Properties: stimuli.file == sigmoid_xor_stimuli.txt
INFO Properties: targets.file == sigmoid_xor_targets.txt
INFO
0: IN (0.0, 0.0, 1.0) OUT (4.0755467194904E-4) TARGET (0.0)
1: IN (0.0, 1.0, 1.0) OUT (0.9998126586761057) TARGET (1.0)
2: IN (1.0, 0.0, 1.0) OUT (0.9921851733246422) TARGET (1.0)
3: IN (1.0, 1.0, 1.0) OUT (0.050401452692758975) TARGET (0.0)
|
ANJI again displays some basic properties, then shows the
results of the 4 network activations. In the first activation, the inputs
are (0.0, 0.0, 1.0). This last value is the input for the bias, which
is always at 1.0. The output of the network is 0.000408, displayed in
scientific notation. The target is 0. From this you can see that the algorithm
has solved the problem and this network now functions as an XOR gate.
The sequence of the XOR inputs is randomized every activation (to ensure
that the network is not simply memorizing a sequence), although they are
always displayed in this order.
|
10 |
Chromosomes are stored
in the anji_2_01/db/chromosome/ directory. These are the
champions of each generation. In addition to generational champions, ANJI
can be configured to persist all chromosomes of the final generation, or
all chromosomes of every generation.
The anji_2_01/db/ directory now contains the id.xml
and neatid.xml files. These persist data relative to unique
chromosome and innovation IDs between runs. These files are necessary to
begin a run with an existing population, or to avoid overwriting previously
generated chromosomes. |
11 |
To clear out the
persistence directories and start fresh, run the following from the anji_2_01
directory:
Windows:
Type
"reset.bat xor.properties" and press Enter.
Unix:
Type "reset.sh xor.properties" and press Enter.
The following will
display:
ANJI v1.0, Copyright (C) 2004 Derek James and Philip Tucker
ANJI comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under the conditions of the GNU General Public License.
Delete all?
|
Type "y"
to delete all persisted data associated with the run. |
12 |
To view graphical
information regarding the run, open the following from Internet Explorer
(or any web browser supporting the <?xml-stylesheet?> tag):
anji_2_01/nevt/fitness/fitness.xml
max, min, and average fitness for each generation throughout the run
anji_2_01/nevt/species/species.xml
# species and size of each specie for each generation throughout the run
anji_2_01/nevt/complexity/complexity.xml
max, min, and average complexity (i.e., # genes per chromosome) for each
generation throughout the run
For example, opening
the fitness.xml in IE will display the following graph:

The blue line for
each generation shows the min and max fitness for that generation. The
black dot indicates the average fitness for the population. This graph
shows that XOR was solved at generation 30. |
13 |
You may wish to
run XOR multiple times in order to verify that it is working properly
on your machine.
In rare cases, XOR
may not be solved. But the solve rate should be well above 95%.
At this point, you
may wish to edit the population size, mutation rates, etc. to see what
effect these parameters have. All parameters are editable in the properties
file associated with each domain. For an overview of these parameters
and recommended settings see here.
|