コード例 #1
0
ファイル: SimulationSession.cs プロジェクト: OlekNg/AHMED
        private void PerformSession()
        {
            Console.WriteLine("Running session on {0}", xmlConfigurationPath);
            for (int i = 0; i < SimulationsInSession ;i++)
            {
                var simulation = new EvacuationSimulation(xmlConfiguration.GetBuilding(), xmlConfiguration.GetGeneticsConfiguration());
                simulation.StatisticsOutputPath = String.Format("{0}/pass_{1}", sessionFolder, i + 1);
                Console.WriteLine("Simulation pass {0}", i + 1);
                simulation.Start();

                var statistics = simulation.GetStatistics();
                if (statistics.BestChromosomeValue > bestChromosomeValue)
                {
                    bestChromosomeValue = statistics.BestChromosomeValue;
                    bestSessionChromosome = i;
                }
            }

            File.Copy(Path.Combine(sessionFolder, String.Format("pass_{0}", bestSessionChromosome + 1), "best_chromosome.txt"), Path.Combine(sessionFolder, "best_chromosome.txt"));
        }
コード例 #2
0
ファイル: Calculator.cs プロジェクト: OlekNg/AHMED
        public void RunGA()
        {
            // If no building is currently loaded then do nothing.
            if (String.IsNullOrEmpty(CurrentFile))
                return;

            CurrentBuilding.ShortGenotype = _geneticsConfiguration.ShortGenotype;
            if (CurrentBuilding.ShortGenotype)
            {
                CurrentBuilding.Rooms
                    .Where(x => x.NumberOfDoors == 1)
                    .ToList()
                    .ForEach(x => x.ApplySimpleEvacuation());
            }

            GeneticsConfiguration<List<bool>> geneticsConfiguration = _geneticsConfiguration.BuildConfiguration(CurrentBuilding);
            _currentSimulation = new EvacuationSimulation(new Building(CurrentBuilding), geneticsConfiguration);

            _currentSimulation.GeneticAlgorithm.Completed += OnGeneticCompleted;

            // Create view model for presenting progression of algorithm.
            Status statusModel = new Status(_currentSimulation.GeneticAlgorithm);
            StatusWindow statusWindow = new StatusWindow(statusModel);

            // Run algorithm asynchronously.
            new Task(_currentSimulation.Start).Start();

            statusWindow.ShowDialog();
        }