#45 ArrayIndexOutOfBoundsException evolving

next JGAP version
closed-fixed
Klaus
8
2007-07-10
2007-07-05
No

Hello, I'm trying to implement the following genetic algorithm usign JGAP.

http://www.neu.edu.cn/wisa2005/report/Immune%20Algorithm%20for%20Selecting%20Optimum%20Services%20in%20Web%20Services%20Composition.pdf

I downloaded the 3.2 version and I have created a class to assign the fittness values according to the algorithm. Attached is the code that I'm using to initialize the structures. When running it, I'm
getting the following error:

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2
at java.util.Vector.get(Vector.java:694)
at org.jgap.Population.getChromosome(Population.java:257)
at org.jgap.impl.GABreeder.evolve(GABreeder.java:87)
at org.jgap.Genotype.evolve(Genotype.java:224)
at cna.example.selection.program.WSSelectionAlgorithm.findBestSelectionGenetic(WSSelectionAlgorithm.java:105)
at cna.example.selection.program.WSSelectionAlgorithm.main(WSSelectionAlgorithm.java:289)

Executing the some unit tests also I get the same error. I've downgraded to 3.1 and it seems to work now.

Discussion

  • Klaus

    Klaus - 2007-07-09

    Logged In: YES
    user_id=722855
    Originator: NO

    Hmmm, I'll check that. Sorry for the later answer, had been on a busines trip.
    After running the unit tests, none failed on my machine. Could you tell me which one you mean? Possibly the code changed since you downloaded JGAP 3.2, and the CVS version is correct.

     
  • Klaus

    Klaus - 2007-07-09
    • labels: --> coding error
    • milestone: --> next JGAP version
    • priority: 5 --> 8
    • assigned_to: nobody --> klausikm
     
  • Klaus

    Klaus - 2007-07-09

    Logged In: YES
    user_id=722855
    Originator: NO

    OK, I think you mean the Fibonacci example. When running it I get the error you described.

    Fix: Either check out from CVS or change class GABreeder in method evolve(Population, Configuration) as follows:
    ---

    OLD:
    // Increase age of all chromosomes which are not modified by genetic
    // operations.
    // -----------------------------------------------------------------
    for (int i = 0; i < originalSize; i++) {

    --

    NEW:
    // Increase age of all chromosomes which are not modified by genetic
    // operations.
    // -----------------------------------------------------------------
    int size = Math.min(originalPopSize, currentPopSize);
    for (int i = 0; i < size; i++) {

    ---

    HTH

    Klaus

     
  • Klaus

    Klaus - 2007-07-09
    • status: open --> open-fixed
     
  • Klaus

    Klaus - 2007-07-10

    Logged In: YES
    user_id=722855
    Originator: NO

    I'm setting this to fixed as I believe it is. A new unit test testEvolve_10 in class GenotypeTest exposes the bug.
    The next release 3.2.1 to appear soon contains the fix of course.

     
  • Klaus

    Klaus - 2007-07-10
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.