Пример #1
0
        public EvolutionAlgorithm initializeEvolutionAlgorithm(IPopulationEvaluator popEval, int popSize, AssessGenotypeFunction assess, List <long> parentGenomeIDs = null)
        {
            //have to add our seed to the parents!
            if (officialSeedGenome != null)
            {
                //if we aren't given any parents, make a new list, and add the seed
                if (parentGenomeIDs == null)
                {
                    parentGenomeIDs = new List <long>();
                }

                parentGenomeIDs.Add(officialSeedGenome.GenomeId);
            }

            //create our initial population, using seeds or not, making sure it is at least "popsize" long
            GenomeList gl = createGenomeList(popSize, assess, parentGenomeIDs);

            //now we have a genomelist full of our parents, if they didn't die in a car crash when we were young, yay!
            //also, these parents, their connections, and neurons are safely catalogued by WIN (eventually...)
            Population pop = new Population(idgen, gl);

            //create our algorithm
            evoAlgorithm = new EvolutionAlgorithm(pop, popEval, neatParams, assess);

            createExperimentDirectory();

            //send it away!
            return(evoAlgorithm);
        }
Пример #2
0
 public void initalizeEvoManager(int cInputs, int cOuputs, NeatParameters np, IPopulationEvaluator popEval)
 {
     cppnInputs     = cInputs;
     cppnOutputs    = cOuputs;
     neatParams     = np;
     populationEval = popEval;
 }
Пример #3
0
        public void ResetEvaluator(IActivationFunction activationFn)
        {
            m_eventAllAgentsRegistered.WaitOne();

            populationEvaluator = new
                                  EveryonePopulationEvaluator(new FourDFieldSubsNetworkEvaluator(m_neatQTables));
        }
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     if (multiple)
     {
         populationEvaluator = new SkirmishPopulationEvaluator(new SkirmishNetworkEvaluator(5, shape));
     }
     else
     {
         populationEvaluator = new SkirmishPopulationEvaluator(new SkirmishNetworkEvaluator(1, shape));
     }
 }
Пример #5
0
        public NoveltyThread(JSPopulationEvaluator jsPop, AssessGenotypeFunction assess, int popSize)
        {
            //save our objects for executing later!
            popEval        = jsPop;
            populationSize = popSize;

            autoEvent = new AutoResetEvent(false);


            waitNextTime = true;

            novelThread = new Thread(delegate()
            {
                autoEvent.WaitOne();

                //we'll start by testing with 0 parents, and popsize of 15 yay!
                noveltyRun = EvolutionManager.SharedEvolutionManager.initializeEvolutionAlgorithm(popEval, populationSize, assess);

                //let our algoirhtm know we want to do novelty gosh darnit
                if (noveltyRun.multiobjective != null)
                {
                    noveltyRun.multiobjective.doNovelty = true;
                }

                //we make sure we don't wait in this loop, since we just got started!
                waitNextTime = false;

                while (true)
                {
                    //this will cause us to pause!
                    if (waitNextTime)
                    {
                        waitNextTime = false;
                        autoEvent.WaitOne();
                    }
                    // Start the stopwatch we'll use to measure eval performance
                    Stopwatch sw = Stopwatch.StartNew();

                    //run the generation
                    noveltyRun.PerformOneGeneration();

                    // Stop the stopwatch
                    sw.Stop();

                    // Report the results
                    Console.WriteLine("Time used per gen (float): {0} ms", sw.Elapsed.TotalMilliseconds);
                    Console.WriteLine("Time used per gen (rounded): {0} ms", sw.ElapsedMilliseconds);
                }
            });

            novelThread.Start();
        }
