public void SaveAndLoadPopulationToZipArchive() { // Create a test population. NeatPopulation <double> pop = NestGenomeTestUtils.CreateNeatPopulation(); // Build path to test population folder. string parentPath = Path.Combine(Directory.GetCurrentDirectory(), "test-pops"); // Delete folder if it already exists. if (Directory.Exists(parentPath)) { Directory.Delete(parentPath, true); } // Create an empty parent folder to save populations into. Directory.CreateDirectory(parentPath); // Save the population to the unit test output folder. NeatPopulationSaver <double> .SaveToZipArchive(pop.GenomeList, parentPath, "pop2", System.IO.Compression.CompressionLevel.Optimal); // Load the population. NeatPopulationLoader <double> loader = NeatPopulationLoaderFactory.CreateLoaderDouble(pop.MetaNeatGenome); string populationZipPath = Path.Combine(parentPath, "pop2.zip"); List <NeatGenome <double> > genomeListLoaded = loader.LoadFromZipArchive(populationZipPath); // Compare the loaded genomes with the original genome list. IOTestUtils.CompareGenomeLists(pop.GenomeList, genomeListLoaded); }
public void SaveAndLoadPopulationToZipArchive() { // Create a test population. NeatPopulation <double> pop = NestGenomeTestUtils.CreateNeatPopulation(); // Create a parent folder to save populations into. string parentPath = Path.Combine(TestContext.TestRunDirectory, "test-pops"); Directory.CreateDirectory(parentPath); // Save the population to the unit test output folder. NeatPopulationSaver <double> .SaveToZipArchive(pop.GenomeList, parentPath, "pop2", System.IO.Compression.CompressionLevel.Optimal); // Load the population. NeatPopulationLoader <double> loader = NeatPopulationLoaderFactory.CreateLoaderDouble(pop.MetaNeatGenome); string populationZipPath = Path.Combine(parentPath, "pop2.zip"); List <NeatGenome <double> > genomeListLoaded = loader.LoadFromZipArchive(populationZipPath); // Compare the loaded genomes with the original genome list. IOTestUtils.CompareGenomeLists(pop.GenomeList, genomeListLoaded); }