コード例 #1
0
        private void LoadBtn_Click(object sender, RoutedEventArgs e)
        {
            string filePath = $"../../../Simulations/{ConfigTextBox.Text}.json";

            if (!File.Exists(filePath))
            {
                DisableButtons();
                return;
            }

            var simulationReader = new SimulationReader();

            simulationReader.ReadConfigsFile(filePath);

            simulations = simulationReader.Configs.ConvertAll(x => x.CreateSimulation());

            if (simulations?[currentSimulationNumber]?.Config.Network != "SOMNetwork")
            {
                imageParser = new ImageParser(simulationReader.ImagesPath);
                imageParser.Parse();
                imageParser.GenerateDataSets(simulations[0].ValidationData, simulations[0].ImagesDisturbanceProbability, simulations[0].ImageDisturbanceMaxDifference);
            }

            EnableButtons();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            var simulationReader = new SimulationReader();

            Console.Write("Simulation config file name (Simulations/XXX.json): ");
            string fileName = Console.ReadLine();

            simulationReader.ReadConfigsFile($"../Simulations/{fileName}.json");
            var file = new StreamWriter($"../Simulations/{fileName}-results.csv");

            Console.WriteLine("Loaded configs");

            var headers = $"{Config.GetCsvHeaders()};LoopsMean;";

            file.WriteLine(headers);
            Console.WriteLine(headers);
            var simulations = new List <Simulation>();

            foreach (var config in simulationReader.Configs)
            {
                var simulation = config.CreateSimulation();
                simulations.Add(simulation);
                var          loopsResults = new List <int>();
                List <float> errors       = null;

                for (int j = 0; j < config.Repeat; j++)
                {
                    simulation.Reset();
                    errors = simulation.TrainByThreshold(config.TrainData, config.TrainThreshold);

                    if (errors == null)
                    {
                        break;
                    }

                    loopsResults.Add(errors.Count);
                }

                string data = $"{config.GetCsvData()};";

                if (errors == null)
                {
                    data += "timeout";
                }
                else
                {
                    data += loopsResults.Sum() / (float)loopsResults.Count;

                    foreach (float error in errors)
                    {
                        data += $";{error}";
                    }
                }

                file.WriteLine(data);
                Console.WriteLine($"{simulations.Count}: {data}");
            }

            file.Close();
            Console.WriteLine("Ended");

            ConsoleMenu(simulations);
        }