Пример #6
0
		/// <summary>
		/// Default Constructor.
		/// </summary>
		public EvolutionAlgorithm(Population pop, IPopulationEvaluator populationEvaluator, NeatParameters neatParameters)
		{
			this.pop = pop;
			this.populationEvaluator = populationEvaluator;
			this.neatParameters = neatParameters;
			neatParameters_Normal = neatParameters;

			neatParameters_PrunePhase = new NeatParameters(neatParameters);
			neatParameters_PrunePhase.pMutateAddConnection = 0.0;
            neatParameters_PrunePhase.pMutateAddNode = 0.0;
            neatParameters_PrunePhase.pMutateAddModule = 0.0;
            neatParameters_PrunePhase.pMutateConnectionWeights = 0.33;
			neatParameters_PrunePhase.pMutateDeleteConnection = 0.33;
			neatParameters_PrunePhase.pMutateDeleteSimpleNeuron = 0.33;

			// Disable all crossover as this has a tendency to increase complexity, which is precisely what
			// we don't want during a pruning phase.
			neatParameters_PrunePhase.pOffspringAsexual = 1.0;
			neatParameters_PrunePhase.pOffspringSexual = 0.0;
			
			if(neatParameters.multiobjective) {
				this.multiobjective=new Multiobjective.Multiobjective(neatParameters);
				neatParameters.compatibilityThreshold=100000000.0; //disable speciation w/ multiobjective
			}
			
            if(neatParameters.noveltySearch)
            {
                if(neatParameters.noveltyHistogram)
                {
                    this.noveltyFixed = new noveltyfixed(neatParameters.archiveThreshold);
                    this.histogram = new noveltyhistogram(neatParameters.histogramBins);
					noveltyInitialized=true;
                    InitialisePopulation();
                }
                
                if(neatParameters.noveltyFixed || neatParameters.noveltyFloat)
                {
                    this.noveltyFixed = new noveltyfixed(neatParameters.archiveThreshold);
                    InitialisePopulation();
                    noveltyFixed.initialize(this.pop);
					noveltyInitialized=true;
			        populationEvaluator.EvaluatePopulation(pop, this);			
			        UpdateFitnessStats();
			        DetermineSpeciesTargetSize();
                }
               
            }
            else
            {
			InitialisePopulation();
			}
		}
Пример #7
0
        public NoveltyThread(JSPopulationEvaluator jsPop, AssessGenotypeFunction assess, int popSize)
        {
            //save our objects for executing later!
            popEval = jsPop;
            populationSize = popSize;

            autoEvent = new AutoResetEvent(false);

            waitNextTime = true;

            novelThread = new Thread(delegate()
                {
                    autoEvent.WaitOne();

                    //we'll start by testing with 0 parents, and popsize of 15 yay!
                    noveltyRun = EvolutionManager.SharedEvolutionManager.initializeEvolutionAlgorithm(popEval, populationSize, assess);

                    //let our algoirhtm know we want to do novelty gosh darnit
                    if(noveltyRun.multiobjective != null)
                         noveltyRun.multiobjective.doNovelty = true;

                    //we make sure we don't wait in this loop, since we just got started!
                    waitNextTime = false;

                    while (true)
                    {
                        //this will cause us to pause!
                        if (waitNextTime)
                        {
                            waitNextTime = false;
                            autoEvent.WaitOne();
                        }
                        // Start the stopwatch we'll use to measure eval performance
                        Stopwatch sw = Stopwatch.StartNew();

                        //run the generation
                        noveltyRun.PerformOneGeneration();

                        // Stop the stopwatch
                        sw.Stop();

                        // Report the results
                        Console.WriteLine("Time used per gen (float): {0} ms", sw.Elapsed.TotalMilliseconds);
                        Console.WriteLine("Time used per gen (rounded): {0} ms", sw.ElapsedMilliseconds);

                    }
                });

            novelThread.Start();
        }
Пример #8
0
		/// <summary>
		/// Default Constructor.
		/// </summary>
		public EvolutionAlgorithm(Population pop, IPopulationEvaluator populationEvaluator) : this(pop, populationEvaluator, new NeatParameters())
		{}
Пример #9
0
        public void ResetEvaluator(SharpNeatLib.NeuralNetwork.IActivationFunction activationFn)
        {
              //populationEval = new SingleFilePopulationEvaluator(new NetworkEvaluator(simExp),null);
   		      populationEval = new MultiThreadedPopulationEvaluator(new NetworkEvaluator(simExp),null);
		}
Пример #10
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     // populationEvaluator = new SingleFilePopulationEvaluator(new RobotDualNetworkEvaluator(), activationFn);
     populationEvaluator = new PacmanPopulationEvaluatorSUPG(new PacmanNetworkEvaluatorSUPG(), activationFn);
 }
