|
Origin Developer's Guide 1.0.2 |
|
The Origin SDK providing a rich set of classes that you can use to develop your own evolutionary computation programs. Your application can build on the functionality provided by the SDK by subclassing and extending Origin classes, or by writing classes that implement the standard interfaces defined in the SDK. Since Origin's behavior is configured at runtime you should normally never have to modify the Origin source code, though you may find it useful to use it as a template for your own work.
The Origin class hierarchy is similar to that provided by ECJ, and the ECJ Tutorials are a good starting point for learning how to develop your own evolutionary computation application. Most ECJ applications will run with little modification under Origin; Converting ECJ Applications to Origin explains this in more detail.
Origin Frontier Grid tasks run in a restricted JVM "sandbox" similar to the sandbox used by Java applets. Code running in the sandbox has extremely limited access to the local system: in particular it cannot access the file system or open network connections. Classes in your application such as fitness evaluators that will run remotely on the grid must follow these rules:
File
object returned from
getFile().
The Origin SDK and third-party jars in the lib directory must be on your compilation classpath. Don't use different versions of these jars - the included versions are the ones Origin has been tested with.
Classes used in your Origin run must be packaged into jar files, and these jars must be included on the Origin runtime classpath. If you have a lot of code that's only used by the local component of your application you should package this in a separate jar to reduce the amount of code that needs to be sent to the Frontier Compute Engines.
Origin provides a sample application directory skeleton and ant build files in the sample-application directory. You can copy this directory and use it as a starting point for developing your own applications. The directory contents are:
After copying this directory edit setup/setup.xml and change the value of origin.dir (at the top of the file) to the location of the Origin directory.
When you run ant in this directory the Ant build files will compile all source code in the src directory, construct a task and application jar, and copy the jars, libraries, configuration files, and documentation to dist/projectname.
If your tasks uses additional jars such as third-party components Origin needs to send these jars to the Frontier Grid Server for distribution to the Compute Engines. In most cases Origin will automatically identify these jars and send them, but sometimes Origin needs additional information about the jars required by your application. Origin uses the Job Manifest entry in your application's jar file to locate these jars. If you use the ant build files in the sample application directory this manifest will be created automatically and added to the application jar when it's built.
The Frontier Job Manifest is an XML file listing required jars and their location in the local filesystem. The job manifest has the form:
<?xml version="1.0" encoding="UTF-8"?>
<job-manifest name="appname">
<executable-element name="jarname" file="jarpath"/>
<executable-element .../>
:
</job-manifest>
Each jar has an executable-element element
giving the jar a unique name and specifying the jar file pathname. If a
pathname is relative and doesn't exist
Origin will search the runtime classpath for the jar. Note that you should only include jars required by
remote task code: jars used only locally (GUI libraries, database drivers, etc.) should not
be listed.
The job manifest must be stored as PARABON-META/JOB-MANIFEST
in your application's jar file.
If you're using Ant you can use the Frontier SDK jobmanifest Ant task to generate the Frontier job manifest. First define the Frontier SDK Ant task definitions (if your build files include the setup/setup.xml and setup/common.xml files from the Origin source distribution this is done for you):
<taskdef description="Frontier SDK ant tasks"
resource="com/parabon/client/antlib.xml"
classpathref="classpath-containing-frontier-sdk.jar"
/>
Generate the manifest like this (you'll need to add it to the application jar file afterwards):
<jobmanifest jobname="application-name"
destfile="${build.dir}/PARABON-META/JOB-MANIFEST"
listfiles="true"
>
<classpath>
<path refid="jars-used-by-tasks"/>
</classpath>
<excludepath>
<path refid="jars-to-exclude"/>
</excludepath>
</jobmanifest>
This will generate a manifest containing all jars on the classpath jars-used-by-tasks except
for those also on jars-to-exclude. One advantage of using the jobmanifest
Ant task is that if you add or remove jars from the compilation classpath in the Ant build file these changes
will automatically be reflected in the Frontier job manifest the next time the manifest is generated.
When Origin runs a Frontier Grid enabled evolutionary model it scans the parameter database for parameters referencing classes and data files that are required by Origin tasks and packages these classes and files with the task. If a parameter references a class the class' jar file is located and the jar file and any additional jars listed in the jar's Frontier job manifest are included with the Origin task.
When a parameter specifies a file pathname and the file exists Origin converts the file to a Frontier data element and sends the element with the task. The remote task can read the data element by calling getInputStream(). Since the parameter database is scanned only once when Origin starts any changes made locally to the data files during an evolutionary run will not be visible to remote tasks.
Origin uses a parameter naming scheme to identify class and input file parameters.
If parametername.slave-class is set to true then parametername
is a class parameter, and the jar containing this class will be included with remote tasks.
Any parameter with a name ending in
.file is treated as a file parameter unless
parametername.slave-file is also defined; if slave-file is true parametername
is a file parameter regardless of its name, and if it's set to false
parametername is not a file parameter.
even if it ends in .file.
The standard set of class and file parameters is defined in origin/conf/params/com/parabon/ec/origin.params.
Because Origin is based on ECJ many ECJ applications will run under Origin without modification. There are a few areas where Origin is incompatible with ECJ:
Output or ParameterDatabase or directly access fields in these
classes.Debugging an Origin application running on the Frontier grid may seem difficult since you have little visibility into the behavior of grid tasks other than their returned results- or fatal exception messages. These are a some helpful methods you can use to debug your application:
Some common errors encountered in Origin applications are described below:
-source 1.5 and -target 1.5 flags to javac or set the
equivalent options in your IDE's project settings (for Eclipse select
Project → Properties → Java Compiler and set
Compiler Compliance Level
to 5.0). The Origin Ant build.xml files set these flags automatically.parametername.slave-class = true for the class' parameter
as described in Class and Input File Parameters. If the class is in a
separate jar add this jar to the applications Frontier Job Manifest
and rebuild the application's jar.DOCTYPE ... SYSTEM "http:some-url.dtd". Some
XML parsers will attempt to read this URL when parsing the document, violating the
sandbox restrictions on network access. You can often resolve this by parsing the document in non-validating
mode.seed.0 is set to a constant value rather than
time (which seeds the random number generator from the system time).
If your fitness evaluation methods perform complex floating-point calculations you may need to use
the strictfp
modifier to produce consistent results on different JVM implementations.| $Date: 2008-07-14 09:05:15 -0400 (Mon, 14 Jul 2008) $ |
|