/// <summary>
        /// Initializes a new instance of the <see cref="ContinuizedGenomeSearchPoint"/> class.
        /// </summary>
        /// <param name="values">
        /// The real-valued point to base this on.
        /// This is the internal representation, not the one in the parameter space.
        /// <para>Use <see cref="CreateFromGenome"/> if starting from search space.</para>
        /// </param>
        /// <param name="parameterTree">Specifies the parameters.</param>
        /// <param name="genomeBuilder">Responsible for checking validity and repairing.</param>
        /// <param name="lowerBounds">The lower bounds by dimension.</param>
        /// <param name="upperBounds">The upper bounds by dimension.</param>
        public ContinuizedGenomeSearchPoint(
            Vector <double> values,
            ParameterTree parameterTree,
            GenomeBuilder genomeBuilder,
            double[] lowerBounds,
            double[] upperBounds)
            : base(values, lowerBounds, upperBounds)
        {
            if (parameterTree == null)
            {
                throw new ArgumentNullException(nameof(parameterTree));
            }

            if (genomeBuilder == null)
            {
                throw new ArgumentNullException(nameof(genomeBuilder));
            }

            var transformator = new TolerantGenomeTransformation(parameterTree);
            var geneValues    = transformator.RoundToValidValues(this.MapIntoBounds().ToArray());
            var genome        = transformator.ConvertBack(geneValues);

            // Remember whether there was no direct mapping to a valid genome.
            this.IsRepaired = false;
            if (!genomeBuilder.IsGenomeValid(genome))
            {
                genomeBuilder.MakeGenomeValid(genome);
                this.IsRepaired = true;
            }

            this.Genome = new ImmutableGenome(genome);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PartialGenomeSearchPoint"/> class.
        /// </summary>
        /// <param name="underlyingGenome">The underlying <see cref="ImmutableGenome"/>.</param>
        /// <param name="values">
        /// The real-valued point to base continuous parameters on.
        /// This is the internal representation, not the one in the parameter space.
        /// <para>Use <see cref="CreateFromGenome"/> if starting from search space.</para>
        /// </param>
        /// <param name="genomeSearchPointConverter">
        /// Responsible for converting between full-fledged <see cref="Genome"/>s and continuous values in
        /// parameter space.
        /// </param>
        /// <param name="genomeBuilder">Responsible for checking validity and repairing.</param>
        /// <param name="lowerBounds">The lower bounds by dimension.</param>
        /// <param name="upperBounds">The upper bounds by dimension.</param>
        public PartialGenomeSearchPoint(
            ImmutableGenome underlyingGenome,
            Vector <double> values,
            GenomeSearchPointConverter genomeSearchPointConverter,
            GenomeBuilder genomeBuilder,
            double[] lowerBounds,
            double[] upperBounds)
            : base(values, lowerBounds, upperBounds)
        {
            if (genomeSearchPointConverter == null)
            {
                throw new ArgumentNullException(nameof(genomeSearchPointConverter));
            }

            if (genomeBuilder == null)
            {
                throw new ArgumentNullException(nameof(genomeBuilder));
            }

            // To create the complete genome, map the continuous values into parameter search space again.
            var genome = genomeSearchPointConverter.MergeIntoGenome(this.MapIntoBounds(), underlyingGenome);

            // Remember whether there was no direct mapping to a valid genome.
            this.IsRepaired = false;
            if (!genomeBuilder.IsGenomeValid(genome))
            {
                genomeBuilder.MakeGenomeValid(genome);
                this.IsRepaired = true;
            }

            this.Genome = new ImmutableGenome(genome);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenomeSearchPoint"/> class.
        /// </summary>
        /// <param name="values">The real-valued components of this point.</param>
        /// <param name="genomeSearchPointConverter">
        /// Responsible for converting between full-fledged <see cref="Genome"/>s and continuous values.
        /// </param>
        /// <param name="underlyingGenome">The underlying <see cref="ImmutableGenome"/>.</param>
        /// <param name="genomeBuilder">
        /// Responsible for validity checking of <see cref="Genome"/>s.
        /// </param>
        private GenomeSearchPoint(
            Vector <double> values,
            GenomeSearchPointConverter genomeSearchPointConverter,
            ImmutableGenome underlyingGenome,
            GenomeBuilder genomeBuilder)
            : base(values)
        {
            if (underlyingGenome == null)
            {
                throw new ArgumentNullException(nameof(underlyingGenome));
            }

            if (genomeBuilder == null)
            {
                throw new ArgumentNullException(nameof(genomeBuilder));
            }

            this._genomeSearchPointConverter = genomeSearchPointConverter ?? throw new ArgumentNullException(nameof(genomeSearchPointConverter));

            this._genome  = this._genomeSearchPointConverter.MergeIntoGenome(this.Values, underlyingGenome);
            this._isValid = genomeBuilder.IsGenomeValid(this._genome);
        }