예제 #1
0
 public void saveState(PopulationInterface Pop) {
   oldFit = Pop.getBestFitness().clone();
   oldNorm = PhenotypeMetric.norm(oldFit);
   popFitCalls = Pop.getFunctionCalls();
   popGens = Pop.getGeneration();
   firstTime = false;
 }
예제 #2
0
 private boolean stagnationTimeHasPassed(PopulationInterface pop) {
   if (stagnationMeasure.isSelectedString("Fitness calls")) { // by fitness calls
     //			System.out.println("stagnationTimeHasPassed returns " + ((pop.getFunctionCalls() -
     // popFitCalls) >= m_stagTime) + " after " + (pop.getFunctionCalls() - popFitCalls));
     return (pop.getFunctionCalls() - popFitCalls) >= m_stagTime;
   } else { // by generation
     //			System.out.println("stagnationTimeHasPassed returns " + ((pop.getFunctionCalls() -
     // popGens) >= m_stagTime) + " after " + (pop.getFunctionCalls() - popGens));
     return (pop.getGeneration() - popGens) >= m_stagTime;
   }
 }
예제 #3
0
 /**
  * Return true if |oldFit - curFit| < |oldFit| * thresh (relative case) and if |oldFit - curFit| <
  * thresh (absolute case).
  *
  * @param
  * @return
  */
 protected boolean isStillConverged(PopulationInterface pop) {
   double[] curFit = pop.getBestFitness();
   double dist = EuclideanMetric.euclideanDistance(oldFit, curFit);
   boolean ret;
   if (convergenceCondition.isSelectedString("Relative")) {
     ret = (dist < (oldNorm * convThresh));
   } else {
     ret = (dist < convThresh);
   }
   return ret;
 }