Пример #1
0
        protected override void Mutation()
        {
            do
            {
                outputNeuron = Network.GetRandomNeuron();
                inputNeuron  = Network.GetRandomNeuron();
            } while ((inputNeuron == outputNeuron));

            insertedNeuron = new Neuron(ActivationFunc);

            synapseToOutput = new Synapse(insertedNeuron)
            {
                Weight = NeuralHelper.GetRandomWeigth()
            };
            outputNeuron.InputSynapses.Add(synapseToOutput);

            synapseToInput = new Synapse(inputNeuron)
            {
                Weight = NeuralHelper.GetRandomWeigth()
            };
            insertedNeuron.InputSynapses.Add(synapseToInput);



            Network.Neurons.Add(insertedNeuron);
            Network.Synapses.Add(synapseToOutput);
            Network.Synapses.Add(synapseToInput);
        }
        protected override void Mutation()
        {
            randomSynapse = Network.GetRandomSynapse();



            outputNeuron    = Network.Neurons.Find(n => n.InputSynapses.Contains(randomSynapse));
            inputConnection = randomSynapse._input;

            insertedNeuron = new Neuron(ActivationFunc);

            synapseToOutput = new Synapse(insertedNeuron)
            {
                Weight = NeuralHelper.GetRandomWeigth()
            };
            outputNeuron.InputSynapses.Add(synapseToOutput);

            synapseToInput = new Synapse(inputConnection)
            {
                Weight = NeuralHelper.GetRandomWeigth()
            };
            insertedNeuron.InputSynapses.Add(synapseToInput);

            outputNeuron.InputSynapses.Remove(randomSynapse);
            Network.Synapses.Remove(randomSynapse);


            Network.Neurons.Add(insertedNeuron);
            Network.Synapses.Add(synapseToOutput);
            Network.Synapses.Add(synapseToInput);
        }
Пример #3
0
        protected override void Mutation()
        {
            canImproveNext = true;

            modifedSynapse = Network.GetRandomSynapse();
            oldWeigth      = modifedSynapse.Weight;

            modifedSynapse.Weight = NeuralHelper.GetRandomWeigth();
        }
Пример #4
0
        protected override void Mutation()
        {
            //TODO: оптимизировать. Сделать добавление не только нейронов но и синапсов
            Network.MetricsRecitate();

            var rechoose = false;

            do
            {
                rechoose   = false;
                neuronFrom = Network.GetRandomNeuron();
                neuronTo   = Network.GetRandomNeuron();

                //Loop condition
                if (neuronFrom.Distance <= neuronTo.Distance)
                {
                    rechoose = true;
                    continue;
                }

                if (neuronTo.InputSynapses.Exists(n => n._input == neuronFrom))
                {
                    rechoose = true;
                }
            } while (rechoose);


            insertedSynapse = new Synapse(neuronFrom)
            {
                Weight = NeuralHelper.GetRandomWeigth()
            };;
            neuronTo.InputSynapses.Add(insertedSynapse);
            Network.Synapses.Add(insertedSynapse);

            Network.MetricsRecitate();

            if (Network.LoopDetected())
            {
                Rollback();
                Network.Neurons.ForEach(n => n.Reset());
            }
        }