ECJ Tutorial 4 - Xholon App (GP)
What is it
This model is a Xholon version of the Tutorial 4 application included with ECJ, an open-source evolutionary computation system written in Java. You will need to download ECJ separately from Xholon. This version of the model generates an optimal solution using genetic programming (GP). The discussion that follows assumes you are generally familiar with GP. If not, see the references later in this document.
This application demonstrates how to combine Xholon with ECJ. It's a very simple Xholon app that functions largely as a container for ECJ. In other Xholon apps, especially AntForaging, the Xholon part of the app does much more work, and uses ECJ simply to generate more and more fit solutions to the problem.
How to use it
Run it:
- Run the Java application through the XhnEalontro GUI (org.primordion.xholon.app.Xhn.java), and select File --> Open --> ealontro --> EcjTutorial4 --> EcjTutorial4_1_xhn.xml.
- Expand the Controller node in the tree.
- Press the Start node.
- You should see the following text, or something similar, displayed in the console window.
- If you have JFreeChart installed, and if you have selected "JFreeChart" as the value of the UseDataPlotter parameter in Tutorial4_1_xhn.xml, you should also see a chart showing the increase in fitness from one generation to the next (0.0 is the ideal fitness). If you don't have JFreeChart installed, then change the value of UseDataPlotter to "gnuplot", and look at the results that are saved to a .csv file in the statistics folder. If you have gnuplot installed, it can read the .plt script in the statistics folder to produce a displayable .png file from the .csv file, that should look similar to the one below.
Opening model: C:\Primordion\workspace\Ealontro\config\ealontro\EcjTutorial4\EcjTutorial4_1_xhn.xml AppM : false InfoM : false ErrorM : true MaxProcessLoops : 500 TimeStepInterval : 10 InheritanceHierarchyFile : ./config/ealontro/EcjTutorial4/InheritanceHierarchy.xml CompositeStructureHierarchyFile : ./config/ealontro/EcjTutorial4/EcjCompositeStructureHierarchy.xml ClassDetailsFile : ./config/ealontro/EcjTutorial4/EcjClassDetails.xml InformationFile : ./config/ealontro/EcjTutorial4/Information_GP.xml JavaClassName : org.primordion.ealontro.app.AppEcjTutorial4 UseDataPlotter : true SaveSnapshots : false EcjArgs : -file bin/ec/app/tutorial4/tutorial4.params C:\Primordion\workspace\Ealontro\config\ealontro\EcjTutorial4\EcjTutorial4_1_xhn.xml | ECJ | An evolutionary computation system (version 15) | By Sean Luke | Contributors: L. Panait, G. Balan, S. Paus, Z. Skolicki, | J. Bassett, R. Hubley, and A. Chircop | URL: http://cs.gmu.edu/~eclab/projects/ecj/ | Mail: ecj-help@cs.gmu.edu | (better: join ECJ-INTEREST at URL above) | Date: April 4, 2006 | Current Java: 1.4.2_10 / Java HotSpot(TM) Client VM-1.4.2_10-b03 | Required Minimum Java: 1.3 Threads: breed/1 eval/1 Seed: 638926703 Job: 0 Setting up Processing GP Types Processing GP Node Constraints Processing GP Function Sets Processing GP Tree Constraints Initializing Generation 0 Population: 1024 Generation 1 Generation 2 Generation 3 Generation 4 Generation 5 Generation 6 Generation 7 Found Ideal Individual
Things to notice
Take a look at the EcjCompositeStructureHierarchy.xml, and EcjClassDetails.xml configuration files in the config/ealontro/EcjTutorial4 folder. These files have little content because ECJ does most of the work.
EcjCompositeStructureHierarchy.xml has multiplicity="1024", which must match the population size specified in an ECJ .params file.
EcjTutorial4_1_xhn.xml contains a "EcjArgs" parameter, with a value="-file bin/ec/app/tutorial4/tutorial4.params". Xholon needs to pass this to ECJ to tell it where its parameters are located.
Notice that XhEcjTutorial4.java also has little content.
Look at the original ECJ files in ec.app.tutorial4. Most of the work in this application is done here, especially in MultiValuedRegression.java.
Read tutorial4/index.html, "Tutorial 4: Build a Multivalued Genetic Programming Symbolic Regression Problem", an excellent descriptive document that comes with ECJ.
The ECJ file out.stat contains the best solution found each generation, and the best individual found in the entire run. The Xholon file EcjCompositeStructureHierarchy_Best.xml contains the best solution, in Xholon format. It can be copied into another CompositeStructureHierarchy.xml file to be run as a hard-coded optimal solution, as is done in the config files for Tutorial4_1_xhn.xml. The ECJ file organizes nodes in textual lists, while Xholon formats the same information using XML trees.
Things to try
When the application has finished running after pressing the Start node, you can examine the final population of solutions produced by ECJ. Click the Refresh node, and then expand the Model nodes until poulation_0 has been expanded. You will now see 1024 instances of EcjTutorial4System, each name preceeded by a fitness score. Click on each of these. The size of the ECJ-generated primitive function tree (PfTree) will be displayed at the bottom of the GUI window. Expand the GeneticProgram node under each instance of EcjTutorial4System to see how that behavior is structured.
Extending the model
This simple application was written to show how to embed ECJ within a Xholon app. It's not intneded that this app be extended. It would be better to study the AntForaging model to learn how to combine Xholon and ECJ.
Xholon and Ealontro features
Generating an optimal solution to a problem using genetic programming (GP).
Displaying results in a chart.