Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs @ 17530

Last change on this file since 17530 was 17519, checked in by dpiringe, 5 years ago

#3026:

  • added error output for failed runner initialization
  • reorganised some final view models
  • TargetedJsonItemType (in JsonItemVMBase) now automatically returns the type of the defined JsonItem
  • code cleanup
  • refactored RegressionProblemDataConverter
  • added lots of comments
  • added new view for StringArrayJsonItem
  • added new UI component for concrete restricted items and used it in JsonItemConcreteItemArrayControl and JsonItemValidValuesControl
File size: 2.6 KB
RevLine 
[17371]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.PluginInfrastructure;
7using HeuristicLab.JsonInterface.App;
8using HeuristicLab.Algorithms.GeneticAlgorithm;
9using HeuristicLab.Problems.TravelingSalesman;
10using HeuristicLab.JsonInterface;
11using System.IO;
12using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
13using HeuristicLab.PluginInfrastructure.Manager;
[17374]14using HeuristicLab.SequentialEngine;
15using System.Threading;
[17371]16
17namespace Heuristiclab.ConfigStarter {
18  public class Program {
[17374]19
[17371]20    public static void Main(string[] args) {
21
22      try {
23        string pluginPath = Path.GetFullPath(Directory.GetCurrentDirectory());
24        var pluginManager = new PluginManager(pluginPath);
25        pluginManager.DiscoverAndCheckPlugins();
26      } catch(Exception e) {
27        Console.WriteLine(e);
28      }
29
30      HEAL.Attic.Mapper.StaticCache.UpdateRegisteredTypes();
31
[17519]32     
[17371]33      HeuristicLabJsonInterfaceAppApplication app = new HeuristicLabJsonInterfaceAppApplication();
34
35      GeneticAlgorithm alg = new GeneticAlgorithm();
[17374]36      alg.MaximumGenerations.Value = 10000;
[17371]37      TravelingSalesmanProblem tsp = new TravelingSalesmanProblem();
38      tsp.Coordinates[0, 0] = 123;
39
40
[17374]41
[17371]42      SymbolicRegressionSingleObjectiveProblem prop = new SymbolicRegressionSingleObjectiveProblem();
43     
[17451]44      alg.Problem = prop;
[17371]45
[17451]46      IJsonItem root = JsonItemConverter.Extract(alg);
[17473]47      ActivateJsonItems(root);
[17451]48
[17439]49     
[17519]50      JCGenerator.GenerateTemplate(@"C:\Workspace\ConfigStarter\", "Template", alg, root);
51     
52
[17371]53      List<ICommandLineArgument> arguments = new List<ICommandLineArgument>();
54      arguments.Add(new StartArgument("JsonInterface"));
[17519]55      arguments.Add(new OpenArgument(@"C:\Workspace\ConfigStarter\Template.json"));
56      arguments.Add(new OpenArgument(@"C:\Workspace\ConfigStarter\Config.json"));
57      arguments.Add(new StringArgument(@"C:\Workspace\ConfigStarter\Output.json"));
[17371]58
59      app.Run(arguments.ToArray());
[17439]60     
[17371]61    }
[17473]62
63    private static void ActivateJsonItems(IJsonItem item) {
[17477]64      foreach (var x in item) {
65        x.Active = true;
66        if (x is ValueLookupJsonItem i) {
67          i.Active = true;
68        }
[17519]69        /*
70        if(x.Name == "Dataset" && x is DoubleMatrixJsonItem mat) {
71          mat.Value = new double[5][];
72          mat.RowNames = new string[] { "R1", "R2", "R3" };
73          for(int j = 0; j < 5; ++j) {
74            mat.Value[j] = new double[10];
75          }
76        }*/
[17473]77      }
78    }
[17371]79  }
80}
Note: See TracBrowser for help on using the repository browser.