September 2011


Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sean Luke <[log in to unmask]>
Reply To:
ECJ Evolutionary Computation Toolkit <[log in to unmask]>
Wed, 28 Sep 2011 17:30:38 -0400
text/plain (42 lines)
I've made some significant modifications to the ec.Evolve file and the ec.util.ParameterDatabase file which (if all goes well) enable ecj to be entirely within a jar file.  

Normally while running, ECJ reads files, such as the parameter database files, various data files that applications use (like Ant's trail file).  It does so in the natural way: by creating a File object (or more correctly, obtaining one from the parameter database), then opening a stream on that object.  The problem with this is that File objects only work in file systems.  Hence ECJ has traditionally been "unpacked" into its directory so files can be found.

My objective is to enable ECJ, and all its parameter files etc., to be wrapped up in a jar file.  To do this the applications must load files using a different procedure, specifically Class.getResourceAsStream().  To do this you'd provide two arguments: a class and a path relative to that class.  Java goes to the ".class" file of the class, then looks for a file relative to the location of that file.  The file can be in a jar file, or in a real file systems, or wherever, so it's pretty portable.

So I've added these facilities to ECJ's parameter database:

1. The parameter database can now be constructed from a class and a path relative to it.

2. If you do #1, then all parents are assumed to be also relative to that class.

3. You can load resources rather than files now, either from the file system or from within a jar file.  I have set up to do this.

4. There's a mechanism (the "@" sign) to specify parents or files which are relative to some other class. 

5. ec.Evolve now has new arguments which permit you to load from a parameter file located inside a jar file.

6. The Makefile now builds jar files as an option 	(make jar)

So now you can do stuff like this:

java -jar ecj.jar -from app/ant/ant.params

[or if ecj.jar is in your classpath]

java ec.Evolve -from app/ant/ant.params

You can still of course do it the old way, though it requires ECJ to be unpacked:

java ec.Evolve -file ec/app/ant.params

I've only set up the ant demo to do this right.  But it's out on SVN right now.  This is a major change but one of significant impact to ECJ's usefulness as a portable, self-contained system.  

It seems to work, but it'd be nice if I had some people banging on this and testing it.