Exemplo n.º 1
0
        private static float[][] SampleBestFitter(ParetoFrontPoint best, int sampleCount)
        {
            var sensorCount   = best.Genome.Network.Sensors.Count;
            var effectorCount = best.Genome.Network.Effectors.Count;
            var sampleLen     = sensorCount + effectorCount;

            var samples = new float[sampleCount][];

            for (var i = 0; i < sampleCount; i++)
            {
                samples[i] = new float[sampleLen];
                var network = best.Genome.Network;
                for (var s = 0; s < sensorCount; ++s)
                {
                    network.Sensors[s] = RandomSource.Range(-1, 1);
                    samples[i][s]      = network.Sensors[s];
                }

                network.Activate();

                for (var e = 0; e < effectorCount; ++e)
                {
                    samples[i][sensorCount + e] = network.Effectors[e];
                }
            }

            return(samples);
        }
Exemplo n.º 2
0
        public static IReadOnlyList <float> EvaluateWinner(ParetoFrontPoint winner, bool isRecurrent)
        {
            Debug.Assert(winner != null, nameof(winner) + " != null");

            var result = new List <float>(XorTruthTable.Length);

            foreach (var t in XorTruthTable)
            {
                result.Add(ActivateAndGetEffector(winner.Genome, isRecurrent, t[0], t[1]));
            }

            return(result);
        }
Exemplo n.º 3
0
        private static void SetParetoRank(ParetoFrontPoint point, ICollection <ParetoFrontPoint> ranks)
        {
            var maxNonDominantFrontNumber = 0;

            foreach (var r in ranks)
            {
                if (point.IsDominatedBy(r) && maxNonDominantFrontNumber < r.Rank)
                {
                    maxNonDominantFrontNumber = r.Rank;
                }
            }

            point.Rank = maxNonDominantFrontNumber + 1;
            ranks.Add(point);
        }