Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs @ 8728

Last change on this file since 8728 was 8545, checked in by fschoepp, 12 years ago

#1888:

  • Controller is now capable of gathering Hive Jobs
  • Hive Jobs will be mapped to independent Job-Class (shared between Controller and Frontend)
  • HiveScenarioManager is capable of gathering Hive Jobs + their results
  • Job Results will be mapped to string properties
  • Frontend renders all Results after opening the job details
  • Misc: Frontend now passes User-object to Controller so that it is able to connect to the Hive Service (hardcoded values removed)
File size: 5.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.ServiceModel;
6using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
7
8namespace HeuristicLab.Services.Optimization.ControllerService {
9  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)]
10  public class PlaceholderControllerService : IControllerService {
11   
12    private IList<Model.OptimizationScenario> scenarios;
13
14    private IScenarioManager hiveManager;
15
16    public PlaceholderControllerService() {
17      var tsp = new Model.OptimizationScenario() { Name = "Traveling Salesman Problem" };
18      hiveManager = new HiveScenarioManager();
19      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Decimal, Value = new Model.DecimalValue() { Name = "BestKnownQuality", Value = 6110.0d } });
20      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.DecimalVector
21      ,Value =
22        new Model.DecimalVector() {
23          Name = "BestKnownSolution",
24          Value = new double[]{
25            0,40,38//,116,111,114,27,61,104,127,15,44,4,10,75,108,60,128,123,63,68,85,87,25,6,96,69,106,126,103,42,33,16,30,26,18,99,14,28,23,115,94,78,86,11,80,102,76,93,88,109,97,67,62,47,24,112,31,35,83,118,110,122,100,81,56,8,55,64,51,74,73,98,72,91,37,105,52,119,57,48,71,90,5,101,9,13,66,12,95,121,54,59,50,41,43,92,36,21,46,39,22,32,20,125,120,77,65,84,124,89,58,29,82,2,113,107,7,17,45,79,117,19,3,34,53,1,49,129,70
26      }}});
27      tsp.InputParameters.Items.Add(new Model.Parameter() {       
28        Type = Model.ParameterType.DecimalMatrix,
29        Value =
30          new Model.DecimalMatrix() {
31            Name = "Coordinates",
32            Value = Utility.ToJagged(new double[,] { { 334.5909245845, 161.7809319139 }, { 334.5909245845, 161.7809319139 }, { 503.8741827107, 172.8741151168 } })
33          }
34      });
35      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "EvaluatorParameter", Value = "HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator", Options = new string[] { "HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator", "HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator", "HeuristicLab.Problems.TravelingSalesman.TSPEuclideanPathEvaluator" } } });
36      //tsp.InputParameters.Add(new Model.Parameter() { Name = "SolutionCreator" });
37      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Boolean, Value = new Model.BoolValue() { Name = "UseDistanceMatrix", Value = true } });
38
39      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "CrossoverParameter", Value = "OrderCrossover2", Options = new string[] { "OrderCrossover2", "CosaCrossover" } } });
40      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "Elites", Value = 1 } });
41      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "MaximumGenerations", Value = 1000 } });//, Value = 1000});
42      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Percent, Value = new Model.DecimalValue() { Name = "MutationProbability", Value = 5 } });//, Value = 5});
43      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "Mutator", Value = "InversionManipulator", Options = new string[] { "InversionManipulator", "ScrambleManipulator" } } });
44      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "PopulationSize", Value = 100 } });//, Value = 100 });
45      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "Seed", Value = 100 } });//, Value = 100 });
46      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "Selector", Value = "ProportionalSelector", Options = new string[] { "ProportionalSelector", "BestSelector" } } });
47      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Boolean, Value = new Model.BoolValue() { Name = "SetSeedRandomly", Value = true } });//, Value = true });
48      this.scenarios = new List<Model.OptimizationScenario>() { tsp };
49      //hiveManager.DispatchScenario(tsp);
50    }
51
52    public IEnumerable<Model.OptimizationScenario> GetOptimizationScenarios() {
53      return scenarios; 
54    }
55
56
57    public Model.OptimizationScenario GetOptimizationScenarioByName(string name) {
58      if (scenarios[0].Name == name)
59        return scenarios[0];
60      return null;
61    }
62
63    public void ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario) {
64      hiveManager.DispatchScenario(user, scenario);
65    }
66
67    public IEnumerable<Model.Job> GetJobs(Model.User user) {
68      return hiveManager.GetJobs(user);
69    }
70
71
72    public Model.Job GetJob(Model.User user, string id) {
73      return hiveManager.GetJob(user, id);
74    }
75
76
77    public void DeleteJob(Model.User user, string id) {
78      hiveManager.DeleteJob(user, id);
79    }
80
81
82    public IList<Model.Run> GetJobResults(Model.User user, string id) {
83      return hiveManager.GetJobResults(user, id);
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.