Menu

#36 Configuration.removeNaturalSelector does not clear Vector

next JGAP version
closed-fixed
Klaus
9
2007-01-23
2007-01-23
No

Hello,

the "removeNaturalSelectors()" method org.jgap.Configuration does not clear the chain of selectors. Instead it only resets m_sizeNaturalSelectors{Pre|Post}. I'm uncertain if this is the intended behaviour.

If this is a bug, I'd propose the following patch.

Regards,
Christoph

Index: src/org/jgap/Configuration.java

RCS file: /cvsroot/jgap/jgap/src/org/jgap/Configuration.java,v
retrieving revision 1.72
diff -u -r1.72 Configuration.java
--- src/org/jgap/Configuration.java 22 Jan 2007 14:31:07 -0000 1.72
+++ src/org/jgap/Configuration.java 23 Jan 2007 11:00:45 -0000
@@ -778,11 +778,11 @@
public void removeNaturalSelectors(final boolean
a_processBeforeGeneticOperators) {
if (a_processBeforeGeneticOperators) {
- getNaturalSelectors(true);
+ getNaturalSelectors(true).clear();
m_sizeNaturalSelectorsPre = 0;
}
else {
- getNaturalSelectors(false);
+ getNaturalSelectors(false).clear();
m_sizeNaturalSelectorsPost = 0;
}
}

Discussion

  • Klaus

    Klaus - 2007-01-23

    Logged In: YES
    user_id=722855
    Originator: NO

    You are absolutely right! It is a bug. I wonder how it could have prevailed that long!
    I added some unit tests to expose the bug and fixed it as you suggested. Changes are checked in.

    Thanx, Christoph!

    Best

    Klaus

     
  • Klaus

    Klaus - 2007-01-23
    • priority: 5 --> 9
    • assigned_to: nobody --> klausikm
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB