static void Main(string[] args) { Console.CancelKeyPress += delegate { if (null != __streamWriter) { __streamWriter.Close(); } }; string experimentId; string filename; StopCondition stopCond = ArgUtils.ReadArgs(args, out experimentId, out filename); if (null == stopCond) { return; } // Initialise NEAT experiment. IGuiNeatExperiment experiment = InitExperiment(experimentId); if (null == experiment) { return; } // Initialise log4net (log to console). XmlConfigurator.Configure(new FileInfo("log4net.properties")); // Initialise evolution algorithm host. EvolutionAlgorithmHost eaHost = new EvolutionAlgorithmHost(experiment, stopCond); __streamWriter = InitOutputFile(filename); try { for (;;) { double secs; int gens; double fitness = eaHost.Sample(out secs, out gens); __streamWriter.WriteLine($"{secs},{gens},{fitness}"); __streamWriter.Flush(); } } finally { if (null != __streamWriter) { __streamWriter.Close(); } } }
static void Main(string[] args) { Console.CancelKeyPress += delegate { if (null != __streamWriter) { __streamWriter.Close(); } }; string experimentId; string filename; StopCondition stopCond = ArgUtils.ReadArgs(args, out experimentId, out filename); if (null == stopCond) { return; } // Initialise NEAT experiment. IGuiNeatExperiment experiment = InitExperiment(experimentId); if (null == experiment) { return; } // Initialise log4net (log to console). XmlConfigurator.Configure(new FileInfo("log4net.properties")); // Initialise evolution algorithm host. EvolutionAlgorithmHost eaHost = new EvolutionAlgorithmHost(experiment, stopCond); __streamWriter = InitOutputFile(filename); try { for (;;) { Sample s = eaHost.Sample(); __streamWriter.WriteLine($"{s.ElapsedTimeSecs},{s.GenerationCount},{s.BestFitness:0.#####},{s.MeanFitness:0.#####},{s.MaxComplexity:0.#####},{s.MeanComplexity:0.#####},{s.EvaluationCount}"); __streamWriter.Flush(); } } finally { if (null != __streamWriter) { __streamWriter.Close(); } } }
private IGuiNeatExperiment GetSelectedExperiment() { if(null == _selectedExperiment && null != cmbExperiments.SelectedItem) { ExperimentInfo expInfo = (ExperimentInfo)(((ListItem)cmbExperiments.SelectedItem).Data); Assembly assembly = Assembly.LoadFrom(expInfo.AssemblyPath); // TODO: Handle non-gui experiments. _selectedExperiment = assembly.CreateInstance(expInfo.ClassName) as IGuiNeatExperiment; _selectedExperiment.Initialize(expInfo.Name, expInfo.XmlConfig); } return _selectedExperiment; }
private void cmbExperiments_SelectedIndexChanged(object sender, EventArgs e) { // Nullify this variable. We get the selected experiment via GetSelectedExperiment(). That method will instantiate // _selectedExperiment with the currently selected experiment (on-demand instantiation). _selectedExperiment = null; // Close any experiment specific forms that remain open. if(null != _bestGenomeForm) { _bestGenomeForm.Close(); _bestGenomeForm = null; } if(null != _domainForm) { _domainForm.Close(); _domainForm = null; } }
public EvolutionAlgorithmHost(IGuiNeatExperiment experiment, StopCondition stopCond) { _experiment = experiment; _stopCond = stopCond; _stopwatch = new Stopwatch(); }