/// <summary> /// Gets the current tuning scores. /// </summary> /// <param name="currentGeneration">The current generation.</param> /// <returns>The current tuning scores.</returns> private GrayBoxSimulationTuningScores GetCurrentTuningScores(int currentGeneration) { var currentTuningScores = new GrayBoxSimulationTuningScores( currentGeneration, this._listOfBlackBoxEvaluationRunTimesInCurrentGeneration.Count, TimeSpan.FromMilliseconds( this._listOfBlackBoxEvaluationRunTimesInCurrentGeneration.Average(runtime => runtime.TotalMilliseconds)), TimeSpan.FromMilliseconds(this._listOfGrayBoxEvaluationRunTimesInCurrentGeneration.Average(runtime => runtime.TotalMilliseconds)), this._bagOfPercentageOfTournamentWinnerChangesPerTournament.Average(), this._bagOfAdaptedWsCoefficientsPerTournament.Average()); return(currentTuningScores); }
/// <summary> /// Logs the total tuning scores. /// </summary> /// <param name="listOfTuningScores">The list of tuning scores.</param> private void LogTotalTuningScores(List <GrayBoxSimulationTuningScores> listOfTuningScores) { var totalNumberOfEvaluations = listOfTuningScores.Sum(score => score.NumberOfEvaluations); // Set generation to -1, since it gets overwritten by "total". var totalTuningScores = new GrayBoxSimulationTuningScores( -1, totalNumberOfEvaluations, TimeSpan.FromMilliseconds( listOfTuningScores.Sum(score => score.AveragedBlackBoxEvaluationRuntime.TotalMilliseconds * score.NumberOfEvaluations) / totalNumberOfEvaluations), TimeSpan.FromMilliseconds( listOfTuningScores.Sum(score => score.AveragedGrayBoxEvaluationRuntime.TotalMilliseconds * score.NumberOfEvaluations) / totalNumberOfEvaluations), listOfTuningScores.Average(score => score.AveragedPercentageOfTournamentWinnerChanges), listOfTuningScores.Average(score => score.AveragedAdaptedWsCoefficient)); this._tuningScoresRecorder.WriteRow(totalTuningScores.ToStringArray("total")); }
/// <summary> /// Initializes all log file recorder. /// </summary> private void InitializeLogFileRecorder() { // Get log file suffix from current simulation configuration. var logFileSuffix = $"SG_{this._simulationConfiguration.GrayBoxStartGeneration}_ST_{this._simulationConfiguration.GrayBoxStartTimePoint.TotalMilliseconds:0}_CT_{this._simulationConfiguration.GrayBoxConfidenceThreshold:0.####}_ID_{ProcessUtils.GetCurrentProcessId()}"; // Get feature importance header from first element in data dictionary. var featureImportanceHeader = new[] { "Generation", }.Concat( this._customGrayBoxMethods.GetGrayBoxFeatureNamesFromDataRecord(this._dataDictionary.Values.First().First())).ToArray(); // Define instance count header. var instanceCountHeader = new[] { "Instance", "CancelledBlackBoxRuns", "FinishedBlackBoxRuns", "CancelledGrayBoxRuns", "FinishedGrayBoxRuns", }; // Initialize log file recorder. this._featureImportanceRecorder = new StringArrayRecorder( new FileInfo(Path.Combine(this._logFileDirectory.FullName, $"featureImportance_{logFileSuffix}.csv")), featureImportanceHeader, true); this._predictionScoresRecorder = new StringArrayRecorder( new FileInfo(Path.Combine(this._logFileDirectory.FullName, $"predictionScores_{logFileSuffix}.csv")), GrayBoxSimulationPredictionScores.GetHeader(), true); this._tuningScoresRecorder = new StringArrayRecorder( new FileInfo(Path.Combine(this._logFileDirectory.FullName, $"tuningScores_{logFileSuffix}.csv")), GrayBoxSimulationTuningScores.GetHeader(), true); this._instanceCountRecorder = new StringArrayRecorder( new FileInfo(Path.Combine(this._logFileDirectory.FullName, $"instanceCounts_{logFileSuffix}.csv")), instanceCountHeader, true); }