Creating Operators

Creating algorithms out of predefined operators gets quite boring after a while. So most likely you want or need to implement own operators. This sections shows how to do that.

Creating operators is nothing else than creating Java classes with some additional information attached. In this little example we will create an evaluation operator. In the projects window right-click your project and choose New > Operator.

A wizard for creating a new Java class appears. Choose the name and the package for your class.

Almost (?!) each genetic operator will extend an abstract class already provided by the Evolvica core library. In our case we want to create a new evaluator. Evaluators extend the base class AbstractEvaluator. We can enter the class manually in the super class field or click the Browse button for choosing the base class. A dialog will appear where you can choose the desired base class.

After choosing the base class the wizard has enough information to create our class. By activating the Inherited abstract methods mark the wizard will create a method stub that needs to be filled out.

After clicking the Finish button a new class will be created and we can start programming. In our case only one method of the new class must be overridden and filled out with own code. In addition you may create property fields with the appropriate get- and set-methods. Please refer to the Evolvica developer manual to learn more about such properties.

After implementing the functionality the operator is actually finished. But as of version 0.5.0 of Evolvica there is a second step that must be performed to prepare the operator for use in the GUI. Each operator is assigned a descriptor that contains information needed by the GUI. In earlier versions of Evolvica this information was attached via code in the constructor. Now this information is saved in a separate desriptor file. So the second step is to create such a descriptor file for our new operator.

You may have already noticed that the editor you're currently using has two small tabs at its bottom: "Source" and "Descriptor". The source tab is currently active and shows the source code of the operator. Now click the descriptor tab to switch to another view to access the descriptor information.

An editor for the descriptor opens. In the upper part general information about the operator can be edited: the name under which the operator appears in the operator palette, the datatype this operator works on, the number of input and output slots, category, vendor and a short description.

In the lower part the properties of the operator can be edited. Here the display name of the property and a short description can be inserted and an expert flag can be set. This flag indicates if the property should appear only after activating Show Advanced Properties in the Property Sheet.

Finally the operator is ready for use. Save your operator by selecting Save from the File menu or press CTRL+S. To make the operator appear in the operator palette close and reopen the graphical view of an algorithm or choose Refresh Operator Cache from the Project menu.