void RunExperiment(string XMLFile, string filename) { _filename = filename; _experiment = new SocialExperiment(); // Write the header for the results file in CSV format. using (TextWriter writer = new StreamWriter(_filename)) writer.WriteLine("Generation,Average,Best,Updates"); using (TextWriter writer = new StreamWriter(_filename.Replace(".csv", "_diversity_after.csv"))) writer.WriteLine("Generation,Orientation Variance,Velocity Variance"); using (TextWriter writer = new StreamWriter(_filename.Replace(".csv", "_diversity_before.csv"))) writer.WriteLine("Generation,Orientation Variance,Velocity Variance"); // Load the XML configuration file XmlDocument xmlConfig = new XmlDocument(); xmlConfig.Load(XMLFile); _experiment.Initialize("SimpleEvolution", xmlConfig.DocumentElement); // Create the evolution algorithm and attach the update event. _ea = _experiment.CreateEvolutionAlgorithm(); _ea.UpdateScheme = new SharpNeat.Core.UpdateScheme(1); _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent); _experiment.Evaluator.TrialId = _trialNum; _experiment.Evaluator.DiversityFile = _filename.Replace(".csv", "_diversity.csv"); // Start algorithm (it will run on a background thread). _ea.StartContinue(); }
private void startEvolution() { gens = 0; // Create evolution algorithm and attach update event. _ea = _experiment.CreateEvolutionAlgorithm(); _ea.UpdateEvent += new EventHandler(ea_UpdateEvent); _experiment.Evaluator.LogDiversity = false; // Start algorithm (it will run on a background thread). _ea.StartContinue(); }