[5153] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using HeuristicLab.Algorithms.GeneticAlgorithm;
|
---|
| 6 | using HeuristicLab.Problems.TestFunctions;
|
---|
| 7 | using System.Threading;
|
---|
| 8 | using HeuristicLab.Optimization;
|
---|
| 9 | using HeuristicLab.Operators;
|
---|
| 10 | using HeuristicLab.Hive.ExperimentManager;
|
---|
| 11 | using HeuristicLab.PluginInfrastructure.Manager;
|
---|
| 12 | using HeuristicLab.PluginInfrastructure;
|
---|
| 13 | using System.Reflection;
|
---|
| 14 | using System.IO;
|
---|
| 15 | using HeuristicLab.Common;
|
---|
| 16 | using HeuristicLab.Core;
|
---|
| 17 |
|
---|
| 18 | namespace HeuristicLab.HiveEngineTest {
|
---|
| 19 | class Program {
|
---|
| 20 | static void Main(string[] args) {
|
---|
| 21 | //PluginLoader.pluginAssemblies.Any();
|
---|
| 22 | PluginManager pm = new PluginManager(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
|
---|
| 23 | pm.DiscoverAndCheckPlugins();
|
---|
| 24 |
|
---|
| 25 | pm.Run(pm.Applications.Where(x => x.Name == "TestApp").SingleOrDefault());
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | [Application("TestApp")]
|
---|
| 30 | public class TestApp : ApplicationBase {
|
---|
| 31 |
|
---|
| 32 | public override void Run() {
|
---|
| 33 | ContentManager.Initialize(new PersistenceContentManager());
|
---|
| 34 | ServiceLocator.Instance.ClientFacadePool.UserName = "cneumuel";
|
---|
[5213] | 35 | ServiceLocator.Instance.ClientFacadePool.Password = "cneumuel";
|
---|
[5153] | 36 | ServiceLocator.Instance.StreamedClientFacadePool.UserName = "cneumuel";
|
---|
[5213] | 37 | ServiceLocator.Instance.StreamedClientFacadePool.Password = "cneumuel";
|
---|
[5153] | 38 |
|
---|
| 39 | GeneticAlgorithm ga = new GeneticAlgorithm();
|
---|
| 40 | ga.Problem = new SingleObjectiveTestFunctionProblem();
|
---|
| 41 | ga.Engine = new HiveEngine.HiveEngine();
|
---|
| 42 | ga.PopulationSize.Value = 10;
|
---|
| 43 | ga.MaximumGenerations.Value = 3;
|
---|
| 44 |
|
---|
[5213] | 45 | ga.Start();
|
---|
[5153] | 46 |
|
---|
[5213] | 47 | while (ga.ExecutionState != Core.ExecutionState.Stopped && ga.ExecutionState != Core.ExecutionState.Paused) {
|
---|
[5153] | 48 | Thread.Sleep(2000);
|
---|
| 49 | Console.Clear();
|
---|
[5213] | 50 | Console.WriteLine(string.Join(Environment.NewLine, ga.Results.Select(x => x.ToString()).ToArray()));
|
---|
[5153] | 51 | Console.WriteLine("---");
|
---|
| 52 | Console.WriteLine("Log:");
|
---|
[5213] | 53 | Console.WriteLine(string.Join(Environment.NewLine, ga.Engine.Log.Messages.ToArray()));
|
---|
[5153] | 54 | }
|
---|
[5213] | 55 | Console.WriteLine("finished: " + ga.ExecutionState);
|
---|
[5153] | 56 |
|
---|
| 57 | Console.WriteLine("Storing...");
|
---|
[5213] | 58 | ContentManager.Save((IStorableContent)ga, string.Format("result_{0}.hl", DateTime.Now.ToString("yy.MM.dd HH;mm;ss")), true);
|
---|
[5153] | 59 | Console.WriteLine("Finished");
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | [Plugin("TestPlugin", "1.0.0.0")]
|
---|
| 64 | [PluginFile("HeuristicLab.HiveEngineTest.exe", PluginFileType.Assembly)]
|
---|
| 65 | public class TestPlugin : PluginBase { }
|
---|
| 66 |
|
---|
| 67 | }
|
---|