예제 #1
0
        public override void Init(Genome parent, double mutationRate)
        {
            var nnParent = (NeuronNet)parent;
            var nnSettings = (NeuronNetSettings)mSettings;
            int numLayers = nnParent.mLayers.Count + LayerMutation();
            numLayers = Util.Clamp(numLayers, nnSettings.mNumLayersMin, nnSettings.mNumLayersMax);
            int numNeurons = 0;
            int iLayer = 0;

            if (numLayers > 0)
            {
                numNeurons = AddLayer().Init(nnSettings.mNumInputs, nnParent.GetLayer(iLayer), mutationRate);
                iLayer++;

                for (int iHiddenLayer = 0; iHiddenLayer < numLayers - 1; iHiddenLayer++)
                {
                    numNeurons = AddLayer().Init(numNeurons, nnParent.GetLayer(iLayer), mutationRate);
                    iLayer++;
                }

                mOutputLayer.Init(numNeurons, nnSettings.mNumOutputs, nnParent.mOutputLayer, mutationRate);
            }
            else
            {
                mOutputLayer.Init(nnSettings.mNumInputs, nnSettings.mNumOutputs, nnParent.mOutputLayer, mutationRate);
            }
        }
예제 #2
0
        private Genome SelectMate(Genome mateA)
        {
            if (mPopulation.Count <= 1)
                return null;

            if (mateA == null)
                throw new Exception();

            int orderMin = Math.Max(0, mateA.mOrder - mSettings.mMateThreshold);
            int orderMax = Math.Min(mateA.mOrder + mSettings.mMateThreshold, mPopulation.Count);
            int iMateB = Util.RandomRangeExcept(orderMin, orderMax, mateA.mOrder);
            var mateB = mPopulation[iMateB];
            mateB.mOrder = iMateB;
            return mateB;
        }
예제 #3
0
 private Genome Cross(Genome parent)
 {
     var baby = (Genome)GetInstance();
     Debug.Assert(baby != null);
     baby.Init(parent, mSettings.mMutationRate);
     return baby;
 }
예제 #4
0
 private Genome Cross(Genome mum, Genome dad)
 {
     var baby = (Genome)GetInstance();
     Debug.Assert(baby != null);
     baby.Init(mum, dad, mSettings.mMutationRate);
     return baby;
 }
예제 #5
0
        public override void Init(Genome mum, Genome dad, double mutationRate)
        {
            var nnMum = (NeuronNet)mum;
            var nnDad = (NeuronNet)dad;
            var nnSettings = (NeuronNetSettings)mSettings;

            int numLayers = Util.RandomRange(nnMum.mLayers.Count, nnDad.mLayers.Count) + LayerMutation();
            numLayers = Util.Clamp(numLayers, nnSettings.mNumLayersMin, nnSettings.mNumLayersMax);

            int numNeurons = 0;
            int iLayer = 0;

            if (numLayers > 0)
            {
                numNeurons = AddLayer().Init(nnSettings.mNumInputs, nnMum.GetLayer(iLayer), nnDad.GetLayer(iLayer), mutationRate);
                iLayer++;

                for (int iHiddenLayer = 0; iHiddenLayer < numLayers - 1; iHiddenLayer++)
                {
                    numNeurons = AddLayer().Init(numNeurons, nnMum.GetLayer(iLayer), nnDad.GetLayer(iLayer), mutationRate);
                    iLayer++;
                }

                mOutputLayer.Init(numNeurons, nnSettings.mNumOutputs, nnMum.mOutputLayer, nnDad.mOutputLayer, mutationRate);
            }
            else
            {
                mOutputLayer.Init(nnSettings.mNumInputs, nnSettings.mNumOutputs, nnMum.mOutputLayer, nnDad.mOutputLayer, mutationRate);
            }
        }
예제 #6
0
파일: Genome.cs 프로젝트: chebz/ANNCsharp
 public abstract void Init(Genome mum, Genome dad, double mutationRate);
예제 #7
0
파일: Genome.cs 프로젝트: chebz/ANNCsharp
 public abstract void Init(Genome parent, double mutationRate);
예제 #8
0
파일: Genome.cs 프로젝트: chebz/ANNCsharp
 public abstract void Init(Genome mum, Genome dad, double mutationRate);
예제 #9
0
파일: Genome.cs 프로젝트: chebz/ANNCsharp
 public abstract void Init(Genome parent, double mutationRate);