Exemple #1
0
 /// <summary>
 /// Used to create a controled tree with the nodes being specified and the type
 /// </summary>
 /// <param name="operatorType"></param>
 /// <param name="left"></param>
 /// <param name="right"></param>
 public Operator(OperatorEnum operatorType, Node left, Node right)
 {
     OperatorType = operatorType;
     _left = left;
     _right = right;
     _divideByZeroFlag = false;
 }
Exemple #2
0
 /// <summary>
 /// Creates a Node with the root of the tree specified.
 /// </summary>
 /// <param name="root">The root node of the tree the individual contains</param>
 public Individual(Node root)
 {
     _root = root;
 }
Exemple #3
0
 /// <summary>
 /// Creates a new individual with a random nodes.
 /// </summary>
 public Individual()
 {
     _root = new Operator();
 }
Exemple #4
0
 /// <summary>
 /// Returns true if the individual has grown.
 /// Returns false if the individual does not need to grow.
 /// </summary>
 /// <returns></returns>
 public bool Grow()
 {
     if (_root.Size() < Settings.MinTreeHeight)
         if (_root.HasChildren())
             return _root.Grow(1);
         else
         {
             _root = new Operator();
             return true;
         }
     else
         return false;
 }