Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Test/Program.cs @ 6000

Last change on this file since 6000 was 6000, checked in by cneumuel, 13 years ago

#1233

  • added GetPlugin service method
  • fixed minor issues with double plugins in database
  • worked on HiveEngine
  • fixed wrong role name for Hive User
  • fixed bug in group assignment of slaves
File size: 2.3 KB
Line 
1using System;
2using System.IO;
3using System.Linq;
4using System.Reflection;
5using System.Threading;
6using HeuristicLab.Algorithms.GeneticAlgorithm;
7using HeuristicLab.Clients.Hive;
8using HeuristicLab.Common;
9using HeuristicLab.Core;
10using HeuristicLab.PluginInfrastructure;
11using HeuristicLab.PluginInfrastructure.Manager;
12using HeuristicLab.Problems.TestFunctions;
13
14namespace HeuristicLab.HiveEngine.Test {
15  public class Program {
16    static void Main(string[] args) {
17      PluginManager pm = new PluginManager(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
18      pm.DiscoverAndCheckPlugins();
19      pm.Run(pm.Applications.Where(x => x.Name == "HeuristicLab.HiveEngine.Test").SingleOrDefault());
20    }
21  }
22
23  [Plugin("HeuristicLab.HiveEngine.Test", "1.0.0.0")]
24  [PluginFile("HeuristicLab.HiveEngine.Test.exe", PluginFileType.Assembly)]
25  public class TestPlugin : PluginBase { }
26
27  [Application("HeuristicLab.HiveEngine.Test")]
28  public class TestApp : ApplicationBase {
29
30    public override void Run() {
31      ContentManager.Initialize(new PersistenceContentManager());
32
33      #region Credentials
34      ServiceLocator.Instance.Username = "cneumuel";
35      ServiceLocator.Instance.Password = "Stormlord105.";
36      #endregion
37
38      GeneticAlgorithm ga = new GeneticAlgorithm();
39      ga.Problem = new SingleObjectiveTestFunctionProblem();
40      ga.Engine = new HiveEngine();     
41      ga.PopulationSize.Value = 3;
42      ga.MaximumGenerations.Value = 3;
43
44      ga.Start();
45
46      while (ga.ExecutionState != Core.ExecutionState.Stopped && ga.ExecutionState != Core.ExecutionState.Paused) {
47        Thread.Sleep(2000);
48        Console.Clear();
49        Console.WriteLine(string.Join(Environment.NewLine, ga.Results.Select(x => x.ToString()).ToArray()));
50        Console.WriteLine("---");
51        Console.WriteLine("Log:");
52        Console.WriteLine(string.Join(Environment.NewLine, ga.Engine.Log.Messages.ToArray()));
53      }
54      Console.WriteLine("finished: " + ga.ExecutionState);
55
56      Console.WriteLine("Storing...");
57      ContentManager.Save((IStorableContent)ga, string.Format("result_{0}.hl", DateTime.Now.ToString("yy.MM.dd HH;mm;ss")), true);
58      Console.WriteLine("Finished");
59
60      Console.ReadLine();
61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.