コード例 #1
0
        public void TimetableGenerationTest()
        {
            String configurationFile = basePath + "TimetableDataExtended.xml";
            TimetableData ttData = TimetableConfigIO.ImportTimetableConfig(configurationFile);
            Assert.IsNotNull(ttData, "Data could not be loaded.");

            TimetableGenerator generator = new TimetableGenerator(ttData);
            generator.IndividualCreated += new Action<int>(generator_IndividualCreated);
            generator.GenerationTick += new Action<TimetableGenerator.HistoryEntry>(generator_GenerationTick);

            DateTime start = DateTime.Now;

            generator.CreatePopulation(25, 10);
            TestRequirements(ttData, generator);
            System.Diagnostics.Debug.WriteLine("Population created after " + (DateTime.Now - start).TotalSeconds + " seconds.");

            generator.PerformEvolution(1000);
            TestRequirements(ttData, generator);
            System.Diagnostics.Debug.WriteLine("Evolution finished after " + (DateTime.Now - start).TotalSeconds + " seconds.");

            TimetableExportCSV.ExportAll(generator.Population[0], ttData, basePath + "outputtest.csv");
            Assert.IsTrue(true);

            TimetablePlanner.TimetableGenerator.HistoryEntry.PrintHistory(generator.EvolutionHistory);
        }
コード例 #2
0
        private void RunGeneration()
        {
            SaveFileDialog svDiag = new SaveFileDialog();
            svDiag.FileName = "Export.csv";
            svDiag.Filter = "CSV-Files (*.csv)|*.csv";
            svDiag.InitialDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            if (svDiag.ShowDialog() != true)
                return;

            TimetableData ttData = GetTimetableData();

            TimetableGenerator generator = new TimetableGenerator(ttData);
            generator.GenerationTick += new Action<TimetableGenerator.HistoryEntry>(generator_GenerationTick);
            generator.IndividualCreated += new Action<int>(generator_IndividualCreated);

            generator.CreatePopulation(_populationSize, 10);
            generator.PerformEvolution(_numberOfGenerations);
            ProgressbarValue = 0;

            TimetableExportCSV.ExportAll(generator.Population[0], ttData, svDiag.FileName);
            System.Diagnostics.Process.Start(svDiag.FileName);
        }