/// <summary>
        /// Completes the generation information history and exports it to file.
        /// </summary>
        public void CompleteAndExportGenerationHistory()
        {
            if (this._configuration.ScoreGenerationHistory &&
                this._runEvaluator is IMetricRunEvaluator <TResult> metricRunEvaluator)
            {
                var scorer = new GenerationInformationScorer <TInstance, TResult>(
                    this._genomeSorter,
                    this._targetRunResultStorage,
                    metricRunEvaluator);

                scorer.ScoreInformationHistory(this._informationHistory, this._trainingInstances, this._testInstances);
                RunStatisticTracker.ExportAverageIncumbentScores(this._informationHistory, this._configuration.EvaluationLimit);
            }

            RunStatisticTracker.ExportGenerationHistory(this._informationHistory);
        }
Ejemplo n.º 2
0
        public void ExportGenerationHistoryWritesOutAllInformation()
        {
            var firstGeneration = new GenerationInformation(
                0,
                TimeSpan.FromSeconds(30),
                34,
                typeof(GgaStrategy <TestInstance, TestResult>),
                new ImmutableGenome(new Genome()),
                "id");

            firstGeneration.IncumbentTrainingScore = -34.5;
            firstGeneration.IncumbentTestScore     = -20;
            var secondGeneration = new GenerationInformation(
                1,
                TimeSpan.FromSeconds(60),
                2587,
                typeof(DifferentialEvolutionStrategy <TestInstance, TestResult>),
                new ImmutableGenome(new Genome()),
                "id");

            secondGeneration.IncumbentTrainingScore = -104;
            secondGeneration.IncumbentTestScore     = -100;

            RunStatisticTracker.ExportGenerationHistory(new List <GenerationInformation> {
                firstGeneration, secondGeneration
            });

            var exported = File.ReadAllLines("generationHistory.csv");

            Assert.True(3 == exported.Length, "Expected three lines: One legend and two generations.");
            Assert.True(
                "Generation;Elapsed(d:hh:mm:ss);Total # Evaluations;Average Train Incumbent;Average Test Incumbent;Strategy;Incumbent;IncumbentID"
                == exported[0],
                "Legend is not as expected.");
            exported[1].ShouldBe(
                "0;0:00:00:30.0000000;34;-34.5;-20;GgaStrategy`2;[](Age: 0)[Engineered: no];id");
            exported[2].ShouldBe(
                "1;0:00:01:00.0000000;2587;-104;-100;DifferentialEvolutionStrategy`2;[](Age: 0)[Engineered: no];id");
        }
Ejemplo n.º 3
0
        public void ExportGenerationHistoryWritesOutAllInformation()
        {
            var firstGeneration = new GenerationInformation(
                0,
                34,
                typeof(GgaStrategy <TestInstance, TestResult>),
                new ImmutableGenome(new Genome()));

            firstGeneration.IncumbentTrainingScore = -34.5;
            firstGeneration.IncumbentTestScore     = -20;
            var secondGeneration = new GenerationInformation(
                1,
                2587,
                typeof(DifferentialEvolutionStrategy <TestInstance, TestResult>),
                new ImmutableGenome(new Genome()));

            secondGeneration.IncumbentTrainingScore = -104;
            secondGeneration.IncumbentTestScore     = -100;

            RunStatisticTracker.ExportGenerationHistory(new List <GenerationInformation> {
                firstGeneration, secondGeneration
            });

            var exported = File.ReadAllLines("generationHistory.csv");

            Assert.True(3 == exported.Length, "Expected three lines: One legend and two generations.");
            Assert.True(
                "Generation;Total # Evaluations;Average Train Incumbent;Average Test Incumbent;Strategy;Incumbent" == exported[0],
                "Legend is not as expected.");
            Assert.True(
                "0;34;-34.5;-20;GgaStrategy`2;[](Age: 0)[Engineered: no]" == exported[1],
                "First generation information is not as expected.");
            Assert.True(
                "1;2587;-104;-100;DifferentialEvolutionStrategy`2;[](Age: 0)[Engineered: no]" == exported[2],
                "Second generation information is not as expected.");
        }
Ejemplo n.º 4
0
 public void ExportGenerationHistoryThrowsForMissingHistory()
 {
     Assert.Throws <ArgumentNullException>(() => RunStatisticTracker.ExportGenerationHistory(informationHistory: null));
 }