Genotype.getFittestChromosomes(int n) method

View: New views
2 Messages — Rating Filter:   Alert me  

Genotype.getFittestChromosomes(int n) method

by Ary Junior-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I'm trying to use the Genotype.getFittestChromosomes(int n) method for, after finish the evolves method, get the best half of the initial population and begin a evolution again... when a try to reset the Configuration object like this:

...
Configuration conf = new Configuration(name, id);
... set the configuration attributes
// Evolve
Genotype population = null;
Population bestChromosomes;
while (populationSize > 3) {
    Configuration.reset();
    conf = new Configuration(name, id);
... re-set the configuration attributes
    conf.setPopulationSize(populationSize);
    if (population == null) {
        // Creating the initial random population
        population = Genotype.randomInitialGenotype(conf);
    } else {
        // Creating the population based on half of the last population
        bestChromosomes = new Population(conf, (IChromosome[]) population.getFittestChromosomes(populationSize).toArray());
        population = new Genotype(conf, bestChromosomes);
    }
    population.evolve(2);
    populationSize = populationSize / 2;
}


After I get the error:

Exception in thread "main" java.lang.RuntimeException: Fitness evaluator has already been set differently.
If you want to set or construct a configuration multiple times, please call static method Configuration.reset() before each setting!
        at org.jgap.Configuration.checkProperty(Configuration.java:549)
        at org.jgap.Configuration.setFitnessEvaluator(Configuration.java:1257)
        at br.ufjf.quimica.gfqsi.sst.ga.adsorbateposition.AdsorbatePositionGA.setConfiguration(AdsorbatePositionGA.java:230)
        at br.ufjf.quimica.gfqsi.sst.ga.adsorbateposition.AdsorbatePositionGA.beginGeneticAlgorithm(AdsorbatePositionGA.java:267)
        at br.ufjf.quimica.gfqsi.sst.ga.adsorbateposition.AdsorbatePositionGA.run(AdsorbatePositionGA.java:214)
        at br.ufjf.quimica.gfqsi.sst.SSTApp.main(SSTApp.java:215)

What is the best way to create a configuration multiple times?

Thanks very much!

Ary Junior

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jgap-users mailing list
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users

Re: Genotype.getFittestChromosomes(int n) method

by Klaus Meffert-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ary,
 
you have to call Configuration.reset() directly before the line where the exception is thrown. From the stack trace I cannot figure out exactly where this is in your code.
 
Best

Klaus
www.klaus-meffert.com

PS: If you like JGAP or RobocodeJGAP, maybe you are willing to vote for it on

http://sourceforge.net/community/cca08-nominate?group_id=11618

 


From: jgap-users-bounces@... [mailto:jgap-users-bounces@...] On Behalf Of Ary Junior
Sent: Saturday, June 07, 2008 1:52 AM
To: jgap-users@...
Subject: [jgap-users] Genotype.getFittestChromosomes(int n) method

Hi, I'm trying to use the Genotype.getFittestChromosomes(int n) method for, after finish the evolves method, get the best half of the initial population and begin a evolution again... when a try to reset the Configuration object like this:

...
Configuration conf = new Configuration(name, id);
... set the configuration attributes
// Evolve
Genotype population = null;
Population bestChromosomes;
while (populationSize > 3) {
    Configuration.reset();
    conf = new Configuration(name, id);
... re-set the configuration attributes
    conf.setPopulationSize(populationSize);
    if (population == null) {
        // Creating the initial random population
        population = Genotype.randomInitialGenotype(conf);
    } else {
        // Creating the population based on half of the last population
        bestChromosomes = new Population(conf, (IChromosome[]) population.getFittestChromosomes(populationSize).toArray());
        population = new Genotype(conf, bestChromosomes);
    }
    population.evolve(2);
    populationSize = populationSize / 2;
}


After I get the error:

Exception in thread "main" java.lang.RuntimeException: Fitness evaluator has already been set differently.
If you want to set or construct a configuration multiple times, please call static method Configuration.reset() before each setting!
        at org.jgap.Configuration.checkProperty(Configuration.java:549)
        at org.jgap.Configuration.setFitnessEvaluator(Configuration.java:1257)
        at br.ufjf.quimica.gfqsi.sst.ga.adsorbateposition.AdsorbatePositionGA.setConfiguration(AdsorbatePositionGA.java:230)
        at br.ufjf.quimica.gfqsi.sst.ga.adsorbateposition.AdsorbatePositionGA.beginGeneticAlgorithm(AdsorbatePositionGA.java:267)
        at br.ufjf.quimica.gfqsi.sst.ga.adsorbateposition.AdsorbatePositionGA.run(AdsorbatePositionGA.java:214)
        at br.ufjf.quimica.gfqsi.sst.SSTApp.main(SSTApp.java:215)

What is the best way to create a configuration multiple times?

Thanks very much!

Ary Junior

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jgap-users mailing list
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users