Print

Print


Alex,

If I understand correctly, you want to have some graphic interface that
displays the best-so-far individual while ECJ runs.  From what you
describe, I understand you try to create this in the postEvaluation
function.

Personally, I this is how I would approach this issue (and probably your
approach is very close as well): I would instantiate the graphics thread
in the statistics' setup function, such a way that it is created only once
per run.  The graphics should deepClone() the best-so-far individual, as
it is possibly to be destroyed soon by the breeding operations in the next
generation.  In the postEvaluation() method, I would tell the graphics
thread to update the information on the best-so-far, and I would wait for
it to deepClone() the best-so-far individual.

Is it possible that you do not wait for it to copy, and the evolution goes
further and the individual is modified while you try to display it? That
may cause some problems....

Also, if you want to block the statistics thread, you can extend the
statistics class and override the postEvaluation statistics.  It could
look like this:

public void postEvaluationStatistics(final EvolutionState state)
{
    // call the super's method to do the actual statistics
    super.postEvaluationStatistics(state);

    // tell the graphics interface to start displaying the new individual.
    // if you extend SimpleStatistics, you have the best_of_run vector
    // available.
    displayIndividual( best_of_run[0].deepClone() );

    // at this point I do not think you actually need to wait for
    // anything, because you deepClone()-d the information you needed for
    // the other thread.  But anyway, if you want to stop the
    // statistics thread for some time, this is the place.
}

Hope this works.

Regards,

Liviu.

On Fri, 26 Mar 2004, Alexandre Sauve wrote:

> Hi,
>
> Well I am trying to do something a little interesting.  I want to
> display a graphic with a demonstration of my latest GP tree built.  The
> demonstration is to visualize how the GP is learning through iterations,
> but I am having some trouble creating my dialog in the postEvaluation
> section of the statistics... Below is the stack trace that I receive...
>
> AWT blocker activation interrupted:
> java.lang.InterruptedException
>     at java.lang.Object.wait(Native Method)
>     at java.lang.Object.wait(Unknown Source)
>     at sun.awt.AWTAutoShutdown.activateBlockerThread(Unknown Source)
>     at sun.awt.AWTAutoShutdown.setToolkitBusy(Unknown Source)
>     at sun.awt.AWTAutoShutdown.notifyToolkitThreadBusy(Unknown Source)
>     at sun.awt.windows.WToolkit.<init>(Unknown Source)
>     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>     at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
>     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
> Source)
>     at java.lang.reflect.Constructor.newInstance(Unknown Source)
>     at java.lang.Class.newInstance0(Unknown Source)
>     at java.lang.Class.newInstance(Unknown Source)
>     at java.awt.Toolkit$2.run(Unknown Source)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.awt.Toolkit.getDefaultToolkit(Unknown Source)
>     at java.awt.Window.getToolkit(Unknown Source)
>     at java.awt.Window.init(Unknown Source)
>     at java.awt.Window.<init>(Unknown Source)
>     at java.awt.Frame.<init>(Unknown Source)
>     at java.awt.Frame.<init>(Unknown Source)
>     at javax.swing.SwingUtilities$1.<init>(Unknown Source)
>     at javax.swing.SwingUtilities.getSharedOwnerFrame(Unknown Source)
>     at javax.swing.JDialog.<init>(Unknown Source)
>     at javax.swing.JDialog.<init>(Unknown Source)
>     at javax.swing.JDialog.<init>(Unknown Source)
>     at ant.gui.AntDialog.<init>(AntDialog.java:90)
>     at ant.gui.GPGuiRunner.run(GPGuiRunner.java:14)
>
> the GPGuiRunner is simply a wrapper thread class.  I thought that it
> would be less affected if running within its own thread, but it seems
> that the thread that is responsible for the statistics output cannot be
> blocked (always immediately results in a InterruptException)... I have
> tried to find out why this is so, but so far to little avail... I need
> to know how to do this ASAP unfortunately, as the assignment is due
> early next week... Thanks... And by the way great tool you have developed!!!
>
> ALex
>