1 10 package org.jgap.impl; 11 12 import org.jgap.*; 13 14 21 public class StaticFitnessFunction 22 extends FitnessFunction implements Comparable { 23 24 25 private final static String CVS_REVISION = "$Revision: 1.10 $"; 26 27 30 private double m_staticFitnessValue; 31 32 38 public StaticFitnessFunction(double a_staticFitnessValue) { 39 m_staticFitnessValue = a_staticFitnessValue; 40 } 41 42 49 public double evaluate(IChromosome a_chrom) { 50 double result = m_staticFitnessValue; 51 return result; 52 } 53 54 60 public double getStaticFitnessValue() { 61 return m_staticFitnessValue; 62 } 63 64 71 public void setStaticFitnessValue(double a_staticFitnessValue) { 72 m_staticFitnessValue = a_staticFitnessValue; 73 } 74 75 public int hashCode() { 76 int result = new Double (m_staticFitnessValue).hashCode(); 77 return result; 78 } 79 80 87 public int compareTo(Object a_other) { 88 StaticFitnessFunction other = (StaticFitnessFunction)a_other; 89 if (m_staticFitnessValue > other.m_staticFitnessValue) { 90 return 1; 91 } 92 else if (m_staticFitnessValue < other.m_staticFitnessValue) { 93 return -1; 94 } 95 else { 96 return 0; 97 } 98 } 99 } 100 | Popular Tags |