Exemplo n.º 1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public NeatGenome(	uint genomeId, 
            NeuronGeneList neuronGeneList,
            ConnectionGeneList connectionGeneList,
            int inputNeuronCount,
            int outputNeuronCount)
        {
            this.genomeId = genomeId;

            this.neuronGeneList = neuronGeneList;
            this.connectionGeneList = connectionGeneList;

            this.inputNeuronCount = inputNeuronCount;
            this.inputAndBiasNeuronCount = inputNeuronCount+1;
            this.outputNeuronCount = outputNeuronCount;
            this.inputBiasOutputNeuronCount = inputAndBiasNeuronCount + outputNeuronCount;
            this.inputBiasOutputNeuronCountMinus2 = inputBiasOutputNeuronCount-2;

            Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
        }
Exemplo n.º 2
0
        public NeatGenome(uint genomeId,
                NeuronGeneList neuronGeneList,
                List<ModuleGene> moduleGeneList,
                ConnectionGeneList connectionGeneList,
                int inputNeuronCount,
                int outputNeuronCount,
                int outputsPerPolicy) // Schrum: Added
        {
			this.genomeId = genomeId;

			this.neuronGeneList = neuronGeneList;
            this.moduleGeneList = moduleGeneList;
			this.connectionGeneList = connectionGeneList;

			this.inputNeuronCount = inputNeuronCount;
            // Schrum: Removed (not used)
			//this.inputAndBiasNeuronCount = inputNeuronCount+1;
			this.outputNeuronCount = outputNeuronCount;
			
            // Schrum: Removed (not used)
            //this.inputBiasOutputNeuronCount = inputAndBiasNeuronCount + outputNeuronCount;
			//this.inputBiasOutputNeuronCountMinus2 = inputBiasOutputNeuronCount-2;
            
            // Schrum: Added
            this.outputsPerPolicy = outputsPerPolicy;

			Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
		}
Exemplo n.º 3
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="copyFrom"></param>
		public NeatGenome(NeatGenome copyFrom, uint genomeId)
		{
			this.genomeId = genomeId;
            this.parent = copyFrom;

			// No need to loop the arrays to clone each element because NeuronGene and ConnectionGene are 
			// value data types (structs).
			neuronGeneList = new NeuronGeneList(copyFrom.neuronGeneList);
            moduleGeneList = new List<ModuleGene>(copyFrom.moduleGeneList);
			connectionGeneList = new ConnectionGeneList(copyFrom.connectionGeneList);

            //joel
            if(copyFrom.Behavior!=null)
            Behavior = new SharpNeatLib.BehaviorType(copyFrom.Behavior);
            
			inputNeuronCount = copyFrom.inputNeuronCount;
            // Schrum: Removed (not used)
			//inputAndBiasNeuronCount = copyFrom.inputNeuronCount+1;
			outputNeuronCount = copyFrom.outputNeuronCount;
            // Schrum: removed (not used)
			//inputBiasOutputNeuronCount = copyFrom.inputBiasOutputNeuronCount;
			//inputBiasOutputNeuronCountMinus2 = copyFrom.inputBiasOutputNeuronCountMinus2;
            // Schrum: Added
            outputsPerPolicy = copyFrom.outputsPerPolicy;

			Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
		}
