コード例 #1
0
 /// <summary>
 /// Constructs a new instance of the <see cref="ChromosomeMetadata"/> class.
 /// </summary>
 internal PopulationMetadata()
 {
     Size               = DEFAULT_SIZE;
     SurvivalRate       = DEFAULT_SURVIVAL_RATE;
     DistanceThreshold  = DEFAULT_DISTANCE_THRESHOLD;
     SelectionAlgorithm = GeneticFactory.ConstructSelectionAlgorithm(DEFAULT_SELECTION_ALGORITHM);
 }
コード例 #2
0
        /// <summary>
        /// Parses a SelectionAlgorithm element.
        /// </summary>
        /// <param name="element">The SelectionAlgorithm element.</param>
        /// <returns>The parsed selection algorithm.</returns>
        private static ISelectionAlgorithm ParseSelectionAlgorithm(XElement element)
        {
            var attributes    = element.Attributes();
            var typeAttribute = attributes.FirstOrDefault(attribute => attribute.Name.LocalName == "Type");
            var argAttribute  = attributes.FirstOrDefault(attribute => attribute.Name.LocalName == "Arg");

            var algorithm = (SelectionAlgorithm)Enum.Parse(typeof(SelectionAlgorithm), typeAttribute.Value);

            return(GeneticFactory.ConstructSelectionAlgorithm(algorithm, argAttribute?.Value));
        }