public void measure_novelty() { int count = population.Count; nov.initialize(population); for (int i = 0; i < count; i++) { population[i].locality = 0.0; population[i].competition = 0.0; } double max = 0.0, min = 100000000000.0; for (int i = 0; i < count; i++) { double fit = nov.measureNovelty((NeatGenome.NeatGenome)population[i]); population[i].objectives[population[i].objectives.Length - 2] = fit + 0.01; if (fit > max) { max = fit; } if (fit < min) { min = fit; } } Console.WriteLine("nov min: " + min.ToString() + " max:" + max.ToString()); }
/// <summary> /// JUSTIN: DO NOT USE THIS METHOD /// IT WAS IN THE ORIGINAL CODEBASE AND IT CAUSED ME 2 WEEKS WORTH OF PROBLEMS. CIRCUMVENTING IT ENTIRELY AND CALCULATING THE NECESSARY OBJECTIVES ELSEWHERE /// THE NOVELTY PATHWAY IN MULTIOBJECTIVE.CS IS/WAS PRETTY BROKEN.. /// /// I am removing the call to this method, and leaving it here as legacy code /// </summary> public void measure_novelty() { int count = population.Count; Console.WriteLine(count + " population members... why is this not 500?"); nov.initialize(population); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); Console.WriteLine("IF YOU SEE THIS IN THE OUTPUT, YOU ARE CALLING A BROKEN FUNCTION. DON'T DO THAT."); for (int i = 0; i < count; i++) { population[i].locality = 0.0; population[i].competition = 0.0; population[i].localGenomeNovelty = 0.0; population[i].nearestNeighbors = 0; } double max = 0.0, min = 100000000000.0; for (int i = 0; i < count; i++) { double fit = nov.measureNovelty((NeatGenome.NeatGenome)population[i]); population[i].objectives[population[i].objectives.Length - 2] = fit + 0.01; // Novelty Objective population[i].objectives[population[i].objectives.Length - 1] = population[i].localGenomeNovelty / population[i].nearestNeighbors; // Local Genetic Diversity Objective population[i].objectives[population[i].objectives.Length - 3] = population[i].competition / population[i].nearestNeighbors; // Local Competition Objective //Console.WriteLine("localGenomeNovelty: " + population[i].localGenomeNovelty + " competition: " + population[i].competition); Console.Write("THERE ARE " + population[i].objectives.Length + " OBJECTIVES: "); //JUSTIN: DEBUG - REMOVE THIS foreach (double d in population[i].objectives) { Console.Write(d + " "); //JUSTIN: DEBUG - REMOVE THIS } Console.WriteLine(); //JUSTIN: DEBUG - REMOVE THIS if (fit > max) { max = fit; } if (fit < min) { min = fit; } } Console.WriteLine("nov min: " + min.ToString() + " max:" + max.ToString()); }
public void measure_novelty() { int count = population.Count; nov.initialize(population); for (int i = 0; i < count; i++) { population[i].locality = 0.0; population[i].competition = 0.0; } NeatGenome.NeatGenome ng; double max = 0.0, min = 100000000000.0; for (int i = 0; i < count; i++) { ng = (NeatGenome.NeatGenome)population[i]; double fit = nov.measureNovelty(ng); //reset our fitness value to be local, yeah boyee ng.objectives[0] = ng.competition / ng.nearestNeighbors; ng.objectives[ng.objectives.Length - 2] = fit + 0.01; Console.WriteLine("Genomic Novelty: " + ng.objectives[ng.objectives.Length - 1] + " After: " + ng.localGenomeNovelty / ng.nearestNeighbors); //this makes genomic novelty into a local measure ng.objectives[ng.objectives.Length - 1] = ng.localGenomeNovelty / ng.nearestNeighbors; if (fit > max) { max = fit; } if (fit < min) { min = fit; } } Console.WriteLine("nov min: " + min.ToString() + " max:" + max.ToString()); }
/// <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(); } }
/// <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 } } } }