Exemplo n.º 4
0
        public NeatGenome(long genomeId,
                NeuronGeneList neuronGeneList,
                List<ModuleGene> moduleGeneList,
                ConnectionGeneList connectionGeneList,
                int inputNeuronCount,
                int outputNeuronCount)
        {
            this.genomeId = genomeId;

            this.neuronGeneList = neuronGeneList;
            this.moduleGeneList = moduleGeneList;
            this.connectionGeneList = connectionGeneList;

            this.inputNeuronCount = inputNeuronCount;
            this.inputAndBiasNeuronCount = inputNeuronCount+1;
            this.outputNeuronCount = outputNeuronCount;
            this.inputBiasOutputNeuronCount = inputAndBiasNeuronCount + outputNeuronCount;
            this.inputBiasOutputNeuronCountMinus2 = inputBiasOutputNeuronCount-2;

            //all genomes must be catalogued by the evolution manager
            EvolutionManager.SharedEvolutionManager.GenomeCreated(this);

            if (!connectionGeneList.IsSorted())
            {
                connectionGeneList.IsSorted();
            }

            Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="copyFrom"></param>
        public NeatGenome(NeatGenome copyFrom, long genomeId)
        {
            this.genomeId = genomeId;
            this.parent = copyFrom;

            // No need to loop the arrays to clone each element because NeuronGene and ConnectionGene are
            // value data types (structs).
            neuronGeneList = new NeuronGeneList(copyFrom.neuronGeneList);
            moduleGeneList = new List<ModuleGene>(copyFrom.moduleGeneList);
            connectionGeneList = new ConnectionGeneList(copyFrom.connectionGeneList);

            //joel
            if(copyFrom.Behavior!=null)
            Behavior = new SharpNeatLib.BehaviorType(copyFrom.Behavior);

            inputNeuronCount = copyFrom.inputNeuronCount;
            inputAndBiasNeuronCount = copyFrom.inputNeuronCount+1;
            outputNeuronCount = copyFrom.outputNeuronCount;
            inputBiasOutputNeuronCount = copyFrom.inputBiasOutputNeuronCount;
            inputBiasOutputNeuronCountMinus2 = copyFrom.inputBiasOutputNeuronCountMinus2;

            //all genomes must be catalogued by the evolution manager
            EvolutionManager.SharedEvolutionManager.GenomeCreated(this);

            if (!connectionGeneList.IsSorted())
            {
                connectionGeneList.IsSorted();
            }

            Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="copyFrom"></param>
        public NeatGenome(NeatGenome copyFrom, uint genomeId)
        {
            this.genomeId = genomeId;

            // No need to loop the arrays to clone each element because NeuronGene and ConnectionGene are
            // value data types (structs).
            neuronGeneList = new NeuronGeneList(copyFrom.neuronGeneList);
            connectionGeneList = new ConnectionGeneList(copyFrom.connectionGeneList);

            inputNeuronCount = copyFrom.inputNeuronCount;
            inputAndBiasNeuronCount = copyFrom.inputNeuronCount+1;
            outputNeuronCount = copyFrom.outputNeuronCount;
            inputBiasOutputNeuronCount = copyFrom.inputBiasOutputNeuronCount;
            inputBiasOutputNeuronCountMinus2 = copyFrom.inputBiasOutputNeuronCountMinus2;

            Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
        }
Exemplo n.º 7
0
        public NeatGenome(uint genomeId,
                NeuronGeneList neuronGeneList,
                List<ModuleGene> moduleGeneList,
                ConnectionGeneList connectionGeneList,
                int inputNeuronCount,
                int outputNeuronCount)
        {
			this.genomeId = genomeId;

			this.neuronGeneList = neuronGeneList;
            this.moduleGeneList = moduleGeneList;
			this.connectionGeneList = connectionGeneList;

			this.inputNeuronCount = inputNeuronCount;
			this.inputAndBiasNeuronCount = inputNeuronCount+1;
			this.outputNeuronCount = outputNeuronCount;
			this.inputBiasOutputNeuronCount = inputAndBiasNeuronCount + outputNeuronCount;
			this.inputBiasOutputNeuronCountMinus2 = inputBiasOutputNeuronCount-2;

            //justin
            objectives = new double[6];
            nearestNeighbors = 0;
            localGenomeNovelty = 0;
            competition = 0;
            geneticDiversity = 0;
            locality = 0;
            Fitness = 0;
            RealFitness = 0;

			Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
		}
Exemplo n.º 8
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="copyFrom"></param>
		public NeatGenome(NeatGenome copyFrom, uint genomeId)
		{
			this.genomeId = genomeId;

			// No need to loop the arrays to clone each element because NeuronGene and ConnectionGene are 
			// value data types (structs).
			neuronGeneList = new NeuronGeneList(copyFrom.neuronGeneList);
            moduleGeneList = new List<ModuleGene>(copyFrom.moduleGeneList);
			connectionGeneList = new ConnectionGeneList(copyFrom.connectionGeneList);

            //joel
            if(copyFrom.Behavior!=null)
            Behavior = new SharpNeatLib.BehaviorType(copyFrom.Behavior);

            //justin
            objectives = (double[])(copyFrom.objectives.Clone());
            nearestNeighbors = copyFrom.nearestNeighbors;
            localGenomeNovelty = copyFrom.localGenomeNovelty;
            competition = copyFrom.competition;
            geneticDiversity = copyFrom.geneticDiversity;
            locality = copyFrom.locality;
            Fitness = copyFrom.Fitness;
            RealFitness = copyFrom.RealFitness;

            
			inputNeuronCount = copyFrom.inputNeuronCount;
			inputAndBiasNeuronCount = copyFrom.inputNeuronCount+1;
			outputNeuronCount = copyFrom.outputNeuronCount;
			inputBiasOutputNeuronCount = copyFrom.inputBiasOutputNeuronCount;
			inputBiasOutputNeuronCountMinus2 = copyFrom.inputBiasOutputNeuronCountMinus2;

			Debug.Assert(connectionGeneList.IsSorted(), "ConnectionGeneList is not sorted by innovation ID");
		}