Ejemplo n.º 1
0
        protected override void Mutation()
        {
            synapse = Network.GetRandomSynapse();
            oldDestination = synapse._input;

            synapse._input = Network.GetRandomNode();
        }
Ejemplo n.º 2
0
        protected override void Mutation()
        {
            canImproveNext = true;

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

            modifedSynapse.Weight = NeuralHelper.GetRandomWeigth();
        }
Ejemplo n.º 3
0
        protected override void Rollback()
        {
            outputNeuron.InputSynapses.Remove(synapseToOutput);

            Network.Neurons.Remove(insertedNeuron);

            Network.Synapses.Remove(synapseToInput);
            Network.Synapses.Remove(synapseToOutput);

            inputNeuron = null;
            synapseToInput = null;
            synapseToOutput = null;
        }
Ejemplo n.º 4
0
        protected override void Mutation()
        {
            removedSynapse = Network.GetRandomSynapse();

            if (Network.Synapses.Count < 3 || Network.Effectors.Exists(e => e._input == removedSynapse))
            {
                fail = true;
                return;

            }

            fromNeuron = Network.Neurons.First(n => n.InputSynapses.Contains(removedSynapse));

            fromNeuron.InputSynapses.Remove(removedSynapse);
            Network.Synapses.Remove(removedSynapse);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
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());
            }
        }