using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Algorithms.GeneticAlgorithm; using HeuristicLab.Problems.TestFunctions; using System.Threading; using HeuristicLab.Optimization; using HeuristicLab.Operators; using HeuristicLab.Hive.ExperimentManager; using HeuristicLab.PluginInfrastructure.Manager; using HeuristicLab.PluginInfrastructure; using System.Reflection; using System.IO; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.HiveEngineTest { class Program { static void Main(string[] args) { //PluginLoader.pluginAssemblies.Any(); PluginManager pm = new PluginManager(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); pm.DiscoverAndCheckPlugins(); pm.Run(pm.Applications.Where(x => x.Name == "TestApp").SingleOrDefault()); } } [Application("TestApp")] public class TestApp : ApplicationBase { public override void Run() { ContentManager.Initialize(new PersistenceContentManager()); ServiceLocator.Instance.ClientFacadePool.UserName = "cneumuel"; ServiceLocator.Instance.ClientFacadePool.Password = "cneumuel"; ServiceLocator.Instance.StreamedClientFacadePool.UserName = "cneumuel"; ServiceLocator.Instance.StreamedClientFacadePool.Password = "cneumuel"; GeneticAlgorithm ga = new GeneticAlgorithm(); ga.Problem = new SingleObjectiveTestFunctionProblem(); ga.Engine = new HiveEngine.HiveEngine(); ga.PopulationSize.Value = 10; ga.MaximumGenerations.Value = 3; ga.Start(); while (ga.ExecutionState != Core.ExecutionState.Stopped && ga.ExecutionState != Core.ExecutionState.Paused) { Thread.Sleep(2000); Console.Clear(); Console.WriteLine(string.Join(Environment.NewLine, ga.Results.Select(x => x.ToString()).ToArray())); Console.WriteLine("---"); Console.WriteLine("Log:"); Console.WriteLine(string.Join(Environment.NewLine, ga.Engine.Log.Messages.ToArray())); } Console.WriteLine("finished: " + ga.ExecutionState); Console.WriteLine("Storing..."); ContentManager.Save((IStorableContent)ga, string.Format("result_{0}.hl", DateTime.Now.ToString("yy.MM.dd HH;mm;ss")), true); Console.WriteLine("Finished"); } } [Plugin("TestPlugin", "1.0.0.0")] [PluginFile("HeuristicLab.HiveEngineTest.exe", PluginFileType.Assembly)] public class TestPlugin : PluginBase { } }