Exemplo n.º 1
0
        /// <summary>
        /// Update the personal best position of a particle.
        /// </summary>
        /// <param name="particleIndex">index of the particle in the swarm</param>
        /// <param name="particlePosition">the particle current position vector</param>
        protected void UpdatePersonalBestPosition(int particleIndex, double[] particlePosition)
        {
            // set the network weights and biases from the vector
            double score = m_calculateScore.CalculateScore(m_networks[particleIndex]);

            // update the best vectors (g and i)
            if ((m_bestErrors[particleIndex] == 0) || IsScoreBetter(score, m_bestErrors[particleIndex]))
            {
                m_bestErrors[particleIndex] = score;
                m_va.Copy(m_bestVectors[particleIndex], particlePosition);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Perform the task.
        /// </summary>
        public void PerformTask()
        {
            IMLMethod phenotype = owner.CODEC.Decode(genome);

            if (phenotype != null)
            {
                double score;
                try
                {
                    score = scoreFunction.CalculateScore(phenotype);
                }
                catch (EARuntimeError e)
                {
                    score = Double.NaN;
                }
                genome.Score         = score;
                genome.AdjustedScore = score;
                BasicEA.CalculateScoreAdjustment(genome, adjusters);
            }
        }
        /// <summary>
        /// Calculate the genome's score.
        /// </summary>
        ///
        /// <param name="genome">The genome to calculate for.</param>
        /// <returns>The calculated score.</returns>
        public double CalculateScore(IGenome genome)
        {
            var network = (IMLRegression)genome.Organism;

            return(_calculateScore.CalculateScore(network));
        }