Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9173 was 9166, checked in by fschoepp, 12 years ago

#1888:

  • Model: OptimizationScenario may be a tree of algorithms (and problems)
  • Model: Renamed InputParameters to ProblemParameters (as they are the parameters of a problem)
  • Model: Added JobExecutionDetails which contain Repetitions + Group (resource to use)
  • ScenarioParser parses the new XML scenario files
  • Website + Model: You are now able to add/remove rows from a table (no JavaScript involved yet)
  • Website + Controller: Added repetitions (enables batch jobs) and group (resource to use) to OaaS which will be used by the controller to schedule the job
  • Website: Updated templates to use new model structure
  • Website + Scenarios: Added the new algorithm Benchmark Algorithm
  • Controller: Added a singleton to make the (Azure/Mockup)-DAL exchangeable
  • Controller: Added mockup classes for DAL + IScenarioManager
  • Website/Result Page: Line Diagrams will be added via JavaScript, crawling their data using AJAX
  • Website: Most configuration parameters can be set in the ServiceDefinition directly
  • Added a mockup for the Membership classes: These can be used if no network connection is available or if other parts of the app shall be tested
  • Scenarios: Updated TSP mappings to new xsd
File size: 6.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.ServiceModel;
6using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
7using HeuristicLab.Services.Optimization.ControllerService.Model;
8
9namespace HeuristicLab.Services.Optimization.ControllerService {
10  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)]
11  public class PlaceholderControllerService : IControllerService {
12   
13    private IList<Model.OptimizationScenario> scenarios;
14
15    private ScenarioParser parser = new ScenarioParser();
16
17    private IScenarioManager hiveManager;
18
19    public PlaceholderControllerService() {
20      /*var tsp = new Model.OptimizationScenario() { Name = "Traveling Salesman Problem" };
21      hiveManager = new HiveScenarioManager();
22      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Decimal, Value = new Model.DecimalValue() { Name = "BestKnownQuality", Value = 6110.0d } });
23      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.DecimalVector
24      ,Value =
25        new Model.DecimalVector() {
26          Name = "BestKnownSolution",
27          Value = new double[]{
28            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
29      }}});
30      tsp.InputParameters.Items.Add(new Model.Parameter() {       
31        Type = Model.ParameterType.DecimalMatrix,
32        Value =
33          new Model.DecimalMatrix() {
34            Name = "Coordinates",
35            Value = Utility.ToJagged(new double[,] { { 334.5909245845, 161.7809319139 }, { 334.5909245845, 161.7809319139 }, { 503.8741827107, 172.8741151168 } })
36          }
37      });
38      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" } } });
39      //tsp.InputParameters.Add(new Model.Parameter() { Name = "SolutionCreator" });
40      tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Boolean, Value = new Model.BoolValue() { Name = "UseDistanceMatrix", Value = true } });
41
42      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "CrossoverParameter", Value = "OrderCrossover2", Options = new string[] { "OrderCrossover2", "CosaCrossover" } } });
43      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "Elites", Value = 1 } });
44      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "MaximumGenerations", Value = 1000 } });//, Value = 1000});
45      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Percent, Value = new Model.DecimalValue() { Name = "MutationProbability", Value = 5 } });//, Value = 5});
46      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "Mutator", Value = "InversionManipulator", Options = new string[] { "InversionManipulator", "ScrambleManipulator" } } });
47      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "PopulationSize", Value = 100 } });//, Value = 100 });
48      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Integer, Value = new Model.DecimalValue() { Name = "Seed", Value = 100 } });//, Value = 100 });
49      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Type, Value = new Model.TypeValue() { Name = "Selector", Value = "ProportionalSelector", Options = new string[] { "ProportionalSelector", "BestSelector" } } });
50      tsp.AlgorithmParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Boolean, Value = new Model.BoolValue() { Name = "SetSeedRandomly", Value = true } });//, Value = true });
51      this.scenarios = new List<Model.OptimizationScenario>() { tsp };*/     
52      //hiveManager.DispatchScenario(tsp);
53      //hiveManager = new MockupScenarioManager();
54      hiveManager = new HiveScenarioManager();
55      scenarios = parser.Scenarios;
56      //hiveManager.DispatchScenario(new User() { Username = "fschoeppl", Password = "fschoeppl" }, scenarios[0]);
57    }
58
59    public IEnumerable<Model.OptimizationScenario> GetOptimizationScenarios() {
60      return scenarios; 
61    }
62
63
64    public Model.OptimizationScenario GetOptimizationScenarioByName(string name) {
65      var scen = (from e in scenarios
66                  where e.Id == name
67                  select e).FirstOrDefault();     
68      return scen;
69    }
70
71    public void ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
72      hiveManager.DispatchScenario(user, scenario, details);
73    }
74
75    public IEnumerable<Model.Job> GetJobs(Model.User user) {
76      return hiveManager.GetJobs(user);
77    }
78
79
80    public Model.Job GetJob(Model.User user, string id) {
81      return hiveManager.GetJob(user, id);
82    }
83
84
85    public void DeleteJob(Model.User user, string id) {
86      hiveManager.DeleteJob(user, id);
87    }
88
89
90    public IList<Model.Run> GetJobResults(Model.User user, string id) {
91      return hiveManager.GetJobResults(user, id);
92    }
93
94
95    public bool AddHiveScenario(User user, string scenarioXml, string scenarioMapper) {
96      var scenario = parser.ParseScenarioFromXml(scenarioXml);
97      if (scenario == null) {
98        return false;
99      }     
100      var added = hiveManager.AddScenario(user, scenario.Id, scenarioXml, scenarioMapper);
101      if (added)
102        scenarios.Add(scenario);
103      return added;
104    }
105
106    public bool DeleteHiveScenario(User user, string scenarioName) {
107      var scen = GetOptimizationScenarioByName(scenarioName);
108      if (scen != null) {
109        scenarios.Remove(scen);
110        return hiveManager.DeleteScenario(user, scenarioName);
111      }
112      return false;
113    }
114
115    public IEnumerable<string> GetOptimizationScenarioNames() {
116      return (from e in scenarios
117              select e.Id).AsEnumerable();     
118    }
119  }
120}
Note: See TracBrowser for help on using the repository browser.