public void RunCFGGPSampleTestSolutionFound() { var ga = CreateCFGGPSample(); ga.SetSeedRandomly.Value = false; ga.Seed.Value = 461206446; ((CFGPythonProblem)ga.Problem).TimeoutParameter.Value.Value = 10000; SamplesUtils.RunAlgorithm(ga); Assert.AreEqual(0, SamplesUtils.GetDoubleResult(ga, "BestQuality")); Assert.AreEqual(13.09, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality")); Assert.AreEqual(99, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality")); Assert.AreEqual(1090, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions")); Assert.AreEqual(7, SamplesUtils.GetIntResult(ga, "Best training solution generation")); var bestTrainingSolution = (CFGPythonSolution)ga.Results["Best training solution"].Value; Assert.AreEqual(0, ((DoubleValue)bestTrainingSolution["Training Quality"].Value).Value); Assert.AreEqual(0, ((DoubleValue)bestTrainingSolution["Test Quality"].Value).Value); Assert.AreEqual(17, ((IntValue)bestTrainingSolution["Model Depth"].Value).Value); Assert.AreEqual(62, ((IntValue)bestTrainingSolution["Model Length"].Value).Value); Assert.AreEqual(1.0, ((PercentValue)bestTrainingSolution["Training Solved Cases Percentage"].Value).Value); Assert.AreEqual(1.0, ((PercentValue)bestTrainingSolution["Test Solved Cases Percentage"].Value).Value); var exceptionTable = (DataTable)ga.Results["Exception frequencies"].Value; Assert.AreEqual(1, exceptionTable.Rows.Count); Assert.IsTrue(exceptionTable.Rows.ContainsKey("No Exception")); Assert.IsTrue(exceptionTable.Rows["No Exception"].Values.All(x => x == 1)); }
public void DisposePythonProcesses() { var ga = CreateCFGGPSample(); ga.SetSeedRandomly.Value = false; ga.Seed.Value = 461206446; var before = Process.GetProcessesByName("python").Length; SamplesUtils.RunAlgorithm(ga); var after = Process.GetProcessesByName("python").Length; Assert.AreEqual(before + Environment.ProcessorCount * 2, after); (ga.Problem as CFGPythonProblem).Dispose(); Thread.Sleep(1000); //give it a second var afterDispose = Process.GetProcessesByName("python").Length; Assert.AreEqual(before, afterDispose); }