[8384] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.ServiceModel;
|
---|
[8506] | 6 | using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
|
---|
[8817] | 7 | using HeuristicLab.Services.Optimization.ControllerService.Model;
|
---|
[8384] | 8 |
|
---|
| 9 | namespace HeuristicLab.Services.Optimization.ControllerService {
|
---|
| 10 | [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)]
|
---|
| 11 | public class PlaceholderControllerService : IControllerService {
|
---|
| 12 |
|
---|
| 13 | private IList<Model.OptimizationScenario> scenarios;
|
---|
| 14 |
|
---|
[8817] | 15 | private ScenarioParser parser = new ScenarioParser();
|
---|
| 16 |
|
---|
[8506] | 17 | private IScenarioManager hiveManager;
|
---|
| 18 |
|
---|
[8384] | 19 | public PlaceholderControllerService() {
|
---|
[8817] | 20 | /*var tsp = new Model.OptimizationScenario() { Name = "Traveling Salesman Problem" };
|
---|
[8506] | 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" } } });
|
---|
[8384] | 39 | //tsp.InputParameters.Add(new Model.Parameter() { Name = "SolutionCreator" });
|
---|
[8506] | 40 | tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Boolean, Value = new Model.BoolValue() { Name = "UseDistanceMatrix", Value = true } });
|
---|
[8384] | 41 |
|
---|
[8506] | 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 });
|
---|
[8817] | 51 | this.scenarios = new List<Model.OptimizationScenario>() { tsp };*/
|
---|
[8506] | 52 | //hiveManager.DispatchScenario(tsp);
|
---|
[8817] | 53 | hiveManager = new HiveScenarioManager();
|
---|
| 54 | scenarios = parser.Scenarios;
|
---|
| 55 | //hiveManager.DispatchScenario(new User() { Username = "fschoeppl", Password = "fschoeppl" }, scenarios[0]);
|
---|
[8384] | 56 | }
|
---|
| 57 |
|
---|
| 58 | public IEnumerable<Model.OptimizationScenario> GetOptimizationScenarios() {
|
---|
| 59 | return scenarios;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | public Model.OptimizationScenario GetOptimizationScenarioByName(string name) {
|
---|
| 64 | if (scenarios[0].Name == name)
|
---|
| 65 | return scenarios[0];
|
---|
| 66 | return null;
|
---|
| 67 | }
|
---|
[8506] | 68 |
|
---|
[8545] | 69 | public void ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario) {
|
---|
| 70 | hiveManager.DispatchScenario(user, scenario);
|
---|
[8506] | 71 | }
|
---|
| 72 |
|
---|
[8545] | 73 | public IEnumerable<Model.Job> GetJobs(Model.User user) {
|
---|
| 74 | return hiveManager.GetJobs(user);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | public Model.Job GetJob(Model.User user, string id) {
|
---|
| 79 | return hiveManager.GetJob(user, id);
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | public void DeleteJob(Model.User user, string id) {
|
---|
| 84 | hiveManager.DeleteJob(user, id);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | public IList<Model.Run> GetJobResults(Model.User user, string id) {
|
---|
| 89 | return hiveManager.GetJobResults(user, id);
|
---|
| 90 | }
|
---|
[8384] | 91 | }
|
---|
| 92 | }
|
---|