Exemple #1
0
        public void saveNetworkOnFile(string path)
        {
            // Delete the file if it exists.
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            FileStream fs        = File.Create(path);
            string     netConfig = "";

            netConfig += "Rho " + this.rho + "\r\n";
            netConfig += "RhoInc " + this.rhoIncrement + "\r\n";
            netConfig += "Alpha " + this.alpha + "\r\n";
            netConfig += "Beta " + this.beta + "\r\n";
            netConfig += "CC " + this.complementCoding + "\r\n";
            netConfig += "F1 " + this.ARTModule.F1.Count + "\r\n";
            netConfig += "MFCategoryCount " + this.mapField.getCategoryCount() + "\r\n";
            for (int catIndex = 0; catIndex < this.mapField.getCategoryCount(); catIndex++)
            {
                MapFieldCategory cat = (MapFieldCategory)this.mapField.categories[catIndex];
                netConfig += cat.getCode() + "\r\n";
                netConfig += cat.getName() + "\r\n";
            }
            netConfig += "ContextCount " + this.ARTModule.contextField.Count + "\r\n";
            ICollection contextKeys     = this.ARTModule.contextField.Keys;
            IEnumerator contextKeysEnum = contextKeys.GetEnumerator();

            while (contextKeysEnum.MoveNext())
            {
                int contextKey = Int32.Parse(contextKeysEnum.Current.ToString());
                netConfig += "Context " + contextKey + "\r\n";
                LayerF2 F2 = ((LayerF2)this.ARTModule.contextField[contextKey]);
                netConfig += "F2Count " + F2.Count + "\r\n";
                for (int f2Index = 0; f2Index < F2.Count; f2Index++)
                {
                    netConfig += "Prototype\r\n";
                    double [] prototype = ((F2Neuron)F2[f2Index]).getProtoTypeCluster();
                    for (int i = 0; i < prototype.Length; i++)
                    {
                        netConfig += prototype[i] + "\t";
                    }
                    netConfig += "\r\n";
                    netConfig += "tdConnWs\r\n";
                    SynapticConnection[] conns = ((F2Neuron)F2[f2Index]).getConnections();
                    for (int connIndex = 0; connIndex < conns.Length; connIndex++)
                    {
                        netConfig += ((SynapticConnection)conns[connIndex]).getWeight() + "\t";
                    }
                    netConfig += "\r\n";
                    netConfig += "CatCode\r\n";
                    //for (int f2Index = 0; f2Index < F2.Count; f2Index++)
                    {
                        MapFieldConnection mapFieldConn = ((F2Neuron)F2[f2Index]).getMapFieldConnection();
                        netConfig += mapFieldConn.getCategory().getCode() + "\r\n";
                    }
                }
            }
            AddText(fs, netConfig);
            fs.Close();
        }