Exemplo n.º 1
0
        /// <summary>
        /// Configures the current gray box handler.
        /// </summary>
        private void ConfigureGrayBoxHandler()
        {
            var genomeTransformation       = new GenomeTransformation <CategoricalBinaryEncoding>(this._parameterTree);
            var genomeDoubleRepresentation =
                genomeTransformation.ConvertGenomeToArray(this._currentEvaluation.GenomeInstancePair.Genome.CreateMutableGenome());

            var tunerDataRecord = new TunerDataRecord <TResult>(
                NetworkUtils.GetFullyQualifiedDomainName(),
                this._currentEvaluation.GenerationId,
                this._currentEvaluation.TournamentId,
                this._currentEvaluation.GenomeInstancePair.Instance.ToId(),
                double.NaN,
                genomeTransformation.GetConverterColumnHeader(),
                genomeDoubleRepresentation,
                null);

            this._grayBoxHandler = new GrayBoxHandler <TInstance, TResult>(
                this._configuration,
                this._configuredTargetAlgorithm as IGrayBoxTargetAlgorithm <TInstance, TResult>,
                this._id,
                tunerDataRecord,
                this._currentEvaluation.UseGrayBoxInEvaluation && this._successfullyDeserializedGrayBoxRandomForest,
                this._customGrayBoxMethods,
                this._grayBoxRandomForest);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Configures the current target algorithm and gray box handler.
        /// </summary>
        /// <param name="targetAlgorithmFactory">The <see cref="ITargetAlgorithmFactory{TTargetAlgorithm,TInstance,TResult}"/>.</param>
        /// <param name="parameterTree">The <see cref="ParameterTree"/>.</param>
        /// <param name="indexOfDesiredPostTuningRun">The index of the desired post tuning run.</param>
        /// <param name="postTuningGenomeInstancePair">The post tuning genome instance pair.</param>
        private void ConfigureTargetAlgorithmAndGrayBoxHandler(
            ITargetAlgorithmFactory <TGrayBoxTargetAlgorithm, TInstance, TResult> targetAlgorithmFactory,
            ParameterTree parameterTree,
            int indexOfDesiredPostTuningRun,
            GenomeInstancePairStringRepresentation postTuningGenomeInstancePair)
        {
            var genomeDoubleRepresentation =
                GenomeDoubleRepresentation.GetGenomeDoubleRepresentationFromGenomeIdentifierStringRepresentation(postTuningGenomeInstancePair.Genome);
            var genomeTransformation = new GenomeTransformation <CategoricalBinaryEncoding>(parameterTree);
            var genome           = genomeTransformation.ConvertBack(genomeDoubleRepresentation);
            var runnerDictionary = genome.GetFilteredGenes(parameterTree);

            this._configuredTargetAlgorithm = targetAlgorithmFactory.ConfigureTargetAlgorithm(runnerDictionary);

            // Set generation to -1, since this is a post tuning run.
            var tunerDataRecord = new TunerDataRecord <TResult>(
                NetworkUtils.GetFullyQualifiedDomainName(),
                -1,
                0,
                postTuningGenomeInstancePair.Instance,
                double.NaN,
                genomeTransformation.GetConverterColumnHeader(),
                genomeDoubleRepresentation,
                null);

            this._grayBoxHandler = new GrayBoxHandler <TInstance, TResult>(
                this._tunerConfiguration,
                this._configuredTargetAlgorithm,
                indexOfDesiredPostTuningRun,
                tunerDataRecord,
                false,
                null,
                null);
        }