예제 #1
0
        /// <summary>
        /// Try to mutate the node into another one if rand is below mutation ratio.
        /// If not return the originalNode
        /// </summary>
        /// <param name="originalNode">The original node</param>
        /// <returns>The mutated node (or the original one)</returns>
        private bool TryMutate(Node originalNode, out Node mutatedNode)
        {
            //Improvement: Mutate by average; Reduce root mutation ratio through generations ?
            if (randsource.NextDouble() < MutationRatio)
            {
                MutationCount++;

                mutatedNode = RandomNodeSource.GetRandomNode(MutationRatio, randsource);
                return(true);
            }
            mutatedNode = originalNode;
            return(false);
        }
예제 #2
0
 /// <summary>
 /// Get a randomized graph
 /// </summary>
 /// <returns>The root node of the randomized graph</returns>
 public Node GetRandomGraph(Random randomsource)
 {
     return(RandomNodeSource.GetRandomNode(1.0, randomsource));
 }