Encog.Neural.Networks.BasicNetwork.EnableConnection C# (CSharp) Method

EnableConnection() public method

Enable, or disable, a connection.
public EnableConnection ( int fromLayer, int fromNeuron, int toNeuron, bool enable ) : void
fromLayer int The layer that contains the from neuron.
fromNeuron int The source neuron.
toNeuron int The target connection.
enable bool True to enable, false to disable.
return void
        public void EnableConnection(int fromLayer,
                                     int fromNeuron, int toNeuron, bool enable)
        {
            double v = GetWeight(fromLayer, fromNeuron, toNeuron);

            if (enable)
            {
                if (!_structure.ConnectionLimited)
                {
                    return;
                }

                if (Math.Abs(v) < _structure.ConnectionLimit)
                {
                    SetWeight(fromLayer, fromNeuron, toNeuron,
                              RangeRandomizer.Randomize(-1, 1));
                }
            }
            else
            {
                if (!_structure.ConnectionLimited)
                {
                    SetProperty(TagLimit,
                                DefaultConnectionLimit);
                    _structure.UpdateProperties();
                }
                SetWeight(fromLayer, fromNeuron, toNeuron, 0);
            }
        }