Getting Started with JaGa

Architecture

JaGa is composed of four main modules:

JaGa Architecture
Fig. 1. Module structure and information flow in JaGa architecture.

JaGa includes a generational Genetic Algorithm which can act as an Evolutionary Strategy implementation of the GA module. It also includes a standard control module suitable for most purposes. In order to customise JaGa to your problem you only have to implement two interfaces corresponding to the deployment and experiment modules. If you are evolving circuits these have been implemented for you.

Example

Let's start with a simple example of using JaGa. We will use a generational GA to evolve an XOR circuit out of digital logic.

Setting up the GA

What we want. We'll have a generational GA with 32 individuals in the population. The best two of every generation will be elites and will survive unmodified into the next generation. Of the remaining 30 of the next generation, 60% will be created through single point cross over and 40% by point mutation. Individuals from the old population will be selected for reproduction using rank selection.

Code
int populationSize = 32;
int elitesNo = 2;
int mutationsPerGenotype = 1;

GeneticOperator spxo = new SinglePointXOver();
GeneticOperator mutation = new ExactGenotypeMutator( mutationsPerGenotype );
GeneticOperator[] geneticOperators = { spxo, mutation };
double[] operatorProbabilities = { 0.60, 0.40 };
Selector selector = new RankSelector();
Evolver evolver = new StandardEvolver( populationSize, genotypeLength, geneticOperators, operatorProbabilities, selector, elitesNo );

Now (with the exception that we don't know what genotypeLength should be yet) we have fully setup our GA module.

Deployment

What we want. In this example we want genotypes to map onto circuit instances in a digital logic simulator. For this we need some kind of mapping. We'll choose one that builds circuits out of Lookup Tables (LUTs) using two inputs. Say we'd also want these logic elements to have a delay of 1 time step. Let's say we want 4 bits to address each LUT so we could have up to 16 LUTs. Don't worry if you don't understand the electronics, its just an arbitrary example of what you'd use JaGa for.

Code
int lutInputNo = 2;
int lutDelay = 1;
int bitsPerAddress = 4;

ElementDelayModel delayModel = new ConstantDelayModel( lutDelay );
CircuitMapping circuitMapping = new LUTAbsoluteMapping( inputsNo, outputsNo, bitsPerAddress, lutInputNo, delayModel );
SimulatorSimpleCircuit circuit = new SimulatorSimpleCircuit( circuitMapping );
Deployment deployment = new SimulatorDeployment( circuit );

Now we only need the number of circuit inputs and outputs, which depend on what kind of circuit we want to evolve - ie. the Experiment.

Experiment

What we want. We want an experiment which generates a test pattern which is good to evaluate a circuit's performance as an XOR circuit. We also want a fitness function which will judge how close a circuit's response is to that of an XOR's. We also want it to only look at the second half of the circuit output samples for each cycle giving it time to settle. This is because the logic elements have delay. This has all been coded.

Code
BooleanFunction xor = new XOrFunction();
double tSetup = 0.5;
Experiment experiment = new ArbitraryFunctionExperiment( xor, tSetup );

Control

What we want. Once we've got the GA, Deployment and Experiment setup we can configure the way in which they'll interact. In this case we want a simple interaction model like the one in Fig. 1.

Code
InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment );
Monica monica = new Monica( interactionModel );

Where Monica is the object with which we'll control the evolutionary process.

Putting it all togather

Code
import jaga.control.*;
import jaga.deploy.*;
import jaga.experiment.*;
import jaga.evolve.*;

import jaga.pj.circuits.*;
import jaga.pj.circuits.experiment.*;
import jaga.pj.circuits.fpgaft.*;

public class JaGaExample
{

}

This example is meant to give an example of how a simple evolutionary process can be setup with JaGa. Don't worry about the electronics details or how the genotype length was calculated since these only apply to evolving circuits. For applying JaGa to your needs all you have to do now is create your own deployment and experiment objects implementing the deploy.Deployment and experiment.Experiment interfaces. Then you can replace the relevant sections in the example above and it should work.

Help!

Please do not hesitate to contact the project administrator for troubleshooting or advice on using JaGa.