private static void StartSCProblem() { var bestClassifiers = new Individual[8]; CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(MultiClassifierProblem)) }); var parameters = Evolve.LoadParameterDatabase(new[] { "-file", @"Params\App\Iris\single.params" }); IEvolutionState state = Evolve.Initialize(parameters, 0); var date = DateTime.Now.Ticks.ToString(); var directoryName = "stats/" + date; var directory = System.IO.Directory.CreateDirectory(directoryName); var writer = new System.IO.StreamWriter(directoryName + "/multi_cl_stats.txt", false); // IEvolutionState state = Evolve.Initialize(Evolve.LoadParameterDatabase(new[] { "-file", @"Params\App\Iris\single.params" }), 0); for (var i = 0; i < 8; i++) { // parameters = Evolve.LoadParameterDatabase(new[] { "-file", @"Params\App\Iris\single.params", "-stat.file", @"out1.stat" }); if (i != 0) { state = Evolve.Initialize(parameters, 0); } MultiClassificationClass.Current = MultiClassificationClass.Labels[i]; // state.Output.FilePrefix = i.ToString(); state.Run(EvolutionState.C_STARTED_FRESH); var best = ((SimpleStatistics)((SimpleEvolutionState)state).Statistics).BestOfRun[0]; int humanGraph = state.Output.AddLog(directoryName + "/multi_cl_human_graph_" + MultiClassificationClass.Current + ".txt"); int ecjGraph = state.Output.AddLog(directoryName + "/multi_cl_ecj_graph_" + MultiClassificationClass.Current + ".txt"); ((GPIndividual)best).Trees[0].PrintStyle = GPTree.PRINT_STYLE_DOT; ((GPIndividual)best).Trees[0].PrintTreeForHumans(state, humanGraph); ((GPIndividual)best).Trees[0].PrintTree(state, ecjGraph); state.Output.Close(); // System.IO.File.Delete("out.stat"); bestClassifiers[i] = best; var writer2 = new System.IO.StreamWriter(directoryName + "/classifier_code_" + MultiClassificationClass.Current + ".txt"); var code = TreeReader.PrintCodeFromTree(((GPIndividual)best).Trees[0]); writer2.Write(code); writer2.Close(); var accuracy = (double)(1552 - ((KozaFitness)bestClassifiers[i].Fitness).StandardizedFitness) / 1552; writer.WriteLine("Klasyfikator dla gestu " + MultiClassificationClass.Labels[i]); writer.WriteLine("Ilość generacji: " + state.NumGenerations.ToString()); writer.WriteLine("Rozmiar drzewa: " + ((GPIndividual)bestClassifiers[i]).Size.ToString()); writer.WriteLine("Poprawność klasyfikacji: " + accuracy.ToString()); writer.WriteLine(); // ((GPIndividual)bestClassifiers[0]).Trees[0].Child.Eval //((GPIndividual)bestClassifiers[0]).Trees[0]. // ((SingleClassifierProblem)state.Evaluator.p_problem) } writer.Close(); CheckClassifierOnTestData(bestClassifiers, state, (int)ClassifierType.MULTI_CLASSIFIER, directoryName); }
public void Tutorial2Basic() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(AddSubtract)) }); Evolve.Run(new[] { "-file", @"App/Tutorial2/Params/App/Tutorial2/tutorial2.params" }); context.WriteLine("\nDone!"); }
static void Main() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new [] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(MaxOnes)) }); Evolve.Run(new [] { "-file", @"Params\App\Tutorial1\tutorial1.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
public void Coevolve1() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(CompetitiveMaxOnes)) }); Evolve.Run(new[] { "-file", @"App/Coevolve1/Params/App/Coevolve1/coevolve1.params" }); context.WriteLine("\nDone!"); }
static void Main(string[] args) { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(RoyalTree)) }); Evolve.Run(new[] { "-file", @"Params\App\RoyalTree\royaltree.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
static void Main(string[] args) { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Edge)) }); // We can run in a loop using each numbered param file. But here we are just running one individually to examine the output. Evolve.Run(new[] { "-file", @"Params\App\Edge\7.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
public void EdgeTestBasic() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(Edge)) }); // We can run in a loop using each numbered param file. But here we are just running one individually to examine the output. Evolve.Run(new[] { "-file", @"App/Edge/Params/App/Edge/1.params" }); context.WriteLine("\nDone!"); }
static void Main(string[] args) { // NOTE : The Coevolve2.params file doesn't exist for some reason. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(ECSuite)) }); Evolve.Run(new[] { "-file", @"Params\App\Spatial\spatial.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
static void Main(string[] args) { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(CartPole)) }); // Here we are starting up with ant.params // But this can also be started with antge.params (which does generational evolution) Evolve.Run(new[] { "-file", @"Params/App/CartPole/cartpole.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
public void AntSantaFe() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(Ant)) }); // Here we are starting up with ant_santefe.params // But this can also be started ant_santefe_ge.params (which presumably does generational evolution; need to check) Evolve.Run(new[] { "-file", @"App/Ant/Params/App/Ant/ant_santafe.params" }); context.WriteLine("\nDone!"); }
public void LawnmowerBasic() { // With the default parameters, this finds an ideal solution in generation 14. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(Lawnmower)) }); Evolve.Run(new[] { "-file", @"App/Lawnmower/Params/App/Lawnmower/ge2.params" }); context.WriteLine("\nDone!"); }
public void SatBasic() { // BRS: TODO : Figure out why this runs okay, but it doesn't seem to improve. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(SAT)) }); Evolve.Run(new[] { "-file", @"App/Sat/Params/App/Sat/sat.params" }); context.WriteLine("\nDone!"); }
public void HiffBasic() { // BRS : TODO : This HIFF does not seem to be behaving correctly. Needs further investigation. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(HIFF)) }); Evolve.Run(new[] { "-file", @"App/Hiff/Params/App/Hiff/hiff.params" }); context.WriteLine("\nDone!"); }
static void Main(string[] args) { // BRS : TODO : This HIFF does not seem to be behaving correctly. Needs further investigation. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(HIFF)) }); Evolve.Run(new[] { "-file", @"Params\App\Hiff\hiff.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
static void Main(string[] args) { throw new NotImplementedException("DOvS is still under construction!"); // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(HighDimension)) }); Evolve.Run(new[] { "-file", @"Params\App\HighDimension\highdimension.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
static void Main(string[] args) { // With the default parameters, this finds an ideal solution in generation 14. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Lawnmower)) }); Evolve.Run(new[] { "-file", @"Params\App\Lawnmower\adf.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
public void MooSuiteBasic() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(MooSuite)) }); // We are defaulting to problem type ZDT1. Change this to another specific type for alternate tests. // Choices include: [sphere, zdt1, zdt2, zdt3, zdt4, zdt6, fon, pol, kur-nsga2, kur-spea2, qv, sch, f2, f3(unconstrained-f2.params)] Evolve.Run(new[] { "-file", @"App/MooSuite/Params/App/MooSuite/zdt1.params" }); context.WriteLine("\nDone!"); }
public void ParityBasic() { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(Parity)) }); // Either of the two provided param files can be used. // Choose "parity.params" to NOT use ADFs, or choose "adf.params" to use them. Evolve.Run(new[] { "-file", @"App/Parity/Params/App/Parity/parity.params" }); context.WriteLine("\nDone!"); }
static void Main(string[] args) { // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Parity)) }); // Either of the two provided param files can be used. // Choose "parity.params" to NOT use ADFs, or choose "adf.params" to use them. Evolve.Run(new[] { "-file", @"Params\App\Parity\parity.params" }); //Evolve.Run(new[] { "-file", @"Params\App\Parity\adf.params" }); // TODO: Not working right! Console.WriteLine("\nDone!"); Console.ReadLine(); }
private static void StartGP() { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; var test = new DataLoader(@"Datasets\gesty_pogrupowane.txt", 11, 1491, 1, 2, '\t'); ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(ClassificationProblem)) }); IEvolutionState state = Evolve.Initialize(Evolve.LoadParameterDatabase(new[] { "-file", @"Params\App\Iris\koza.params" }), 2); state.Run(EvolutionState.C_STARTED_FRESH); var best = ((SimpleStatistics)((SimpleEvolutionState)state).Statistics).BestOfRun[0]; var date = DateTime.Now.Ticks.ToString(); var directoryName = "stats/" + date; var directory = System.IO.Directory.CreateDirectory(directoryName); var stats = new List <string>(); stats.Add("Ilość pokoleń: " + state.NumGenerations); var accuracy = (double)(1552 - ((KozaFitness)best.Fitness).StandardizedFitness) / 1552; stats.Add("Rozmiar drzewa: " + ((GPIndividual)best).Size.ToString()); stats.Add("Głębokość drzewa: " + ((GPIndividual)best).Trees[0].Child.Depth.ToString()); stats.Add("Poprawność klasyfikacji dla danych uczących: " + accuracy.ToString()); System.IO.File.WriteAllLines(directoryName + "/single_cl_stats.txt", stats.ToArray()); var writer = new System.IO.StreamWriter(directoryName + "/classifier_code.txt"); var code = TreeReader.PrintCodeFromTree(((GPIndividual)best).Trees[0]); writer.Write(code); writer.Close(); int humanGraph = state.Output.AddLog(directoryName + "/single_cl_human_graph.txt"); int ecjGraph = state.Output.AddLog(directoryName + "/single_cl_ecj_graph.txt"); ((GPIndividual)best).Trees[0].PrintStyle = GPTree.PRINT_STYLE_DOT; ((GPIndividual)best).Trees[0].PrintTreeForHumans(state, humanGraph); ((GPIndividual)best).Trees[0].PrintTree(state, ecjGraph); CheckClassifierOnTestData(new[] { best }, state, (int)ClassifierType.SINGLE_CLASSIFIER, directoryName); //var data = new ClassificationData(); /* * state.Output.AddLog(@"F:\Logs\test.gv"); * ((GPIndividual)best[0]).Trees[0].PrintStyle = GPTree.PRINT_STYLE_DOT; * ((GPIndividual)best[0]).Trees[0].PrintTreeForHumans(state, state.Output.NumLogs - 1); * ((GPIndividual)best[0]).Trees[0].PrintTree(state, state.Output.NumLogs - 1); */ }
static void Main(string[] args) { // This application is missing ICCEAStatistics, which no longer seems to be included. // It was set in the local ecsuite.params (renamed ecsuite2.params), // so that we can have the library param file in the same directory. // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(CoevolutionaryECSuite)) }); Evolve.Run(new[] { "-file", @"Params/App/Coevolve2/coevolve2.params" }); Console.WriteLine("\nDone!"); Console.ReadLine(); }
private static void TestCode() { ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(ClassificationProblem)) }); var parameters = Evolve.LoadParameterDatabase(new[] { "-file", @"Params\App\Iris\koza.params" }); IEvolutionState state = Evolve.Initialize(parameters, 0); state.Setup(state, new Parameter(new string[] { "a" })); //state.Run(EvolutionState.C_STARTED_FRESH); // var individual = (GPIndividual)((SimpleStatistics)state.Statistics).BestOfRun[0]; var tree = new GPTree(); var reader = new System.IO.StreamReader("single_cl_ecj_graph.txt"); tree.ReadTree(state, reader); var writer = new System.IO.StreamWriter("testcode.txt"); var code = TreeReader.PrintCodeFromTree(tree); writer.Write(code); writer.Close(); }
public void BBOBenchmarkTest() { // NOTE: This requires some attention, since it is a fairly complex benchmark suite, and I'm not sure if it working properly yet. // One thing I changed was setting each individual to evalutated in BBOBenchmarks.Evalutate(...) // It was not previously doing this (intentional?). // This primes the activator so it knows where to look for types that will be created from parameters. ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(Evaluator)), Assembly.GetAssembly(typeof(BBOBenchmarks)) }); // Here we are starting up with bbob.params // But this can also be started with de.params (which does differential evolution) Evolve.Run(new[] { "-file", @"App/BBob/Params/App/BBob/bbob.params" }); context.WriteLine("\nDone!"); }
private static void CheckTreeFromFile() { ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(ClassificationProblem)) }); var parameters = Evolve.LoadParameterDatabase(new[] { "-file", @"Params\App\Iris\koza.params" }); IEvolutionState state = Evolve.Initialize(parameters, 0); state.Setup(state, new Parameter(new string[] { "a" })); //state.Run(EvolutionState.C_STARTED_FRESH); var individual = (GPIndividual)((SimpleStatistics)state.Statistics).BestOfRun[0]; var tree = new GPTree(); var reader = new System.IO.StreamReader("single_cl_ecj_graph.txt"); tree.ReadTree(state, reader); // individual.Setup(state, new Parameter(new string[] { "numtrees = 1", "1" })); individual.Trees[0] = tree; // CheckClassifierOnTestData(new[] { individual }, state, (int)ClassifierType.SINGLE_CLASSIFIER, directoryName); }
static void Main(string[] args) { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; ECActivator.AddSourceAssemblies(new[] { Assembly.GetAssembly(typeof(IEvolutionState)), Assembly.GetAssembly(typeof(FeatureExtractionProblem2)) }); IEvolutionState state = Evolve.Initialize(Evolve.LoadParameterDatabase(new[] { "-file", @"Parameters\problem2.params" }), 11); state.Run(EvolutionState.C_STARTED_FRESH); var problem = (FeatureExtractionProblem2)state.Evaluator.p_problem; // var treeLog1 = state.Output.AddLog(@"F:\Gesty\logs\gvtree_gen1.txt"); //var treeLog2 = state.Output.AddLog(@"F:\Gesty\logs\gvtree_gen10.txt"); //var ecjGraph = state.Output.AddLog(@"F:\Gesty\logs\ecjGraph.txt"); //var bestOfRun = ((SimpleStatistics)state.Statistics).BestOfRun[0]; //((GPIndividual)bestOfRun).Trees[0].PrintTree(state, ecjGraph); //((GPIndividual)bestOfRun).Trees[0].PrintStyle = GPTree.PRINT_STYLE_DOT; //((GPIndividual)bestOfRun).Trees[0].PrintTreeForHumans(state, treeLog); var input = problem.Input; var stack = problem.Stack; var stats = (SimpleStatistics)state.Statistics; var bestOfRun = (GPIndividual)stats.BestOfRun[0]; var treeReader = new StreamReader(@"F:\Gesty\logs\ecjGraph.txt"); bestOfRun.Trees[0].ReadTree(state, treeReader); bestOfRun.Evaluated = false; var imageList = new string[] { @"F:\Gesty\problem2\grayscale\A\a\color_0_0002.png", @"F:\Gesty\problem2\grayscale\A\b\color_1_0002.png", @"F:\Gesty\problem2\grayscale\A\c\color_2_0002.png", @"F:\Gesty\problem2\grayscale\A\f\color_5_0002.png", @"F:\Gesty\problem2\grayscale\A\h\color_7_0002.png" }; int i = 0; foreach (string image in imageList) { var dir = @"F:\Gesty\testy\examples"; var tempImg = new Image <Gray, Byte>(image); tempImg.CopyTo(problem.currentImage[0]); tempImg.CopyTo(problem.originalImage[0]); bestOfRun.Trees[0].Child.Eval(state, 0, input, stack, bestOfRun, problem); tempImg.Save(dir + @"\" + i + ".png"); problem.currentImage[0].Save(dir + @"\" + i + "_trans.png"); ImageTransformer.GetSquareSuperpixelImages(problem.currentImage[0], dir, i.ToString(), 8); i++; } problem.Evaluate(state, bestOfRun, 0, 0); Console.WriteLine(bestOfRun.Fitness); /* * var confMatFile = new StreamWriter(@"F:\Gesty\testy\confmatBest.csv"); * for (int x = 0; x < 10; x++) * { * var line = new StringBuilder(); * for (int j = 0; j < 10; j++) * { * line.Append(problem.confMat[x, j].ToString() + ';'); * } * confMatFile.WriteLine(line.ToString().Trim(';')); * } * confMatFile.Close(); */ // Console.WriteLine(bestOfRun.Fitness); /* * var tempImg = new Image<Gray, Byte>(@"F:\Gesty\problem2\grayscale\A\a\color_0_0002.png"); * tempImg.CopyTo(problem.currentImage[0]); * tempImg.CopyTo(problem.originalImage[0]); * ((GPIndividual)bestOfRun).Trees[0].Child.Eval(state, 0, input, stack, bestOfRun, problem); * problem.currentImage[0].Save(@"F:\Gesty\testy\transformed.png"); */ /* * var gesty = new string[8] { "piesc", "dlon", "1p", "2p", "3p", "4p", "5p", "kciuk" }; * var imageIndex = 0; * foreach (string gest in gesty) * { * var dir = @"F:\Gesty\superpixel\200x200\" + gest; * * //oryginalny * var tempImg = new Image<Gray, Byte>(problem.imageList[imageIndex]); * tempImg.CopyTo(problem.currentImage[0]); * tempImg.CopyTo(problem.originalImage[0]); * tempImg.Dispose(); * bestOfRun.Trees[0].Child.Eval(state, 0, input, stack, bestOfRun, problem); * problem.imageTransformer.GetSuperpixelImages(problem.currentImage[0], dir, "oryginalny"); * imageIndex += 101; * * //obrocony * var tempImg2 = new Image<Gray, Byte>(problem.imageList[imageIndex]); * tempImg2.CopyTo(problem.currentImage[0]); * tempImg2.CopyTo(problem.originalImage[0]); * tempImg2.Dispose(); * bestOfRun.Trees[0].Child.Eval(state, 0, input, stack, bestOfRun, problem); * problem.imageTransformer.GetSuperpixelImages(problem.currentImage[0], dir, "obrocony"); * imageIndex += 101; * * //zaklocony * var tempImg3 = new Image<Gray, Byte>(problem.imageList[imageIndex]); * tempImg3.CopyTo(problem.currentImage[0]); * tempImg3.CopyTo(problem.originalImage[0]); * tempImg3.Dispose(); * bestOfRun.Trees[0].Child.Eval(state, 0, input, stack, bestOfRun, problem); * problem.imageTransformer.GetSuperpixelImages(problem.currentImage[0], dir, "zaklocony"); * imageIndex += 11; * } */ Console.ReadKey(); }