Esempio n. 1
0
        public static CSNeuroNet FromByteArray(byte[] array)
        {
            int i        = 0;
            int inputsc  = BitConverter.ToInt32(array, i); i += 4;
            int outputsc = BitConverter.ToInt32(array, i); i += 4;

            CSNeuroNet result = new CSNeuroNet(inputsc, outputsc);

            int nodesC = BitConverter.ToInt32(array, i); i += 4;

            for (int k = 0; k < nodesC; ++k)
            {
                Node n = new Node(BitConverter.ToInt32(array, i)); i += 4;
                n.Value = BitConverter.ToDouble(array, i); i += 8;
                result.AddNode(n);
            }

            int connectionsCount = BitConverter.ToInt32(array, i); i += 4;

            for (int k = 0; k < connectionsCount; ++k)
            {
                int    id     = BitConverter.ToInt32(array, i); i += 4;
                int    from   = BitConverter.ToInt32(array, i); i += 4;
                int    to     = BitConverter.ToInt32(array, i); i += 4;
                double weight = BitConverter.ToDouble(array, i); i += 8;

                Connection c = new Connection(id, from, to, weight);
                result.AddConnection(c);
            }
            return(result);
        }