Creating Algorithms

This section describes the creation of algorithms.

Creation via GUI

The creation of algorithms via the GUI is described in the Evolvica user manual. Make sure to read the sections about operator creation guidelines to be able to use your own operators in the GUI.

Creation via Code

In addition to creation of algorithms in the GUI algorithms can also be created programmatically and run from the commandline. In order to do that derive a class from org.evolvica.engine.AbstractAlgorithm. There are two abstract methods which must be filled out: setup() and teardown().
The setup-method is called before an algorithm is executed and must be used to create the algorithm structure. In this method you should instantiate all you operators, set all operator parameters and connect everything together. A minimal example algorithm would look like this:

public void setup() {
	MyIntializer init = new MyInitializer();
	MySink sink = new MySink();
	init.setParameter( 10 );
	connect( init, 0, sink, 0 );
}
The first two lines create two operators (an initializer and a sink). The third sets a parameter value to the initializer. The fourth line finally connects the output no. 0 of the initializer with the input no. 0 of the source. The whole algorithm creates some data in the initializer and sends the data to the sink where it is stored.
The teardown()-method is called after the algorithm has finished. This method can be used to extract the result data from the sinks and print the best individuals.
The final step in algorithm creation is to create a main-method to be able to start algorithms:
public static void main( String[] args ) {
	new MyAlgorithm().execute();
}
In addition to this section please refer to the source code of the examples to get an idea of how to create algorithms programmatically.