File: readme.txt Author: Justin Basilico Course: PO CS 152: Neural Networks Assignment: Final Project Updated: 2001.12.19 Created: 2001.12.19 DESCRIPTION: This project contains code for evolving sigma-pi networks that simulate other simple feed-forward networks. The main program is implemented in the NetworkEvolver.java file, which is the program that runs the genetic algorithm for evolving the sigma-pi networks. Two utility programs are also provided, DatasetCreator which creates the datasets of random networks to simulate for the NetworkEvolver program to read, and NetworkTester, which tests saved networks from the NetworkEvolver against a dataset created by the DatasetCreator. This file explains how to compile and run each of these three programs and also provides the exact syntax of how to replicate each of the experiments that are described in the write-up for the project. HOW TO COMPILE: To compile all of the three program classes and the classes that they depend on, just do: javac NetworkEvolver.java javac DatasetCreator.java javac NetworkTester.java HOW TO RUN: All of the programs have the same basic syntax to run, which is: java NetworkEvolver java DatasetCreator java NetworkTester The parameters accepted by each program, along with a description of what they do is provided below. NETWORK EVOLVER: This program implements the genetic algorithm for evolving sigma-pi networks that are simulators for other networks. The basic idea is that it creates chromosomes that represent the connectivity of the sigma-pi network and tests each chromosome by loading it into a sigma-pi network and against a specified dataset of random networks. The fitness of a chromosome is its average mean squared error across the whole dataset, so a smaller fitness value means a better chromosome. The program runs for the specified number of generations and after each generation, the fitness of the best chromosome in the current population and the average fitness of the chromosomes in the population is output. To create the next generation from the current one, first the top 5% of chromosomes are copied into the next generation directly. For the rest, rank selection is used to select two chromosomes, which are crossed over at the bit level with given probability of being swapped. Then one of the two children is selected and mutated with the given mutation rate, which is the chance that any one bit in the chromosome will flip. Every 100 generations the best chromosome is loaded into a sigma-pi network and that network is output. Also, if specified, this network will be saved into a specified file after every given number of generations. The goal of the network evolver is to get a chromosome whose best fitness is 0.0. The program accepts the following parameters: -e This parameter specifies which experiment (1, 2, or 3) should be run. The first experiment evolves a sigma-pi network that simulates a 2-1 network. The second experiment evolves a simulator for a 2-2 network. The third evolves one for a 2-2-1 network. The experiment number must be specified on the command- line and it must be either 1,2, or 3. Also, make sure that the experiment agrees with the dataset being used (which means the dataset was created for the proper network size). -p This parameter specifies the size of the population to run the genetic algorithm with. It is the number of chromosomes in the population that is being evolved. It must be at least 1. The default is 200. -g This parameter specifies the number of generations to run the genetic algorithm for to evolve the sigma-pi simulator networks. It must be at least 1. The default is 100. -m This parameter specifies the value for the mutation rate per bit in the chromosome. The mutation rate must be between 0.0 and 1.0. It is really just the percent chance any one bit will flip at each generation. The default value is 0.01. It is suggested that the rate be kept small for the algorithm to work properly. -c This parameter specifies the value for the crossover rate per bit in the chromosome. The crossover rate must also be between 0.0 and 1.0. The crossover between two chromosomes is done by just basically using a bit mask, and this is the probability that any one bit will be crossed over. The default is 0.1. -d This parameter specifies the file that contains the dataset that the program is going to use to test the evolved networks in the fitness function. This parameter must be specified and the given file must be a proper file that was created by the DatasetCreator program (or something similar) that creates valid networks to be simulated. It is assumed that the proper dataset is given with the experiment number. If it is not, strange results might occur. Also, the dataset file should exist and contain some data. -r This parameter specifies the seed value for the random number generator, which is a long value. If no random number seed is specified, then the value returned by System.currentTimeMillis() is used. -n This parameter specifies where the SigmaPiNetwork object corresponding to the best member of the population will be stored at the end of the algorithm and possibly every specified number of epochs. If no file is specified, then it will not be saved. The default is to have no such file. -s This parameters specifies how many epochs should pass between each save of the best SigmaPiNetwork that has been created yet, using the given network save file name. It must be a positive integer The default is 100. -h If this parameter is given, a help message about the usage of this program will be output. Example: java NetworkEvolver -e 1 -d experiment_1.txt -g 50 -p 100 -n network_1.net -m 0.05 -c 0.2 -s 25 This will run the first experiment using the dataset in "experiment_1.txt" for 50 generations with a population of 100, a mutation rate of 0.05, and a crossover rate of 0.2. It will save the best network into the file "network_1.net" every 25 epochs. This program is used in the project for running the genetic algorithm. For more information, see "NetworkEvolver.java". DATASET CREATOR: This program is for creating the datasets of random simple, fully-connected, feed-forward networks that the sigma-pi networks are to try and simulate in the NetworkEvolver program. In particular, it creates the specified number of random networks with random weight values and turns them into an input vector where the first units are the inputs to the network and the rest are the weights of that network. The output associated with the input is the output that the random network produces on the random input, since the sigma-pi networks are trying to simulate these networks. For each weight in the network of the specified architecture it randomly assigns a value between -5.0 and 5.0 and for each input it assigns a value between -1.0 and 1.0. The dataset is written into a file specified by the user. The format of the file is that it has on the first line the size of the input to expect and the size of the output to expect. Then on every other pair of lines in the file, the first line specifies the double input values and the second line specifies the double output values. These should both be of the length specified by the first line in the file. Before writing the dataset into the file it outputs the information about the dataset it is creating. The program accepts the following parameters: -f This parameter specifies the name of the file to write the generated dataset into. If this is a file that already exists, it will be overwritten, so be careful. The parameter must be specified for the program to run. -n This parameter specifies the positive integer number of random networks (input/output pairs) for the program to create in the specified file. It must be at least 1. The default value is 100. -i This parameter specifies the number of inputs that the simulated networks are to have. It must be at least 1. The default is 2. -o This parameter specifies the number of outputs that the simulated networks are to have. It must be at least 1. The default is 2. -h