Ejemplo n.º 1
0
        /// <summary>
        /// Performs multiple generations of the evolutionary algorithm.
        /// </summary>
        public void evolve(int generations)
        {
            for (int j = 0; j < generations; j++)
            {
                oneGeneration(j);
            }
            LogOutput.Close();

            XmlDoc = new XmlDocument();
            XmlGenomeWriterStatic.Write(XmlDoc, (NeatGenome)EA.BestGenome, ActivationFunctionFactory.GetActivationFunction("NullFn"));
            OutputFileInfo = new FileInfo(Path.Combine(OutputFolder, "bestGenome.xml"));
            XmlDoc.Save(OutputFileInfo.FullName);


            //if doing novelty search, write out archive
            if (experiment.DefaultNeatParameters.noveltySearch)
            {
                XmlDocument archiveout = new XmlDocument();

                XmlPopulationWriter.WriteGenomeList(archiveout, EA.noveltyFixed.archive);
                OutputFileInfo = new FileInfo(Path.Combine(OutputFolder, "archive.xml"));
                archiveout.Save(OutputFileInfo.FullName);
            }

            // dump the MapElites grid contents (empty if we aren'type doing ME and we aren'type tracking ME-style-grid for some other algorithm)
            XmlDocument gridout = new XmlDocument();

            XmlPopulationWriter.WriteGenomeList(gridout, EA.meDumpGrid());
            OutputFileInfo = new FileInfo(Path.Combine(OutputFolder, "finalgrid.xml"));
            gridout.Save(OutputFileInfo.FullName);
        }