Ejemplo n.º 1
0
 /// <summary>
 /// Record a unique genome
 /// </summary>
 /// <param name="genome">genome to be record</param>
 public void setGenomeLog(IGenome genome)
 {
     xtw.WriteStartElement("Genome");
     xtw.WriteAttributeString("Value", genome.ToString());
     xtw.WriteAttributeString("Fitness", genome.Evaluate().ToString());
     xtw.WriteEndElement();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Record a unique genome
 /// </summary>
 /// <param name="genome">genome to be record</param>
 public void setGenomeLog(IGenome genome)
 {
     xtw.WriteStartElement("Genome");
     xtw.WriteAttributeString("Value", genome.ToString());
     xtw.WriteAttributeString("Fitness", genome.Evaluate().ToString());
     xtw.WriteEndElement();
 }
Ejemplo n.º 3
0
        public int CompareTo(IGenome other)
        {
            //if this is the smaller genome
            if (Evaluate() < other.Evaluate())
            {
                return(-1);
            }

            // else if this is the biggest genome
            else if (Evaluate() > other.Evaluate())
            {
                return(1);
            }

            // otherwise they are equal
            else
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Get the best genome based in the fitness' value
 /// </summary>
 /// <returns>the best genome</returns>
 public IGenome getBest()
 {
     if (this.Length > 0)
     {
         IGenome best = this[0];
         for (int i = 1; i < this.Length; i++)
         {
             if (this[i].Evaluate() > best.Evaluate())
             {
                 best = this[i];
             }
         }
         return(best);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
        public int CompareTo(IGenome other)
        {
            //if this is the smaller genome
            if (Evaluate() < other.Evaluate())
                return -1;

            // else if this is the biggest genome
            else if (Evaluate() > other.Evaluate())
                return 1;

            // otherwise they are equal
            else
                return 0;
        }