LISTSERV mailing list manager LISTSERV 16.0

Help for ECJ-INTEREST-L Archives


ECJ-INTEREST-L Archives

ECJ-INTEREST-L Archives


ECJ-INTEREST-L@LISTSERV.GMU.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

ECJ-INTEREST-L Home

ECJ-INTEREST-L Home

ECJ-INTEREST-L  November 2010

ECJ-INTEREST-L November 2010

Subject:

Re: ECJ as a library?

From:

Sean Luke <[log in to unmask]>

Reply-To:

ECJ Evolutionary Computation Toolkit <[log in to unmask]>

Date:

Sat, 27 Nov 2010 12:36:55 -0500

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (125 lines)

On Nov 27, 2010, at 7:35 AM, Lucian Ionita wrote:

> Hello,
>
> I'm researching ECJ for use in a course project (together with
> MASON, mind you). I've read the tutorials but they only show how to
> use it as a stand alone program, when I need it more as a library,
> so I can control it from within a java program, just like I do with
> MASON. I'm sure that this is possible, but I want to ask if there is
> some tutorial or example available or do I have to dig into the
> ec.Evolve class to find out how to use it that way?
>
> Best regards,
> Lucian Ionita



ECJ can absolutely be used as a library -- it's entirely self-
contained -- but it requires a bit of elbow grease. For example, I
was recently modifying ECJ in an experimental test on meta-evolution,
where one ECJ process would evaluate individuals by using them to
define parameters for other ECJ processes. Some information:

0. Be sure to use the version on the current SVN repository, not the
snapshot (we'll remedy that soon).

1. You may wish to control Output's dumping of announcements to
STDERR. Ordinarily ECJ creates two logs by default. Log 0 goes to
STDOUT and log 1 goes to STDERR. Only the STDERR log is set up to
receive announcements. So you may need to hush up STDERR, or perhaps
redirect it elsewhere: but we've recently gotten rid of verbosity.
How would you do it The simplest ECJ top-level loop looks like this

public static void main(String[] args)
{
EvolutionState state = Evolve.possiblyRestoreFromCheckpoint(args);
if (state!=null) // loaded from checkpoint
state.run(EvolutionState.C_STARTED_FROM_CHECKPOINT);
else
{
ParameterDatabase parameters = Evolve.loadParameterDatabase(args);
state = Evolve.initialize(parameters, 0);
state.run(EvolutionState.C_STARTED_FRESH);
}
Evolve.cleanup(state);
System.exit(0);
}

We can simplify this further by eliminating the ability to restore
from checkpoint, and preventing an exit(0). Then we get:

public static void main(String[] args)
{
ParameterDatabase parameters = Evolve.loadParameterDatabase(args);
state = Evolve.initialize(parameters, 0);
state.run(EvolutionState.C_STARTED_FRESH);
Evolve.cleanup(state);
}

The problem here is that the creation of the Output and the STDOUT and
STDERR logs appears in Evolve.initialize(...). You can replace that
method -- just do some cut and paste -- to delete the STDERR log. Or
I just committed to SVN a new version of the initialize method which
gives you more control over Output, allowing you to do this:

public static void main(String[] args)
{
ParameterDatabase parameters = Evolve.loadParameterDatabase(args);
Output output = new Output();
         output.addLog(ec.util.Log.D_STDOUT,false);
         // output.addLog(ec.util.Log.D_STDERR,true); // no talking
out STDERR
initialize(parameters, 0, output);
state = Evolve.initialize(parameters, 0);
state.run(EvolutionState.C_STARTED_FRESH);
Evolve.cleanup(state);
}

All other disk accesses can be controlled in the parameters.



2. If you're repeatedly making new evolutionary runs, may need to load
a parameter database and reuse it instead of reloading from disk. To
begin you may want to control the parameter database that's loaded
rather than just passing in args. You can do that with something like:

String myParameterDatabaseFile = ... ;
ParameterDatabase parameters = Evolve.loadParameterDatabase(
new String[] {"-file", myParameterDatabaseFile});

Second, you may wish to reuse this rather than reloading from disk.
You can do this easily like this:


String myParameterDatabaseFile = ... ;
ParameterDatabase template = Evolve.loadParameterDatabase(
new String[] {"-file", myParameterDatabaseFile});

... now whenever you want to make a parameter database, you just say:

ParameterDatabase database = new ParameterDatbase();
database.addParent(template);

template is never modified: all modifications are made to just database.

Note that I'm planning on releasing a major modification of
ParameterDatabase which makes it more easily used in JAR files. But
it'll posted to SVN after the upcoming snapshot because I don't know
how stable it will be.


3. Which brings us to jar files. You can jar up ECJ but will find
that it expects to open parameter database files and other resources
as Files, which is a problem. I'm making modifications to the
ParameterDatabase system to enable the entire library to exist inside
a single jar file if you really need it. But it won't be out until
after the snapshot. [Some early preparatory changes have already been
made prior to the snapshot].


If you're interested in seeing ECJ running as a subprocess of another
ECJ process, get ahold of me and I can throw you some code.

Sean

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

September 2019
August 2019
June 2019
April 2019
March 2019
January 2019
December 2018
November 2018
October 2018
July 2018
May 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004

ATOM RSS1 RSS2



LISTSERV.GMU.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager