Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmaEsElements"/> class.
        /// </summary>
        /// <param name="configuration">Fixed parameters for CMA-ES.</param>
        /// <param name="generation">The current generation.</param>
        /// <param name="distributionMean">The current distribution mean.</param>
        /// <param name="stepSize">The current step size.</param>
        /// <param name="covariances">The current covariance matrix.</param>
        /// <param name="covariancesDecomposition">The current eigendecomposition of the covariance matrix.</param>
        /// <param name="evolutionPath">The current evolution path.</param>
        /// <param name="conjugateEvolutionPath">The conjugate evolution path.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if <paramref name="generation"/> or <paramref name="stepSize"/> are negative.
        /// </exception>
        public CmaEsElements(
            CmaEsConfiguration configuration,
            int generation,
            Vector <double> distributionMean,
            double stepSize,
            Matrix <double> covariances,
            Evd <double> covariancesDecomposition,
            Vector <double> evolutionPath,
            Vector <double> conjugateEvolutionPath)
        {
            if (generation < 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(generation),
                          $"Generation must be nonnegative, but was {generation}.");
            }

            if (stepSize < 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(stepSize),
                          $"Step size must be nonnegatives, but was {stepSize}.");
            }

            this.Configuration            = configuration;
            this.Generation               = generation;
            this._distributionMean        = distributionMean?.Clone();
            this.StepSize                 = stepSize;
            this._covariances             = covariances?.Clone();
            this._covariancesDiagonal     = covariancesDecomposition == null ? null : DiagonalMatrix.OfMatrix(covariancesDecomposition.D);
            this._covariancesEigenVectors = covariancesDecomposition?.EigenVectors.Clone();
            this._evolutionPath           = evolutionPath?.Clone();
            this._conjugateEvolutionPath  = conjugateEvolutionPath?.Clone();
        }