Пример #11
0
        public EvolutionAlgorithm initializeEvolutionAlgorithm(IPopulationEvaluator popEval, int popSize, AssessGenotypeFunction assess, List<long> parentGenomeIDs = null)
        {
            //have to add our seed to the parents!
            if (officialSeedGenome != null)
            {
                //if we aren't given any parents, make a new list, and add the seed
                if (parentGenomeIDs == null)
                    parentGenomeIDs = new List<long>();

                parentGenomeIDs.Add(officialSeedGenome.GenomeId);
            }

            //create our initial population, using seeds or not, making sure it is at least "popsize" long
            GenomeList gl = createGenomeList(popSize, assess, parentGenomeIDs);

            //now we have a genomelist full of our parents, if they didn't die in a car crash when we were young, yay!
            //also, these parents, their connections, and neurons are safely catalogued by WIN (eventually...)
            Population pop = new Population(idgen, gl);

            //create our algorithm
            evoAlgorithm = new EvolutionAlgorithm(pop, popEval, neatParams, assess);

            createExperimentDirectory();

            //send it away!
            return evoAlgorithm;
        }
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new
                           EveryonePopulationEvaluator(new CCEAGeomCtrlNetworkEvaluator(m_neatQTable));
 }
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new
                           EveryonePopulationEvaluator(new FieldSubs3LNetworkEvaluator(m_neatQTable));
 }
Пример #14
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new SingleFilePopulationEvaluator(new XorNetworkEvaluator(), activationFn);
 }
Пример #15
0
 public void ResetEvaluator(SharpNeatLib.NeuralNetwork.IActivationFunction activationFn)
 {
     //populationEval = new SingleFilePopulationEvaluator(new NetworkEvaluator(simExp),null);
     populationEval = new MultiThreadedPopulationEvaluator(new NetworkEvaluator(simExp), null);
 }
Пример #16
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new EveryonePopulationEvaluator(new
                                                           Skirmish3DNetworkEvaluator(m_numAgents, shape));
 }
Пример #17
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     if(multiple)
         populationEvaluator = new SkirmishPopulationEvaluator(new SkirmishNetworkEvaluator(5, shape));
     else
         populationEvaluator = new SkirmishPopulationEvaluator(new SkirmishNetworkEvaluator(1, shape));
 }
