Directed SANE software

This page allows you to download the software described in our article ("Evolving artificial neural networks to control chaotic systems", E. R. Weeks and J. M. Burgess, published in Phys. Rev. E 56, pp 1531-1540, August 1997). Click here to download a PDF copy. If you have questions or comments about our work, we'd love to hear from you, send Eric email: erweeks / (change / to @). Note that while I'm happy to answer questions directly related to this webpage, I have not done any research with neural networks or controlling chaos since 1997, so I'm not an expert on those topics. I greatly thank the Internet Archive Wayback Machine for having archived the old version of this web page, from which I restored the page that you're now reading.

Click here for a description of our method and results (a brief web description).

  1. Download the software
  2. How to use
  3. Source code files
  4. Output files
  5. Modifying the program

Download the software

The software and algorithm are copyrighted by Eric R. Weeks and John M. Burgess, 1998. They may be freely distributed with proper attribution and full acknowlegement of the copyright.

You have several choices for downloading the source code:


: untar with "tar -zxvf". (39k) (File is compressed with the UNIX utility "gzip".)


: untar with "tar -Zxvf". (65k) (File is compressed with the UNIX utility "compress".)

: A standard zip file. (41k)

This package comes with a Makefile. This should have no problems compiling on any UNIX system, although you might want to change the line that says CC=cc to CC=gcc if you prefer the gcc compiler. To compile, type make. This creates an executable file called dsane.x.

How to use:

The program is designed to be easy to use, allowing you to do simple things through command-line options and more complicated things by modifying some of the files and recompiling. Without modifying anything the program is set to try to control the Henon map; the default parameters should work without any problems.

To compile, see above. Compiling creates an executable file called dsane. To run, you must specify a suffix which will be used to name the output files (see below). The simplest way to run the program is:

dsane.x test1

which will generate output files names evol.test1, popul.test1, etc. If you wish to use command line options, put them between "dsane" and the suffix:

dsane.x -p 1.4 -E 0.003 test2

Right now you can do three different maps:

Henon Map (default): X'=P + 0.3 Y - X^2, Y' = X

Logistic Map: X' = P X (1 - X)

"User Map": X' = (P - X - 0.1 Y) X, Y' = (P - Y - 0.15 X) Y

Command line options:

-h : this prints out a help message listing the options below and their defaults. -p # : sets the parameter for the map, P -e # : sets size of delta P maximum -E # : sets the size of delta P2 maximum. This is only used for systems which allow two perturbations. For the Henon map, the second perturbation is applied to the 0.3 coefficient. -N # : sets the level of the noise in the map. -N0 turns the noise off. -M # : determines which map is used. -M1 is logistic, -M2 is Henon, -M3 is the user map. The Henon map is the default. -l # : how many iterations are used to determine the fitness. The default is 1000. -t # : how many networks are formed & tested each generation. The default is 100. -D # : allows for double-checking of networks. Each network is tested twice by default; this option allows you to change so that networks are tested once only (-D1) or more than twice (ie, -D7 means each network is tested 7 times.) -T # : look for a period # orbit (by default, the program looks for a period 1 orbit, which would be an unstable fixed point.) -y # : each generation, the best network is retested and the last few iterations of the map being controlled by that network are saved to a file with the prefix "dyn" (see below). This option sets the number of iterations written to this file. The default is 0 (and thus the file is never created). -s # : stop evolution when the fitness exceeds this value. This determines how good a network the program is looking for. If a network is never found that has a fitness higher than this value, the program terminates after a set number of generations set by the next option. -g # : maximum number of generations to evolve; default is 2000. -z # : for Directed SANE, save this many network definitions. Default is 4. -Z # : for Directed SANE, form this percentage of networks using network definitions. Default is 50. Set to 0 to form all networks randomly.

Source Code Files

There are a total of seven files, as well as a Makefile, that comprise the DSANE program. Several of these files are simple to modify. The seven files are:

Output Files

When the program runs, it generates the following output files (note that the suffix is set by the command line):

para.suffix: this file contains a listing of all of the important parameters describing this trial. Some of these parameters can be modified using command line options; others require editing the file "params.h" and recompiling the program.

control.suffix: every ten generations, the best network of the current generation is tested 200 times, allowing the network 3000 iterations to try to control the map. This file contains the results: the average number of iterations needed to control the map, the number of times the network failed to control, the earliest iteration control was achieved, and the latest iteration control was achieved. Due to the simplistic nature of the test for control, networks which fail to control the map may still "control" the map for the last one or two iterations; this is clear from the earliest iteration control was achieved being set to 2998 or so.

evol.suffix: information about the population fitness at each generation. The first column is the generation number. The next information is the fitness of the best network tested each generation. Then is the average fitness of the neurons in the population. The last four columns give information about Directed SANE as compared to the "original" method (for details of the two techniques, see the Appendix in our paper). The last four columns typically look something like this: "D 2 o 7". The capital D indicates that Directed SANE formed the best network that generation; a capital O indicates that the original method formed the best. The 2 and 7 mean that this generation, Directed SANE formed 2 networks better than the previous generation's best fitness, and the original method formed 7 networks better than the previous generation.

net.suffix: a description of the best neural network formed so far. When the program is finished this is the best network that was found. The file contains a description of the network topology, and a listing of the weights connecting the hidden neurons to the input and output layer.

lambda.suffix: contains information used to calculate fitness, for the best network each generation. The first column is the generation number. The second column is the number of iterations the behavior of the system was near the fixed point (as defined by successive iterations being close to each other; the fixed point location isn't known). The third column is the value of lambda that was found. This indicates that near the fixed point, generally:

| X - X | = lambda | X - X | | n+1 n | | n n-1 | If lambda is near 1, the fixed point is stable. See the paper for more details.

best.suffix: contains a sample run from the best network that has been found so far. After the program exits, this file contains a sample run from the best network found. The data is in four columns, (iteration n, x(n), delta P 1 (n), delta P 2 (n)).

dyn.suffix: each generation the best network is taken and retested. The last N iterations of that test are saved to this file. The default value of N is 0 and this file isn't written; to change the default value, use the -y option (see the command line options above). Each line in this file indicates the generation, two values for fitness, and then the data. The first value for the fitness is the fitness the best network had the first time it was tested (which was how we decided it was the best network), and the second value for the fitness is the fitness found during the retest.

Modifying the Program

There are several ways to modify the program:

  1. The easiest is to use the command line options.
  2. Common parameters are in the file params.h. This file can be edited and the program recompiled.
  3. The file usermap.c is provided to allow you to easily enter a new map to try to control. If you want to connect the program to an experiment, in principle the connection would be made through this file, with any experiment input or output functions in this subroutine. That is, usermap.c takes the perturbation given by the neural network and determines the next observation X; this could be coming from an experiment.
  4. To modify how the network interacts with the system, edit the file network.c. This file gives information to the network input layer, and interprets the network output layer as a perturbation.
  5. To modify the fitness function coefficients, edit the file params.h. To modify the fitness function itself, edit the file fitness.c.
  6. It is likely casual users of this program will have no interest in modifying the Directed SANE algorithm directly. If necessary, the DSANE algorithm is contained in dsane.c and dsane.h. We have tried to add in comments to the code as necessary.