- Timestamp:
- 08/20/12 13:00:30 (12 years ago)
- Location:
- branches/OaaS/HeuristicLab.Services.Optimization.Controller
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj
r8384 r8506 32 32 </PropertyGroup> 33 33 <ItemGroup> 34 <Reference Include="ALGLIB-3.5.0, Version=3.5.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 35 <SpecificVersion>False</SpecificVersion> 36 <HintPath>..\bin\ALGLIB-3.5.0.dll</HintPath> 37 </Reference> 38 <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3"> 39 <HintPath>..\bin\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath> 40 </Reference> 41 <Reference Include="HeuristicLab.Clients.Hive-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 42 <SpecificVersion>False</SpecificVersion> 43 <HintPath>..\bin\HeuristicLab.Clients.Hive-3.3.dll</HintPath> 44 </Reference> 45 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 46 <SpecificVersion>False</SpecificVersion> 47 <HintPath>..\bin\HeuristicLab.Collections-3.3.dll</HintPath> 48 </Reference> 49 <Reference Include="HeuristicLab.Common-3.3"> 50 <HintPath>..\bin\HeuristicLab.Common-3.3.dll</HintPath> 51 </Reference> 52 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 53 <SpecificVersion>False</SpecificVersion> 54 <HintPath>..\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath> 55 </Reference> 56 <Reference Include="HeuristicLab.Core-3.3"> 57 <HintPath>..\bin\HeuristicLab.Core-3.3.dll</HintPath> 58 </Reference> 59 <Reference Include="HeuristicLab.Data-3.3"> 60 <HintPath>..\bin\HeuristicLab.Data-3.3.dll</HintPath> 61 </Reference> 62 <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3"> 63 <HintPath>..\bin\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath> 64 </Reference> 65 <Reference Include="HeuristicLab.Encodings.IntegerVectorEncoding-3.3"> 66 <HintPath>..\bin\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.dll</HintPath> 67 </Reference> 68 <Reference Include="HeuristicLab.Encodings.PermutationEncoding-3.3"> 69 <HintPath>..\bin\HeuristicLab.Encodings.PermutationEncoding-3.3.dll</HintPath> 70 </Reference> 71 <Reference Include="HeuristicLab.Encodings.PermutationEncoding.Views-3.3"> 72 <HintPath>..\bin\HeuristicLab.Encodings.PermutationEncoding.Views-3.3.dll</HintPath> 73 </Reference> 74 <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3"> 75 <HintPath>..\bin\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath> 76 </Reference> 77 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4"> 78 <HintPath>..\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath> 79 </Reference> 80 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4"> 81 <HintPath>..\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.dll</HintPath> 82 </Reference> 83 <Reference Include="HeuristicLab.Hive-3.3"> 84 <HintPath>..\bin\HeuristicLab.Hive-3.3.dll</HintPath> 85 </Reference> 86 <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 87 <SpecificVersion>False</SpecificVersion> 88 <HintPath>..\bin\HeuristicLab.Operators-3.3.dll</HintPath> 89 </Reference> 90 <Reference Include="HeuristicLab.Optimization-3.3"> 91 <HintPath>..\HeuristicLab.Optimization\3.3\obj\Debug\HeuristicLab.Optimization-3.3.dll</HintPath> 92 </Reference> 93 <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 94 <SpecificVersion>False</SpecificVersion> 95 <HintPath>..\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath> 96 </Reference> 97 <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 98 <SpecificVersion>False</SpecificVersion> 99 <HintPath>..\bin\HeuristicLab.Parameters-3.3.dll</HintPath> 100 </Reference> 101 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 102 <SpecificVersion>False</SpecificVersion> 103 <HintPath>..\bin\HeuristicLab.Persistence-3.3.dll</HintPath> 104 </Reference> 105 <Reference Include="HeuristicLab.Problems.Instances-3.3"> 106 <HintPath>..\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath> 107 </Reference> 108 <Reference Include="HeuristicLab.Problems.TravelingSalesman-3.3"> 109 <HintPath>..\bin\HeuristicLab.Problems.TravelingSalesman-3.3.dll</HintPath> 110 </Reference> 111 <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 112 <SpecificVersion>False</SpecificVersion> 113 <HintPath>..\bin\HeuristicLab.Random-3.3.dll</HintPath> 114 </Reference> 115 <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 116 <SpecificVersion>False</SpecificVersion> 117 <HintPath>..\bin\HeuristicLab.Selection-3.3.dll</HintPath> 118 </Reference> 119 <Reference Include="HeuristicLab.Tracing-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 120 <SpecificVersion>False</SpecificVersion> 121 <HintPath>..\bin\HeuristicLab.Tracing-3.3.dll</HintPath> 122 </Reference> 34 123 <Reference Include="System" /> 35 124 <Reference Include="System.Core" /> … … 43 132 </ItemGroup> 44 133 <ItemGroup> 134 <Compile Include="HiveScenarioManager.cs" /> 45 135 <Compile Include="Interfaces\IControllerService.cs" /> 136 <Compile Include="Interfaces\IScenarioManager.cs" /> 46 137 <Compile Include="Model\ControllerModel.cs" /> 47 138 <Compile Include="PlaceholderControllerService.cs" /> 48 139 <Compile Include="Properties\AssemblyInfo.cs" /> 140 <Compile Include="Utility.cs" /> 141 </ItemGroup> 142 <ItemGroup> 143 <WCFMetadata Include="Service References\" /> 49 144 </ItemGroup> 50 145 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs
r8384 r8506 15 15 [OperationContract] 16 16 OptimizationScenario GetOptimizationScenarioByName(string name); 17 18 [OperationContract] 19 void ScheduleOptimizationScenario(OptimizationScenario scenario); 17 20 } 18 21 } -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Model/ControllerModel.cs
r8384 r8506 4 4 using System.Text; 5 5 using System.Runtime.Serialization; 6 using System.Globalization; 7 using System.Xml; 6 8 7 9 namespace HeuristicLab.Services.Optimization.ControllerService.Model { … … 25 27 26 28 [DataContract] 27 public abstract class Value { 29 public abstract class Value { 30 [DataMember] 31 public string Name { get; set; } 32 33 public abstract bool TrySetFromString(string input); 34 } 35 36 37 [DataContract] 38 public class DecimalMatrix : Value { 39 [DataMember] 40 public double[][] Value { get; set; } 41 42 public override bool TrySetFromString(string input) { 43 var splitted = input.Split(':'); 44 int i, j; 45 if (splitted.Length != 3) 46 return false; 47 48 if (!int.TryParse(splitted[0], out i)) 49 return false; 50 51 if (!int.TryParse(splitted[1], out j)) 52 return false; 53 54 double value; 55 if (!double.TryParse(splitted[2], out value)) 56 return false; 57 // very, very buggy 58 if (i >= Value.Length || j >= Value[0].Length ) { 59 double[][] valueArr = new double[i >= Value.GetLength(0) ? i : Value.GetLength(0)][]; 60 for (int k = 0; k < Value.Length; k++) { 61 valueArr[k] = new double[j >= Value.GetLength(1) ? j : Value.GetLength(1)]; 62 for (int l = 0; l < Value[k].Length; l++) { 63 valueArr[k][l] = Value[k][l]; 64 } 65 } 66 Value = valueArr; 67 } 68 69 Value[i][j] = value; 70 return true; 71 } 72 } 73 74 [DataContract] 75 public class DecimalVector : Value { 76 [DataMember] 77 public double[] Value { get; set; } 78 79 public override bool TrySetFromString(string input) { 80 var splitted = input.Split(':'); 81 int index; 82 if (splitted.Length != 2) 83 return false; 84 85 if (!int.TryParse(splitted[0], out index)) 86 return false; 87 88 double value; 89 if (!double.TryParse(splitted[1], out value)) 90 return false; 91 92 if (index >= Value.Length) { 93 double[] valueArr = new double[index + 1]; 94 Array.Copy(Value, valueArr, Value.Length); 95 Value = valueArr; 96 } 97 98 Value[index] = value; 99 return true; 100 } 101 } 102 103 [DataContract] 104 public class TypeValue : Value { 105 [DataMember] 106 public string Value { get; set; } 107 108 [DataMember] 109 public string[] Options { get; set; } 110 111 public override bool TrySetFromString(string input) { 112 if (Options.Contains(input)) { 113 Value = input; 114 return true; 115 } 116 return false; 117 } 28 118 } 29 119 … … 32 122 [DataMember] 33 123 public double Value { get; set; } 124 125 public override bool TrySetFromString(string input) { 126 double result; 127 if (double.TryParse(input, out result)) { 128 Value = result; 129 return true; 130 } 131 return false; 132 } 34 133 } 35 134 … … 38 137 [DataMember] 39 138 public bool Value { get; set; } 139 140 public override bool TrySetFromString(string input) { 141 bool result; 142 if (input.Contains(",")) 143 input = input.Split(',')[0].Trim(); 144 if (bool.TryParse(input, out result)) { 145 Value = result; 146 return true; 147 } 148 return false; 149 } 40 150 } 41 151 … … 43 153 [KnownType(typeof(BoolValue))] 44 154 [KnownType(typeof(DecimalValue))] 45 public class Parameter {46 [DataMember]47 public string Name { get; set; }48 155 [KnownType(typeof(TypeValue))] 156 [KnownType(typeof(DecimalVector))] 157 [KnownType(typeof(DecimalMatrix))] 158 public class Parameter { 49 159 // some kind of value type 50 160 [DataMember] … … 52 162 53 163 [DataMember] 54 public Value Value { get; set; } 55 164 public Value Value { get; set; } 56 165 /* 57 166 //[DataMember] … … 60 169 61 170 [DataContract] 171 public class InputParameters { 172 private IList<Parameter> items = new List<Parameter>(); 173 174 [DataMember] 175 public IList<Parameter> Items { 176 get { return items; } 177 set { items = value; } 178 } 179 } 180 181 [DataContract] 182 public class AlgorithmParameters { 183 private IList<Parameter> items = new List<Parameter>(); 184 185 [DataMember] 186 public IList<Parameter> Items { 187 get { return items; } 188 set { items = value; } 189 } 190 } 191 192 [DataContract] 62 193 public class OptimizationScenario { 63 194 [DataMember] 64 195 public string Name { get; set; } 65 196 66 private IList<Parameter> inputParameters = new List<Parameter>(); 67 68 [DataMember] 69 public IList<Parameter> InputParameters { 70 get { return inputParameters; } 71 set { inputParameters = value; } 72 } 73 74 private IList<Parameter> algorithmParameters = new List<Parameter>(); 75 76 [DataMember] 77 public IList<Parameter> AlgorithmParameters { 197 private InputParameters inputParams = new InputParameters(); 198 199 [DataMember] 200 public InputParameters InputParameters { 201 get { return inputParams; } 202 set { inputParams = value; } 203 } 204 205 206 private AlgorithmParameters algorithmParameters = new AlgorithmParameters(); 207 208 [DataMember] 209 public AlgorithmParameters AlgorithmParameters { 78 210 get { return algorithmParameters; } 79 211 set { algorithmParameters = value; } 80 212 } 213 81 214 } 82 215 } -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs
r8384 r8506 4 4 using System.Text; 5 5 using System.ServiceModel; 6 using HeuristicLab.Services.Optimization.ControllerService.Interfaces; 6 7 7 8 namespace HeuristicLab.Services.Optimization.ControllerService { … … 11 12 private IList<Model.OptimizationScenario> scenarios; 12 13 14 private IScenarioManager hiveManager; 15 13 16 public PlaceholderControllerService() { 14 var tsp = new Model.OptimizationScenario() { Name = "Travelling Salesman Problem" }; 15 tsp.InputParameters.Add(new Model.Parameter() { Name = "BestKnownQuality", Type = Model.ParameterType.Decimal, Value = new Model.DecimalValue() { Value = 6110.0d } }); 16 tsp.InputParameters.Add(new Model.Parameter() { Name = "BestKnownSolution", Type = Model.ParameterType.DecimalMatrix }); //, Value = 17 //new double[]{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}}); 18 tsp.InputParameters.Add(new Model.Parameter() { Name = "Coordinates", Type = Model.ParameterType.DecimalMatrix }); //, Value = 19 //new double[,]{{334.5909245845, 161.7809319139},{334.5909245845, 161.7809319139},{503.8741827107,172.8741151168}}}); 20 tsp.InputParameters.Add(new Model.Parameter() { Name = "Evaluator", Type = Model.ParameterType.Type });//, Value = "TSPRoundedEuclideanPathEvaluator", Choices = new string[]{ "TSPRoundedEuclideanPathEvaluator", "TSPGeoPathEvaluator", "TSPEuclideanPathEvaluator" } }); 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" } } }); 21 36 //tsp.InputParameters.Add(new Model.Parameter() { Name = "SolutionCreator" }); 22 tsp.InputParameters. Add(new Model.Parameter() { Name = "UseDistanceMatrix", Type = Model.ParameterType.Boolean});//, Value = true});37 tsp.InputParameters.Items.Add(new Model.Parameter() { Type = Model.ParameterType.Boolean, Value = new Model.BoolValue() { Name = "UseDistanceMatrix", Value = true } }); 23 38 24 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "Crossover", Type = Model.ParameterType.Type});//, Value = "OrderCrossover2", Choices = new string[] { "OrderCrossover2", "CosaCrossover"} });25 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "Elites", Type = Model.ParameterType.Integer});//, Value = 1});26 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "MaximumGenerations", Type = Model.ParameterType.Integer});//, Value = 1000});27 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "MutationProbability", Type = Model.ParameterType.Percent});//, Value = 5});28 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "Mutator", Type = Model.ParameterType.Type});//, Value = "InversionManipulator", Choices = new string[]{"InversionManipulator", "ScrambleManipulator"} });29 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "PopulationSize", Type = Model.ParameterType.Integer});//, Value = 100 });30 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "Seed", Type = Model.ParameterType.Integer});//, Value = 100 });31 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "Selector", Type = Model.ParameterType.Type });//, Value = "ProportionalSelector", Choices = new string[]{"ProportionalSelector", "BestSelector"} });32 tsp.AlgorithmParameters. Add(new Model.Parameter() { Name = "SetSeedRandomly", Type = Model.ParameterType.Boolean});//, Value = true });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 }); 33 48 this.scenarios = new List<Model.OptimizationScenario>() { tsp }; 49 //hiveManager.DispatchScenario(tsp); 34 50 } 35 51 … … 44 60 return null; 45 61 } 62 63 public void ScheduleOptimizationScenario(Model.OptimizationScenario scenario) { 64 hiveManager.DispatchScenario(scenario); 65 } 66 67 46 68 } 47 69 }
Note: See TracChangeset
for help on using the changeset viewer.