SIMULATION CODE
Initial versions of simulators (written in Java) are available here. Each of these simulate the behavior of an EEXIST comprised of a 1-D array of thin tubes containing pairs of the SRC (S) and DST (D) chemicals. This is a discretization in space (delta-x) as well as time (the simulation advances in discrete time steps). The continuity of the system's state changes is unverified, but assuming continuity, the simulation approaches the actual continuous behavior by using smaller and smaller deltas.
Different simulator versions explore different aspects of this system, but most share a core set of features. They simulate the behavior of the system as it runs forward in time, starting from some initial random configuration, and proceeding for a certain amount of time. Each initial configuration is consider an “individual” in a theoretical population of individual, and while an individual is simulated, it is observed and measured according to some metric (which may be based on a given task it's supposed to perform). After a certain number of individuals have been studied, the most-fit are combined (with a certain degree of random mutation affecting their offspring), while the least fit are discarded. This new population is then studied, and the system continues to evolve in this way.
MAIN EXECUTION
When executing the main method, two windows initially appear. The main control window allows you to start the simulation or pause it (Pause/Evolve radio buttons, upper-left: Stimulate is a NOP). Once running, the other window shows the current status of the system's chemicals: space runs from X=0 to X=40, with green vertical lines marking every 5 units. Time runs vertically, from t=0 (top) to the bottom, and then rolling-over to the top again. By default, there are 320 tubes across, so each tube covers 0.125 in space.
MAIN DISPLAY
Scanning across a single horizontal row, each region represents the contents of a single tube. Red corresponds to SRC chemical, blue to DST. The mix of red and blue reflects the mix of chemicals; the intensity of the color represents the amount of each chemical. Thus a dark region has few chemicals; right red has a lot of SRC; bright blue a lot of DST; bright purple a mix of a lot of SRC and DST; dark purple a mix but with less total amount; and so on. The RGB slider controls the mapping from chemical level-to-intensity of the display.
Normally the simulation runs for a short period of time, and then a new simulation begins. The window's label (“Member n) shows the (sequential) numeric identity of the current system being simulated. By clicking Loop the simulation can be forced to continue forward in time indefinitely. Further clicking Expire will cause the simulation to advance to a new initial state if the current simulation becomes “uninteresting,” i.e. if the concentration of chemicals doesn't change by much over a period of time).
PRIMARY CONTROLS
Each individual begins initially with two randomly-selected tubes populated with random amounts of SRC and DST. The # of initial bins seeded each time can be set with the “# of Initial Bins” slider. Having more initial bins generally correlates with having more interaction among the bins, but sometimes just 2 initial bins will interact, leading to rich dynamic behavior in the system.
Temporary stimuli can be applied by clicking the Stim button, which will introduce a random mix of chemicals into a random tube.
The SET button can be used to change a few global variables:
Effect controls how much impact a given SRC->DST transfer affects nearby regions (the total effect drops off by an exponential(?) function whose slope is affected by this variable);
dt controls the timestep from one stage of the simulation to another
Mut Rate is used in some versions of the code to control the mutation rate across evolving generations
There are other buttons which are unused (“New label”)
The LOAD/SAVE pair of buttons allows the current state of the system to be saved to disk. Hitting Save will pop up a file dialog, allowing you to specify a file to save into. Check boxes also specification of what to save: the Src/Dst contents of each tube (“S/D”); the system-wide Constants; and the initial Genome of the system. These are likely unreliable in their present form, but are available for future use.
SD Transfer Addressing controls the basic operating mode of the system. In Absolute Addressing, the SRC and DST concentrations specify addresses (X coordinates) of the tubes between which chemicals are transferred. In Relative Addressing, the SRC and DST concentrations within a tube are relative offsets from that tube's address to the source and destination of the intended transfer. This touches on one of the areas of future exploration.
When looking at concentrations of chemicals across space, the display resembles a frequency spectrum. As an experiment, the Audio button causes those concentration to be interpreted in exactly that way: as amplitudes of different frequencies in an frequency spectrum. The Audio button will perform a reverse FFT, creating a .WAV file (you'll see a countdown in the display window as output is generated). The resulting file is called sample.wav, and is saved on the desktop (may be bound to my particular userID). Samples of such audio files can be found here. The interesting step in the sounds is likely a red herring, coming from the discretization in space of the theoretically-infinitesimal tubes.
DETAILED TUBE DISPLAY
Clicking in the main display will bring up a new window which shows a detailed view of the S/D concentrations in each tube. This window shows an x-y plot for a single point in time: x=space (range of tubes), and y=chemical concentration (the graph is drawn with y=0 at the top).
The display shows the concentration of chemicals in the tubes, at the point in time corresponding to where you clicked in the main display. You can zoom in Y by using the scroll wheel of the mouse, and scroll in X by holding SHIFT and using the scroll wheel (the window itself is also resizable). The display itself can also be dragged within the window, to zoom in on different sections of it. A pair of reset buttons allow resetting the Scroll (dragging of the window) and Zoom to their default settings.
The “UpdateLive: checkbox (which is checked by default) causes the display to update in sync with the main display. Instead of displaying a snapshot of chemical concentrations, it displays the current chemical concentrations of the system (and thus generally changes over wall-time). Flip R/B changes which concentration is drawn first (normally Red/SRC, then Blue/DST). See the online videos for a clearer explanation of this.
Finally, positioning the mouse anywhere inside this detailed display window will cause the title bar to show to bin number (X position) corresponding to the mouse pointer's position in the detailed display. The title bar also displays the mouse's Y value, as well as the S (SRC amount) and D (D amount) for the tube at the given X position. Play with it and it will make more sense!
CODE
While the code was never intended to be user-friendly (i.e. well-documented, carefully organized, and so on), it is fairly modular, comprised of several main classes:
C.java
The code for this simulator uses a number of global variables (“constants”), stored as statics in C.java. Sure, its not best-practice, it's sloppy, it's lazy. It works though, and for now this is how things are set up. Maybe after a better understanding of EEXIST emerges, this can be re-worked in a more object-oriented style.
C contains the following variables:
static double minX=0,maxX=40;
These are the spatial limits of the one-dimensional universe of chemical tubes. Be careful changing these, as these limits may be hardwired into the code elsewhere.
static double dx=.03125;
Time-increment for the simulation. Should be safe to change.
static double dx=.125;
Space-increment for the simulation. Very likely unsafe to change without looking through the code carefully, especially for the constant 320 ((maxX-minX)/dx)
static double effect=20;
Degree to which each transfer causes similar transfers near the source/destination bins. 0 causes a pure point-based trandfer, larger numbers spread the effect. Increasing this value significantly slows the simulation.
static int timeStep=0;
Simple counter of how long the simulation has run. Used for GA functions.
static boolean debug=false;
Generic flag to add (mostly) println messages.
static double rgbScale=7;
Color intensity/contrast.
static double dt=0.05;
Time-delta for simulation. Should be safe to change. Increases accuracy, slows down simulation accordingly.
static double maxTime=50;
Used by some code to limit how many timesteps are used before re-initializing the system (GA models)
static int scaleX=2,scaleY=1;
Simply scaling for the main display.
static int numStepsOnDisplay=600;
Used to determine when to wrap the main display (# of time steps)
static boolean VOLUMECLIP=true;
set to clip volumes between [0,MAXVAL] (???)
static int clearTime=20;
Used in metric testing of GA individuals; allows initial chemical setups to change mid-test
static int POPSIZE=40;
# of individuals in the population. Be very careful changing this. Used for GA system.
static int SELECT=6;
Survivor per generation (GA)
static double MUTATIONRATE=0.05;
Likelihood of random genome changes (GA)
static int CSIZE=16;
Obsolete version of genome where individual is comprised of a set of tubes (???)
static int S=0,D=1;
Don't change these! Used as indicies for the last dim of the main chemcomp memory
static boolean looping=false;
Generic global var, used to loop forever vs. expiring an individual and moving on to the next. Was added to allow “interesting” individuals to be examined further.
static boolean doStim=false;
Set when the user requests injection of chemicals into the system.
static double snapshotDiffThreshold=0.01;
report changes smaller than this (???)
static int NumInitBins=2;
# of chemical bins initially containing chemicals. Controlable via slider on main Control Panel
static boolean ABSOLUTEXFER=false;
True signifies that SRC and DEST levels refer to the absolute coordinates of chemical tubes. FALSE puts the simulator into RELATIVE ADDRESSING MODE, wherein SRC and DEST levels specify the source and destination as relative offsets from the tube containing the instruction.
static int loopCountExpire=100;
if expire checkbox is checked, only loop this many timesteps
EXIST.java
EXIST is the main class for the system. It contains the main system memory (mem[][]), as well as the main transfer code (step(), transfer(), connect()) plus various utility code (readBin, etc.)
Universe.java
Universe constructs and exposes most of the other main classes in the system (Display, Control, etc.) Its run method drives the main GA loop: initializing a population, running the simulation (assess()) an saving the individual's fitness, comparing, mating, mutating and repeating across generations.
Individual.Java
This class contains the genome (balance of chemicals across space) for a single individual in the population. It includes methods for manipulating an individual's genome: smoothing, randomizing, etc.
Main.java
Main program for the system. Constructs and starts a Universe.
Control.java
GUI control panel for manipulating the simulation.
Display.java
Graphical view of system status (chemical balance).
DrawingPanel.java
Drawing support.
GraphFrame.java
Draws and manages detail-level display of current (or snapshot) system view.
MyScrollPane.java
Drawing support.
Log.java
Records system state to a file, in a mostly write-only manner...