Ejemplo n.º 1
0
        public void DeleteTopologyAndWeightsMatrix(string NeuroNetName, LoadingWindow loadingWindow)
        {
            connector.ConnectToDB();
            SQLiteCommand cmd = new SQLiteCommand(connector.connection);

            cmd.CommandText = "SELECT ID FROM NeuroNet WHERE NAME = '" + NeuroNetName + "'";
            int NNID = Convert.ToInt32(cmd.ExecuteScalar());

            cmd.CommandText = "SELECT ID FROM NetTopology WHERE NeuroNetID = '" + Convert.ToString(NNID) + "'";
            List <int> ls = new List <int>();

            double progress = 0.0;

            try
            {
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ls.Add(Convert.ToInt32(reader[0]));
                }
                reader.Close();

                foreach (int item in ls)
                {
                    cmd.CommandText = "DELETE FROM WeightsMatrix WHERE NetTopologyID = '" + Convert.ToString(item) + "'";
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = "DELETE FROM NetTopology WHERE ID = '" + Convert.ToString(item) + "'";
                    cmd.ExecuteNonQuery();

                    progress += 100.0 / Convert.ToDouble(ls.Count);
                    Action f = new Action(() => loadingWindow.LoadingBar.Value = Convert.ToInt32(progress));
                    if (loadingWindow.LoadingBar.InvokeRequired)
                    {
                        loadingWindow.LoadingBar.Invoke(f);
                    }
                    else
                    {
                        f();
                    }
                }
            }
            catch (SQLiteException ex)
            {
                MessageBox.Show(ex.Message);
            }

            connector.DisconnectFromDB();
            loadingWindow.Invoke(new Action(() => loadingWindow.Close()));
        }
Ejemplo n.º 2
0
        public void InsertTopologyOfNeuroNet(string NameNN, string TopologyTypeName,
                                             int CountNeurons, int CountLayers, int[] NeuronsInLayers, LoadingWindow loadingWindow)
        {
            connector.ConnectToDB();
            SQLiteCommand cmd = new SQLiteCommand(connector.connection);

            cmd.CommandText = "SELECT ID FROM NeuroNet WHERE Name = '" + NameNN + "'";
            int NetID = Convert.ToInt32(cmd.ExecuteScalar());

            Topology topology = LibraryOfTopologies.GetTopology(TopologyTypeName,
                                                                LibraryOfTopologies.GetterParameter.TypeOfTopologyName);

            bool[,] connections = topology.CreateNet(CountNeurons, CountLayers, NeuronsInLayers);

            double progressValue = 0.0;

            for (int i = 0; i < CountNeurons; i++)
            {
                for (int j = 0; j < CountNeurons; j++)
                {
                    if (connections[i, j] == true)
                    {
                        cmd.CommandText = "INSERT INTO NetTopology (IndexInputNeuron, " +
                                          "IndexOutputNeuron, NeuroNetID) values('" + Convert.ToString(j) +
                                          "','" + Convert.ToString(i) + "','" + Convert.ToString(NetID) + "')";
                        cmd.ExecuteNonQuery();
                    }
                    progressValue += 100.0 / Convert.ToDouble(CountNeurons * CountNeurons);
                    Action f = new Action(() => loadingWindow.LoadingBar.Value = Convert.ToInt32(progressValue));
                    if (loadingWindow.LoadingBar.InvokeRequired)
                    {
                        loadingWindow.LoadingBar.Invoke(f);
                    }
                    else
                    {
                        f();
                    }
                }
            }
            connector.DisconnectFromDB();
            loadingWindow.Invoke(new Action(() => loadingWindow.Close()));
        }
Ejemplo n.º 3
0
        public void DeleteWeightsMatrix(string NeuroNetName, LoadingWindow loadingWindow)
        {
            connector.ConnectToDB();
            SQLiteCommand cmd = new SQLiteCommand(connector.connection);
            cmd.CommandText = "SELECT ID FROM NeuroNet WHERE NAME = '" + NeuroNetName + "'";
            int NNID = Convert.ToInt32(cmd.ExecuteScalar());

            cmd.CommandText = "SELECT ID FROM NetTopology WHERE NeuroNetID = '" + Convert.ToString(NNID) + "'";
            List<int> ls = new List<int>();

            double progress = 0.0;
            try
            {
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ls.Add(Convert.ToInt32(reader[0]));
                }
                reader.Close();

                foreach (int item in ls)
                {
                    cmd.CommandText = "DELETE FROM WeightsMatrix WHERE NetTopologyID = '" + Convert.ToString(item) + "'";
                    cmd.ExecuteNonQuery();

                    progress += 100.0 / Convert.ToDouble(ls.Count);
                    Action f = new Action(() => loadingWindow.LoadingBar.Value = Convert.ToInt32(progress));
                    if (loadingWindow.LoadingBar.InvokeRequired)
                    {
                        loadingWindow.LoadingBar.Invoke(f);
                    }
                    else
                    {
                        f();
                    }
                }

            }
            catch (SQLiteException ex)
            {
                MessageBox.Show(ex.Message);
            }

            connector.DisconnectFromDB();
            loadingWindow.Invoke(new Action(() => loadingWindow.Close()));
        }
Ejemplo n.º 4
0
        public void InsertTopologyOfNeuroNet(string NameNN, string TopologyTypeName,
            int CountNeurons, int CountLayers, int[] NeuronsInLayers, LoadingWindow loadingWindow)
        {
            connector.ConnectToDB();
            SQLiteCommand cmd = new SQLiteCommand(connector.connection);
            cmd.CommandText = "SELECT ID FROM NeuroNet WHERE Name = '" + NameNN + "'";
            int NetID = Convert.ToInt32(cmd.ExecuteScalar());

            Topology topology = LibraryOfTopologies.GetTopology(TopologyTypeName,
                LibraryOfTopologies.GetterParameter.TypeOfTopologyName);
            bool[,] connections = topology.CreateNet(CountNeurons, CountLayers, NeuronsInLayers);

            double progressValue = 0.0;
            for (int i = 0; i < CountNeurons; i++)
            {
                for (int j = 0; j < CountNeurons; j++)
                {
                    if (connections[i, j] == true)
                    {
                        cmd.CommandText = "INSERT INTO NetTopology (IndexInputNeuron, " +
                            "IndexOutputNeuron, NeuroNetID) values('" + Convert.ToString(j) +
                            "','" + Convert.ToString(i) + "','" + Convert.ToString(NetID) + "')";
                        cmd.ExecuteNonQuery();
                    }
                    progressValue += 100.0 / Convert.ToDouble(CountNeurons * CountNeurons);
                    Action f = new Action(() => loadingWindow.LoadingBar.Value = Convert.ToInt32(progressValue));
                    if (loadingWindow.LoadingBar.InvokeRequired)
                    {
                        loadingWindow.LoadingBar.Invoke(f);
                    }
                    else
                    {
                        f();
                    }
                }
            }
            connector.DisconnectFromDB();
            loadingWindow.Invoke(new Action(() => loadingWindow.Close()));
        }