Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the current <see cref="GrayBoxSimulationPredictionScores"/>.
        /// </summary>
        /// <param name="generation">The generation.</param>
        /// <param name="timePoint">The gray box start time point.</param>
        /// <param name="currentDataRecords">The current data records.</param>
        /// <returns>The current <see cref="GrayBoxSimulationPredictionScores"/>.</returns>
        private GrayBoxSimulationPredictionScores GetPredictionScores(
            int generation,
            TimeSpan timePoint,
            IEnumerable <DataRecord <TResult> > currentDataRecords)
        {
            var predictionScores = new GrayBoxSimulationPredictionScores(
                generation,
                timePoint,
                this._positiveTrainDataCount,
                this._negativeTrainDataCount);

            foreach (var record in currentDataRecords)
            {
                if (record.IsCancelledByGrayBoxDuringGrayBoxSimulation && record.GrayBoxLabel == GrayBoxUtils.GrayBoxLabelOfTimeouts)
                {
                    predictionScores.TruePositiveCount++;
                }

                if (record.IsCancelledByGrayBoxDuringGrayBoxSimulation && record.GrayBoxLabel == GrayBoxUtils.GrayBoxLabelOfNonTimeouts)
                {
                    predictionScores.FalsePositiveCount++;
                }

                if (!record.IsCancelledByGrayBoxDuringGrayBoxSimulation && record.GrayBoxLabel == GrayBoxUtils.GrayBoxLabelOfNonTimeouts)
                {
                    predictionScores.TrueNegativeCount++;
                }

                if (!record.IsCancelledByGrayBoxDuringGrayBoxSimulation && record.GrayBoxLabel == GrayBoxUtils.GrayBoxLabelOfTimeouts)
                {
                    predictionScores.FalseNegativeCount++;
                }
            }

            return(predictionScores);
        }