WeightedRouletteSelector one more time

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

WeightedRouletteSelector one more time

Krzysztof Chmielewski
Hello again :) Klaus, thank You very much for helping me with my previous question.
Please excuse me, my "newbie" programming questions, I do not have big experience in that filed, still learning :)
So I tried to use WeightedRouletteSelector and there were (still are) some problems.

So this is it:

1. Is this ok?:
        Configuration conf = new DefaultConfiguration();
        WeightedRouletteSelector wrs = new WeightedRouletteSelector();  
        conf.addNaturalSelector(wrs, false);

I'm trying to change the default natural selector, which  by default is BestChromosomesSelector. Am I doing it right?

2. In first when I start my program, there were a compilation error: NoClassDefFoundError: gnu/trove/THashMap
in WeightedRouletteSelector class in 48'th line: private THashMap m_wheel = new THashMap();  I did not have the gnu/trove library... so I downloaded it and added to project, but error didn't stop occurring. I have noticed that there were a problem with import in  WeightedRouletteSelector (import gnu.trove.*;) . So I added a new java class to my project and just Copy-Paste the whole WeightedRouletteSelector code and change import to import gnu.trove.map.hash.*; (the import gnu.trove.*; didn't works) and that works... no errors :). But.. (there is always a "but") there is a syntax error in 412th line:

  public Object clone() {
    try {
      WeightedRouletteSelector result = new WeightedRouletteSelector(
      result.m_wheel = (THashMap) m_wheel.clone();  <-- error: The method clone() from the type Object is not visible
      result.m_config = new WeightedRouletteSelConfig();
      result.m_config.m_doublettesAllowed = m_config.m_doublettesAllowed;
      return result;
    } catch (InvalidConfigurationException iex) {
      throw new CloneException(iex);

But program runs... without any errors, so I assumed that this public Object clone()  is never called (?)

So these are my question:
1. Is section 1 ok?
2. Why there is a problem with import gnu.trove.* in section 2
3. Why there is a syntax error in public Object clone()

Thank You for any help


This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
jgap-users mailing list
[hidden email]