Exemplo n.º 1
0
 /** As we want the maximum of the function, lower y's are less fit */
 public boolean lessFitThan(Dna defiant) {
   MinusXSquared d = (MinusXSquared) defiant;
   if (this.getY() < d.getY()) {
     return true;
   }
   return false;
 }
Exemplo n.º 2
0
 /** Detects if the solutions are the same */
 public boolean asFitAs(Dna defiant) {
   MinusXSquared d = (MinusXSquared) defiant;
   if (this.getY() == d.getY()) {
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
 /**
  * The crossover operation consists of calculating the simple mean between the x's of each dna
  * involved.
  */
 public Dna crossover(Dna dna) {
   MinusXSquared mxs = (MinusXSquared) dna;
   MinusXSquared newMxs = new MinusXSquared();
   double newX = (this.x + mxs.getX()) / 2;
   newMxs.setX(newX);
   return newMxs;
 }