SharpNeat.Decoders.HyperNeat.Substrate.Substrate C# (CSharp) Method

Substrate() public method

Constructs with the provided substrate nodesets and mappings that describe how the nodesets are to be connected up.
public Substrate ( List nodeSetList, IActivationFunctionLibrary activationFnLibrary, int activationFnId, double weightThreshold, double maxWeight, List nodeSetMappingList ) : System
nodeSetList List Substrate nodes, represented as distinct sets of nodes. By convention the first and second /// sets in the list represent the input and output noes respectively. All other sets represent hidden nodes.
activationFnLibrary IActivationFunctionLibrary The activation function library allocated to the networks that are 'grown' from the substrate.
activationFnId int The ID of an activation function in activationFnLibrary. This is the activation function /// ID assigned to all nodes in networks that are 'grown' from the substrate.
weightThreshold double The weight threshold below which substrate connections are not created in grown networks.
maxWeight double Defines the weight range of grown connections (+-maxWeight).
nodeSetMappingList List A list of mappings between node sets that defines what connections to create between substrate nodes.
return System
        public Substrate(List<SubstrateNodeSet> nodeSetList, 
                         IActivationFunctionLibrary activationFnLibrary, int activationFnId,
                         double weightThreshold, double maxWeight,
                         List<NodeSetMapping> nodeSetMappingList)
        {
            VaildateSubstrateNodes(nodeSetList);

            _nodeSetList = nodeSetList;
            _inputNodeCount =  _nodeSetList[0].NodeList.Count;
            _outputNodeCount =  _nodeSetList[1].NodeList.Count;
            _dimensionality = _nodeSetList[0].NodeList[0]._position.GetUpperBound(0) + 1;

            _activationFnLibrary = activationFnLibrary;
            _activationFnId = activationFnId;

            _weightThreshold = weightThreshold;
            _maxWeight = maxWeight;
            _weightRescalingCoeff = _maxWeight / (1.0 - _weightThreshold);

            _nodeSetMappingList = nodeSetMappingList;
            
            // Get an estimate for the number of connections defined by mappings.
            int nonBiasConnectionCountHint = 0;
            foreach(NodeSetMapping mapping in nodeSetMappingList) {
                nonBiasConnectionCountHint += mapping.GetConnectionCountHint(nodeSetList);
            }

            if(nonBiasConnectionCountHint <= ConnectionCountCacheThreshold)
            {   
                // Pre-generate the substrate connections and store them in a list.
                _connectionList = _connectionCountHint == 0 ? new List<SubstrateConnection>() : new List<SubstrateConnection>(nonBiasConnectionCountHint);
                foreach(NodeSetMapping mapping in nodeSetMappingList)
                {
                    IEnumerable<SubstrateConnection> connectionSequence = mapping.GenerateConnections(nodeSetList);
                    foreach(SubstrateConnection conn in connectionSequence) {
                        _connectionList.Add(conn);
                    }
                }
                _connectionList.TrimExcess();
            }

            // Set total connection count hint value (includes additional connections to a bias node).
            _connectionCountHint = nonBiasConnectionCountHint + CalcBiasConnectionCountHint(nodeSetList);

            // Pre-create the network definition node list. This is re-used each time a network is created from the substrate.
            _netNodeList = CreateNetworkNodeList();
        }

Same methods

Substrate::Substrate ( List nodeSetList, IActivationFunctionLibrary activationFnLibrary, int activationFnId, double weightThreshold, double maxWeight, List connectionList ) : System