Ejemplo n.º 1
0
        /// <summary>
        /// Constructs a list of neural mutations operators.
        /// </summary>
        /// <param name="mutationOptions">The neural mutation options.</param>
        /// <param name="weight">The mutation weight.</param>
        /// <returns>The constructed neural mutations operators.</returns>
        public static List <IMutation> ConstructNeuralMutationOperators(NeuralMutation mutationOptions, double weight = 1)
        {
            var mutations = new List <IMutation>();

            if ((mutationOptions & NeuralMutation.Edge) == NeuralMutation.Edge)
            {
                mutations.Add(new EdgeMutation(weight));
            }
            if ((mutationOptions & NeuralMutation.Node) == NeuralMutation.Node)
            {
                mutations.Add(new NodeMutation(weight));
            }
            if ((mutationOptions & NeuralMutation.EnableDisable) == NeuralMutation.EnableDisable)
            {
                mutations.Add(new EnableDisableMutation(weight));
            }
            if ((mutationOptions & NeuralMutation.Weight) == NeuralMutation.Weight)
            {
                mutations.Add(new WeightMutation(weight));
            }
            if (mutations.Count == 0)
            {
                throw new ArgumentException("Error! Invalid neural mutation selection.");
            }

            return(mutations);
        }
Ejemplo n.º 2
0
        private NeuralChromosome GetMutation(NeuralChromosome chromosome, NeuralMutation mutation)
        {
            var rator = GeneticFactory.ConstructNeuralMutationOperators(mutation).First();

            return(rator.Invoke(chromosome) as NeuralChromosome);
        }