[3.2.2] Exception on multiple calls to GPGenotype.evolve()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[3.2.2] Exception on multiple calls to GPGenotype.evolve()

Daniel Jue
Hi,

I was modifying the math problem example to look like the
MinimizingMakeChange example, in that the evolve() method is called
inside a loop, so that I can print progress out to the screen.

My goal was to do something like this:

for( int i = 0; i < MAX_ALLOWED_EVOLUTIONS; i++ )
{
    population.evolve();
//print some intermediate results
}
//print final output


If I just modify the code to look like this, with two calls to evolve,

                GPProblem problem = new MathProblem(config);
                GPGenotype gp = problem.create();
                gp.setVerboseOutput(true);
                gp.evolve();
                gp.evolve();
                gp.outputSolution(gp.getAllTimeBest());
                // problem.showTree(gp.getAllTimeBest(), "mathproblem_best.png");
                System.out.println("Done: " + gp.getAllTimeBest().getFitnessValue());

I get this error.  The WARN output is much longer than this, depending
on the size of the population.

[WARN] GPPopulation Prototype program reused because random program
did not satisfy constraints
[WARN] GPPopulation Prototype program reused because random program
did not satisfy constraints
[WARN] GPPopulation Prototype program reused because random program
did not satisfy constraints
[WARN] GPPopulation Prototype program reused because random program
did not satisfy constraints
Exception in thread "main" java.lang.NullPointerException
        at org.jgap.gp.impl.GPGenotype.outputSolution(GPGenotype.java:577)
        at myapp.model.gp.MathProblem.main(MathProblem.java:114)


Line 114 in main is

gp.outputSolution(gp.getAllTimeBest());

BTW I am using Java 1.5 in Eclipse.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users
Reply | Threaded
Open this post in threaded view
|

Re: [3.2.2] Exception on multiple calls toGPGenotype.evolve()

Klaus Meffert-5
Daniel,

thanx for your bug report. The error in JGAP is that a null object is
dereferenced. I fixed that and will check in the changes asap.
Is it correct that this error does not always occur but in a random fassion?
I could not reproduce it with the original code (MathProblem) in place,
adding two consecutive calls to evolve(). But I have only tried with the
newest code not released yet.

The warn messages say that no valid program coould be constructed randomly
after a certain number of tries. This can of course happen and is not an
error.

Best

Klaus
PS: I fixed a small bug that only seems to occur with Java 6: in class
MathProblem the variables vx, x and y should be protected instead of
private.

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf
> Of Daniel Jue
> Sent: Thursday, October 18, 2007 7:47 PM
> To: [hidden email]
> Subject: [jgap-users] [3.2.2] Exception on multiple calls
> toGPGenotype.evolve()
>
> Hi,
>
> I was modifying the math problem example to look like the
> MinimizingMakeChange example, in that the evolve() method is
> called inside a loop, so that I can print progress out to the screen.
>
> My goal was to do something like this:
>
> for( int i = 0; i < MAX_ALLOWED_EVOLUTIONS; i++ ) {
>     population.evolve();
> //print some intermediate results
> }
> //print final output
>
>
> If I just modify the code to look like this, with two calls to evolve,
>
> GPProblem problem = new MathProblem(config);
> GPGenotype gp = problem.create();
> gp.setVerboseOutput(true);
> gp.evolve();
> gp.evolve();
> gp.outputSolution(gp.getAllTimeBest());
> // problem.showTree(gp.getAllTimeBest(),
> "mathproblem_best.png");
> System.out.println("Done: " +
> gp.getAllTimeBest().getFitnessValue());
>
> I get this error.  The WARN output is much longer than this,
> depending on the size of the population.
>
> [WARN] GPPopulation Prototype program reused because random
> program did not satisfy constraints [WARN] GPPopulation
> Prototype program reused because random program did not
> satisfy constraints [WARN] GPPopulation Prototype program
> reused because random program did not satisfy constraints
> [WARN] GPPopulation Prototype program reused because random
> program did not satisfy constraints Exception in thread
> "main" java.lang.NullPointerException
> at
> org.jgap.gp.impl.GPGenotype.outputSolution(GPGenotype.java:577)
> at myapp.model.gp.MathProblem.main(MathProblem.java:114)
>
>
> Line 114 in main is
>
> gp.outputSolution(gp.getAllTimeBest());
>
> BTW I am using Java 1.5 in Eclipse.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users