Пример #18
0
        /// <summary>
        /// Default Constructor.
        /// </summary>
        public EvolutionAlgorithm(Population pop, IPopulationEvaluator populationEvaluator, NeatParameters neatParameters)
        {
            this.pop = pop;
            this.populationEvaluator = populationEvaluator;
            this.neatParameters = neatParameters;
            neatParameters_Normal = neatParameters;

            neatParameters_PrunePhase = new NeatParameters(neatParameters);
            neatParameters_PrunePhase.pMutateAddConnection = 0.0;
            neatParameters_PrunePhase.pMutateAddNode = 0.0;
            neatParameters_PrunePhase.pMutateConnectionWeights = 0.33;
            neatParameters_PrunePhase.pMutateDeleteConnection = 0.33;
            neatParameters_PrunePhase.pMutateDeleteSimpleNeuron = 0.33;

            // Disable all crossover as this has a tendency to increase complexity, which is precisely what
            // we don't want during a pruning phase.
            neatParameters_PrunePhase.pOffspringAsexual = 1.0;
            neatParameters_PrunePhase.pOffspringSexual = 0.0;

            InitialisePopulation();
        }
		/// <summary>
		/// Default Constructor.
		/// </summary>
		public EvolutionAlgorithm(Population pop, IPopulationEvaluator populationEvaluator, NeatParameters neatParameters)
		{
			this.pop = pop;
			this.populationEvaluator = populationEvaluator;
			this.neatParameters = neatParameters;
			neatParameters_Normal = neatParameters;

			neatParameters_PrunePhase = new NeatParameters(neatParameters);
			neatParameters_PrunePhase.pMutateAddConnection = 0.0;
            neatParameters_PrunePhase.pMutateAddNode = 0.0;
            neatParameters_PrunePhase.pMutateAddModule = 0.0;
            neatParameters_PrunePhase.pMutateConnectionWeights = 0.33;
			neatParameters_PrunePhase.pMutateDeleteConnection = 0.33;
			neatParameters_PrunePhase.pMutateDeleteSimpleNeuron = 0.33;

			// Disable all crossover as this has a tendency to increase complexity, which is precisely what
			// we don't want during a pruning phase.
			neatParameters_PrunePhase.pOffspringAsexual = 1.0;
			neatParameters_PrunePhase.pOffspringSexual = 0.0;

            if (neatParameters.mapelites)
            {
                meInitialisePopulation();
                meGridInit(pop);
                Console.WriteLine("Mapelites stuff has been initialized. Oh btw, we're doing mapelites.");
                if (neatParameters.me_simpleGeneticDiversity)
                {
                    Console.WriteLine("Mapelites reinforced by the power of 51MPLE gENET1C d1VER51TY!!!!1  *fireworks* *applause* *receive phd*");
                }
                if (neatParameters.me_noveltyPressure)
                {
                    Console.WriteLine("Mapelites now with NOVELTY PRESSURE! (>'')>");
                }
            } // Skip all that other stupid shit if we are doing MapElites
            else if (neatParameters.NS2)
            {
                if (neatParameters.NS1) ns1 = true;

                ns2InitializePopulation();
                if (neatParameters.track_me_grid)
                {
                    Console.WriteLine("Initializing mapelites-style-grid genome tracking..");
                    meGridInit(pop);
                }
                Console.WriteLine("Novelty Search 2.0 has been initialized.");
            } // Skip the code jungle below if we are doing Novelty Search 2.0
            else if (neatParameters.NSLC) // (Steady-State NSLC -- NEW!!)
            {
                // TODO: JUSTIN: SS-NSLC GOES HERE!
                ns1 = true;
                ns2InitializePopulation();
                if (neatParameters.track_me_grid)
                {
                    Console.WriteLine("Initializing mapelites-style-grid genome tracking..");
                    meGridInit(pop);
                }
                Console.WriteLine("Initializing STEADY STATE -- NSLC! NEW! This is a thing that is happening now. You cannot stop it. Relax.");
                // TODO: INITIALIZATION for SS-NSLC (is like NS1... but make it separate so we can stop being so intertwined. cleaner is better, yo)


            } // Skip the nasty quagmire of unverified bogus rotten banana sandwiches if doing Steady-State NSLC
            else
            {
                if (neatParameters.multiobjective)
                {
                    this.multiobjective = new Multiobjective.Multiobjective(neatParameters);
                    neatParameters.compatibilityThreshold = 100000000.0; //disable speciation w/ multiobjective
                }

                if (neatParameters.noveltySearch)
                {
                    if (neatParameters.noveltyHistogram)
                    {
                        this.noveltyFixed = new noveltyfixed(neatParameters.archiveThreshold);
                        this.histogram = new noveltyhistogram(neatParameters.histogramBins);
                        noveltyInitialized = true;
                        InitialisePopulation();
                    }

                    if (neatParameters.noveltyFixed || neatParameters.noveltyFloat)
                    {
                        this.noveltyFixed = new noveltyfixed(neatParameters.archiveThreshold);
                        InitialisePopulation();
                        noveltyFixed.initialize(this.pop);
                        noveltyInitialized = true;
                        populationEvaluator.EvaluatePopulation(pop, this);
                        UpdateFitnessStats();
                        DetermineSpeciesTargetSize();
                    }

                    if (neatParameters.track_me_grid)
                    {
                        Console.WriteLine("Initializing mapelites-style-grid genome tracking..");
                        meGridInit(pop); // JUSTIN: Trying to add grid-tracking to NS1
                    }

                }
                else
                {
                    InitialisePopulation();

                    if (neatParameters.track_me_grid)
                    {
                        Console.WriteLine("Initializing mapelites-style-grid genome tracking..");
                        meGridInit(pop); // JUSTIN: Trying to add grid-tracking to fitness-based search
                    }
                }
            }
		}
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new
                           EveryonePopulationEvaluator(new HyperNEATPlayerNetworkEvaluator(m_neatQTable));
 }
Пример #21
0
 public void initalizeEvoManager(int cInputs, int cOuputs, NeatParameters np, IPopulationEvaluator popEval)
 {
     cppnInputs = cInputs;
     cppnOutputs = cOuputs;
     neatParams = np;
     populationEval = popEval;
 }
Пример #22
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new ClunePopulationEvaluator(new CluneNetworkEvaluator(inputs, outputs, hidden));
 }
Пример #23
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     // populationEvaluator = new SingleFilePopulationEvaluator(new RobotDualNetworkEvaluator(), activationFn);
     populationEvaluator = new FoodGathererPopulationEvaluator(new FoodGathererNetworkEvaluator(), activationFn);
 }
Пример #24
0
 public void ResetEvaluator(IActivationFunction activationFn)
 {
     populationEvaluator = new EveryonePopulationEvaluator(
         new SkirmishCCEANetworkEvaluator(m_agentId));
     //populationEvaluator = new SkirmishPopulationEvaluator(new SkirmishNetworkEvaluator(1, shape));
 }