Changeset 5212 for branches/HeuristicLab.MetaOptimization
- Timestamp:
- 01/05/11 02:03:20 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/HeuristicLab.MetaOptimization.Test.csproj
r5207 r5212 116 116 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Data.Views-3.3.dll</HintPath> 117 117 </Reference> 118 <Reference Include="HeuristicLab.DataAccess-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 119 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.DataAccess-3.3.dll</HintPath> 120 </Reference> 118 121 <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3"> 119 122 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath> … … 136 139 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.3"> 137 140 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.3.dll</HintPath> 141 </Reference> 142 <Reference Include="HeuristicLab.Hive.Contracts-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 143 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Contracts-3.3.dll</HintPath> 144 </Reference> 145 <Reference Include="HeuristicLab.Hive.ExperimentManager-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 146 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.ExperimentManager-3.3.dll</HintPath> 147 </Reference> 148 <Reference Include="HeuristicLab.Hive.ExperimentManager.Views-3.3"> 149 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.ExperimentManager.Views-3.3.dll</HintPath> 150 </Reference> 151 <Reference Include="HeuristicLab.Hive.JobBase-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 152 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.JobBase-3.3.dll</HintPath> 153 </Reference> 154 <Reference Include="HeuristicLab.Hive.Server.Console-3.3"> 155 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.Console-3.3.dll</HintPath> 156 </Reference> 157 <Reference Include="HeuristicLab.Hive.Server.Core-3.3"> 158 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.Core-3.3.dll</HintPath> 159 </Reference> 160 <Reference Include="HeuristicLab.Hive.Server.DataAccess-3.3"> 161 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.DataAccess-3.3.dll</HintPath> 162 </Reference> 163 <Reference Include="HeuristicLab.Hive.Server.LINQDataAccess-3.3"> 164 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Server.LINQDataAccess-3.3.dll</HintPath> 165 </Reference> 166 <Reference Include="HeuristicLab.Hive.Slave.Common-3.3"> 167 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Common-3.3.dll</HintPath> 168 </Reference> 169 <Reference Include="HeuristicLab.Hive.Slave.Communication-3.3"> 170 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Communication-3.3.dll</HintPath> 171 </Reference> 172 <Reference Include="HeuristicLab.Hive.Slave.Console-3.3"> 173 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Console-3.3.dll</HintPath> 174 </Reference> 175 <Reference Include="HeuristicLab.Hive.Slave.Core-3.3"> 176 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.Core-3.3.dll</HintPath> 177 </Reference> 178 <Reference Include="HeuristicLab.Hive.Slave.ExecutionEngine-3.3"> 179 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Slave.ExecutionEngine-3.3.dll</HintPath> 180 </Reference> 181 <Reference Include="HeuristicLab.Hive.Tracing-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 182 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Hive.Tracing-3.3.dll</HintPath> 183 </Reference> 184 <Reference Include="HeuristicLab.HiveEngine-3.3"> 185 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.HiveEngine-3.3.dll</HintPath> 138 186 </Reference> 139 187 <Reference Include="HeuristicLab.LibSVM-1.6.3"> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
r5207 r5212 21 21 using System.Diagnostics; 22 22 using HeuristicLab.Encodings.RealVectorEncoding; 23 using HeuristicLab.Hive.ExperimentManager; 23 24 24 25 namespace HeuristicLab.MetaOptimization.Test { 25 26 class Program { 26 private static int metaAlgorithmPopulationSize = 50;27 private static int metaAlgorithmMaxGenerations = 30;28 private static int metaProblemRepetitions = 5;29 private static int baseAlgorithmMaxGenerations = 1000;30 31 //private static int metaAlgorithmPopulationSize = 10;32 //private static int metaAlgorithmMaxGenerations = 20;33 //private static int metaProblemRepetitions = 3;34 //private static int baseAlgorithmMaxGenerations = 10;27 //private static int metaAlgorithmPopulationSize = 50; 28 //private static int metaAlgorithmMaxGenerations = 30; 29 //private static int metaProblemRepetitions = 5; 30 //private static int baseAlgorithmMaxGenerations = 1000; 31 32 private static int metaAlgorithmPopulationSize = 10; 33 private static int metaAlgorithmMaxGenerations = 20; 34 private static int metaProblemRepetitions = 3; 35 private static int baseAlgorithmMaxGenerations = 10; 35 36 36 37 static void Main(string[] args) { … … 53 54 MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem(); 54 55 metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions); 55 //GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem); 56 GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem); 56 GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem); 57 //GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem); 58 //GeneticAlgorithm metaLevelAlgorithm = GetHiveParallelMetaGA(metaOptimizationProblem); 59 57 60 //EvolutionStrategy metaLevelAlgorithm = GetMetaES(metaOptimizationProblem); 58 61 … … 304 307 private static GeneticAlgorithm GetParallelMetaGA(MetaOptimizationProblem metaOptimizationProblem) { 305 308 GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem); 306 307 UniformSubScopesProcessor uniformSubScopesProcessor =308 (HeuristicLab.Operators.UniformSubScopesProcessor)309 ((HeuristicLab.Operators.AlgorithmOperator)metaLevelAlgorithm.OperatorGraph.Operators.ElementAt(2)).OperatorGraph.Operators.ElementAt(8);310 uniformSubScopesProcessor.Parallel.Value = true;311 312 309 metaLevelAlgorithm.Engine = new ParallelEngine.ParallelEngine(); 313 310 return metaLevelAlgorithm; 311 } 312 313 private static GeneticAlgorithm GetHiveParallelMetaGA(MetaOptimizationProblem metaOptimizationProblem) { 314 GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem); 315 metaLevelAlgorithm.Engine = new HiveEngine.HiveEngine(); 316 ServiceLocator.Instance.ClientFacadePool.UserName = "cneumuel"; 317 ServiceLocator.Instance.ClientFacadePool.Password = "cneumuel"; 318 ServiceLocator.Instance.StreamedClientFacadePool.UserName = "cneumuel"; 319 ServiceLocator.Instance.StreamedClientFacadePool.Password = "cneumuel"; 314 320 return metaLevelAlgorithm; 315 321 } … … 337 343 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 338 344 Evaluator = new GriewankEvaluator(), 345 ProblemSize = new IntValue(5) 346 }); 347 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 348 Evaluator = new GriewankEvaluator(), 349 ProblemSize = new IntValue(50) 350 }); 351 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 352 Evaluator = new GriewankEvaluator(), 339 353 ProblemSize = new IntValue(500) 340 354 }); 341 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 342 // Evaluator = new GriewankEvaluator(), 343 // ProblemSize = new IntValue(1000) 344 //}); 345 346 ConfigurePopulationSize(algorithmVc, 0, 100, 1); 355 356 ConfigurePopulationSize(algorithmVc, 12, 100, 1); 347 357 ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01); 348 ConfigureMutationOperator(algorithmVc);358 //ConfigureMutationOperator(algorithmVc); 349 359 ConfigureElites(algorithmVc, 0, 10, 1); 350 ConfigureSelectionOperator(algorithmVc, true);360 //ConfigureSelectionOperator(algorithmVc, true); 351 361 return algorithmVc; 352 362 } … … 541 551 if (result.Name == "Population") { 542 552 RunCollection rc = (RunCollection)result.Value; 543 var orderedRuns = rc.OrderBy(x => x.Results[" RunsAverageQuality"]);544 545 TableBuilder tb = new TableBuilder(" AvgQual", "AvgET", "PoSi", "MutRa", "Eli", "SelOp", "MutOp", "NrSelSubScopes");553 var orderedRuns = rc.OrderBy(x => x.Results["AverageQualityNormalized"]); 554 555 TableBuilder tb = new TableBuilder("QNorm", "PoSi", "MutRa", "Eli", "SelOp", "MutOp", "NrSelSubScopes"); 546 556 foreach (IRun run in orderedRuns) { 547 557 string selector; … … 553 563 554 564 tb.AppendRow( 555 ((DoubleValue)run.Results["RunsAverageQuality"]).Value.ToString("#0.00"), 556 run.Results["RunsAverageExecutionTime"].ToString(), 565 ((DoubleValue)run.Results["AverageQualityNormalized"]).Value.ToString("#0.00"), 557 566 ((IntValue)run.Parameters["PopulationSize"]).Value.ToString(), 558 567 ((DoubleValue)run.Parameters["MutationProbability"]).Value.ToString("0.00"), … … 584 593 private static void metaLevelAlgorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) { 585 594 Console.WriteLine("metaLevelAlgorithm_ExceptionOccurred"); 595 Console.WriteLine(e.Value.ToString()); 596 if (e.Value.InnerException != null) { 597 Console.WriteLine(e.Value.InnerException.ToString()); 598 } 586 599 } 587 600 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/app.config
r5184 r5212 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 <runtime> 4 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 5 <dependentAssembly> 6 <assemblyIdentity name="HeuristicLab.Tracing-3.3" publicKeyToken="BA48961D6F65DCEC" culture="neutral"/> 7 <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0"/> 8 </dependentAssembly> 9 <dependentAssembly> 10 <assemblyIdentity name="HeuristicLab.Common.Resources-3.3" publicKeyToken="BA48961D6F65DCEC" culture="neutral"/> 11 <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0"/> 12 </dependentAssembly> 13 </assemblyBinding> 14 </runtime> 15 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> 3 <configSections> 4 </configSections> 5 6 <system.serviceModel> 7 8 <bindings> 9 <netTcpBinding> 10 <binding name="ClientTcpStreamedEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="314572800"> 11 <readerQuotas maxDepth="32" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600"/> 12 <reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="false"/> 13 <security mode="TransportWithMessageCredential"> 14 <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/> 15 <message clientCredentialType="UserName" algorithmSuite="Default"/> 16 </security> 17 </binding> 18 </netTcpBinding> 19 <wsHttpBinding> 20 <binding name="ClientHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="314572800" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 21 <readerQuotas maxDepth="32" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600"/> 22 <reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="false"/> 23 <security mode="Message"> 24 <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> 25 <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/> 26 </security> 27 </binding> 28 </wsHttpBinding> 29 </bindings> 30 <client> 31 <endpoint address="net.tcp://christoph:9001/Hive-3.3/ClientService.svc" binding="netTcpBinding" bindingConfiguration="ClientTcpStreamedEndpoint" contract="HeuristicLab.Hive.Contracts.Interfaces.IClientFacade" name="ClientTcpStreamedEndpoint"> 32 <identity> 33 <dns value="localhost"/> 34 </identity> 35 </endpoint> 36 <endpoint address="http://christoph/Hive-3.3/ClientService.svc" binding="wsHttpBinding" bindingConfiguration="ClientHttpEndpoint" contract="HeuristicLab.Hive.Contracts.Interfaces.IClientFacade" name="ClientHttpEndpoint"> 37 <identity> 38 <certificate encodedValue="AwAAAAEAAAAUAAAAozaKcSPdw1Cdd57hw9mr3eCjxTIgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhBhrVLVbjrtvUe4zWuGbVeuMAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMTAxMjA2NTYyNloXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFM6bQUgvCnsnBO9TZnOrC6x1riE2pXUzU6H38GYot674WNfir82fMh9+ojWSY/CiMzExcNWFtC3i8BG7giLYVwSanuwQ8QyRFYq3g5UMqdlm4/aof/4QMmS+SuRDsa8F4lbvdS9zBVFiyyUNYzlzO/rY08DrkCgx4X2IQGOvixwIDAQABo0kwRzBFBgNVHQEEPjA8gBCjMn9uvzNhU2c//E3RSYmUoRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghBhrVLVbjrtvUe4zWuGbVeuMAkGBSsOAwIdBQADgYEADIf8as2VBfZEpwb/GuVifvPTR0Ud+dTCwTjBdMymqjNR5NTSi408DifssSTBVGIi7xkWbQDlQQHOZmVqVFoqfNbGrtm9w1MSK24HAEMXr0WFBltvldGKCvtYnZqf377qU5gq7IBXcJZi87bZ2l1M3icr6RJo4fIbnZOa5M430aw="/> 39 </identity> 40 </endpoint> 41 </client> 42 43 </system.serviceModel> 44 </configuration> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/BestParameterConfigurationAnalyzer.cs
r5087 r5212 40 40 } 41 41 42 // stores the medians of the qualities of each problem 43 public LookupParameter<DoubleArray> ProblemQualityMediansParameter { 44 get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityMedians"]; } 45 } 46 public LookupParameter<ConstrainedItemList<ISingleObjectiveProblem>> ProblemsParameter { 47 get { return (LookupParameter<ConstrainedItemList<ISingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; } 48 } 49 42 50 public BestParameterConfigurationAnalyzer() 43 51 : base() { … … 49 57 Parameters.Add(new LookupParameter<IRun>("BestKnownSolution", "TODO The best known solution of this TSP instance.")); 50 58 Parameters.Add(new LookupParameter<RunCollection>("Population", "TODO The best known solution of this TSP instance.")); 59 Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityMedians", "")); 60 Parameters.Add(new LookupParameter<ConstrainedItemList<ISingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName)); 51 61 } 52 62 … … 65 75 66 76 int idxBest = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index; 67 68 77 69 78 ParameterConfigurationTree best = (ParameterConfigurationTree)parameterTrees[idxBest]; … … 87 96 88 97 // population 89 90 98 int i = 0; 91 99 RunCollection rc = new RunCollection(); 92 foreach (ParameterConfigurationTree pt in parameterTrees.OrderBy Descending(x => x.BestQuality.Value)) { // todo: respect Maximization:true/false100 foreach (ParameterConfigurationTree pt in parameterTrees.OrderBy(x => x.AverageQualityNormalized)) { // todo: respect Maximization:true/false 93 101 IRun run = new Run(); 94 102 run.Name = string.Format("Individuum ({0})", i); … … 106 114 } 107 115 116 // medians for the problems 117 DoubleArray medians = new DoubleArray(ProblemsParameter.ActualValue.Count); 118 for (int pi = 0; pi < ProblemsParameter.ActualValue.Count; pi++) { 119 double[] values = new double[rc.Count]; 120 for (int ri = 0; ri < rc.Count; ri++) { 121 values[ri] = ((DoubleArray)rc.ElementAt(ri).Results["RunsAverageQualities"])[pi]; 122 } 123 medians[pi] = values.Median(); 124 } 125 ProblemQualityMediansParameter.ActualValue = medians; 126 127 if (results.ContainsKey("ProblemsAverageQualityMedians")) { 128 results["ProblemsAverageQualityMedians"].Value = medians; 129 } else { 130 results.Add(new Result("ProblemsAverageQualityMedians", medians)); 131 } 132 108 133 return base.Apply(); 109 134 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurationTree.cs
r5207 r5212 14 14 [StorableClass] 15 15 public class ParameterConfigurationTree : ValueConfiguration, IEnumerable { 16 [Storable] 17 private DoubleValue bestQuality; 18 public DoubleValue BestQuality { 19 get { return bestQuality; } 16 17 [Storable] 18 private DoubleValue averageQualityNormalized; 19 public DoubleValue AverageQualityNormalized { 20 get { return averageQualityNormalized; } 20 21 set { 21 if (bestQuality != value) { 22 if (bestQuality != null) DeregisterQualityEvents(); 23 bestQuality = value; 24 if (bestQuality != null) RegisterQualityEvents(); 22 if (averageQualityNormalized != value) { 23 averageQualityNormalized = value; 25 24 OnQualityChanged(); 26 25 } … … 29 28 30 29 [Storable] 31 private DoubleValue averageQuality; 32 public DoubleValue AverageQuality { 33 get { return averageQuality; } 34 set { averageQuality = value; } 35 } 36 37 [Storable] 38 private DoubleValue worstQuality; 39 public DoubleValue WorstQuality { 40 get { return worstQuality; } 41 set { worstQuality = value; } 42 } 43 44 [Storable] 45 private DoubleValue qualityVariance; 46 public DoubleValue QualityVariance { 47 get { return qualityVariance; } 48 set { qualityVariance = value; } 49 } 50 51 [Storable] 52 private DoubleValue qualityStandardDeviation; 53 public DoubleValue QualityStandardDeviation { 54 get { return qualityStandardDeviation; } 55 set { qualityStandardDeviation = value; } 56 } 57 58 [Storable] 59 private TimeSpanValue averageExecutionTime; 60 public TimeSpanValue AverageExecutionTime { 61 get { return averageExecutionTime; } 62 set { averageExecutionTime = value; } 30 private DoubleArray qualitiesNormalized; 31 public DoubleArray QualitiesNormalized { 32 get { return qualitiesNormalized; } 33 set { 34 if (qualitiesNormalized != value) { 35 qualitiesNormalized = value; 36 } 37 } 38 } 39 40 [Storable] 41 private DoubleArray bestQualities; 42 public DoubleArray BestQualities { 43 get { return bestQualities; } 44 set { 45 if (bestQualities != value) { 46 bestQualities = value; 47 } 48 } 49 } 50 51 [Storable] 52 private DoubleArray averageQualities; 53 public DoubleArray AverageQualities { 54 get { return averageQualities; } 55 set { averageQualities = value; } 56 } 57 58 [Storable] 59 private DoubleArray worstQualities; 60 public DoubleArray WorstQualities { 61 get { return worstQualities; } 62 set { worstQualities = value; } 63 } 64 65 [Storable] 66 private DoubleArray qualityVariances; 67 public DoubleArray QualityVariances { 68 get { return qualityVariances; } 69 set { qualityVariances = value; } 70 } 71 72 [Storable] 73 private DoubleArray qualityStandardDeviations; 74 public DoubleArray QualityStandardDeviations { 75 get { return qualityStandardDeviations; } 76 set { qualityStandardDeviations = value; } 77 } 78 79 [Storable] 80 private ItemList<TimeSpanValue> averageExecutionTimes; 81 public ItemList<TimeSpanValue> AverageExecutionTimes { 82 get { return averageExecutionTimes; } 83 set { averageExecutionTimes = value; } 63 84 } 64 85 … … 88 109 : base(null, algorithm.GetType()) { 89 110 this.Optimize = true; // root must always be optimized 90 this.BestQuality = new DoubleValue();91 111 this.parameters = new Dictionary<string, IItem>(); 92 112 93 113 PopulateParameterConfigurations(algorithm); 94 Initialize();95 114 } 96 115 public ParameterConfigurationTree() { 97 Initialize();98 116 } 99 117 [StorableConstructor] … … 101 119 protected ParameterConfigurationTree(ParameterConfigurationTree original, Cloner cloner) 102 120 : base(original, cloner) { 103 this.bestQualit y = cloner.Clone(original.BestQuality);104 this.averageQualit y = cloner.Clone(original.averageQuality);105 this.worstQualit y = cloner.Clone(original.worstQuality);106 this.qualityStandardDeviation = cloner.Clone(original.qualityStandardDeviation);107 this.qualityVariance = cloner.Clone(original.qualityVariance);108 this.averageExecutionTime = cloner.Clone(original.averageExecutionTime);121 this.bestQualities = cloner.Clone(original.BestQualities); 122 this.averageQualities = cloner.Clone(original.averageQualities); 123 this.worstQualities = cloner.Clone(original.worstQualities); 124 this.qualityStandardDeviations = cloner.Clone(original.qualityStandardDeviations); 125 this.qualityVariances = cloner.Clone(original.qualityVariances); 126 this.averageExecutionTimes = cloner.Clone(original.averageExecutionTimes); 109 127 this.repetitions = cloner.Clone(original.repetitions); 110 128 this.runs = cloner.Clone(original.runs); … … 113 131 this.parameters.Add(p.Key, cloner.Clone(p.Value)); 114 132 } 115 Initialize();116 133 } 117 134 public override IDeepCloneable Clone(Cloner cloner) { … … 120 137 [StorableHook(HookType.AfterDeserialization)] 121 138 private void AfterDeserialization() { 122 Initialize();123 139 } 124 140 #endregion 125 141 126 private void Initialize() {127 //if (algorithm != null) RegisterAlgorithmEvents();128 if (bestQuality != null) RegisterQualityEvents();129 }130 131 142 public virtual void CollectResultValues(IDictionary<string, IItem> values) { 132 values.Add("RunsAverageExecutionTime ", AverageExecutionTime);143 values.Add("RunsAverageExecutionTimes", AverageExecutionTimes); 133 144 values.Add("Repetitions", Repetitions); 134 values.Add("RunsBestQuality", BestQuality); 135 values.Add("RunsAverageQuality", AverageQuality); 136 values.Add("RunsWorstQuality", WorstQuality); 137 values.Add("RunsQualityVariance", QualityVariance); 138 values.Add("RunsQualityStandardDeviation", QualityStandardDeviation); 145 values.Add("RunsBestQualities", BestQualities); 146 values.Add("RunsAverageQualities", AverageQualities); 147 values.Add("RunsWorstQualities", WorstQualities); 148 values.Add("RunsQualityVariances", QualityVariances); 149 values.Add("RunsQualityStandardDeviations", QualityStandardDeviations); 150 values.Add("QualitiesNormalized", QualitiesNormalized); 151 values.Add("AverageQualityNormalized", AverageQualityNormalized); 139 152 values.Add("Runs", Runs); 140 153 } … … 147 160 148 161 #region Events 149 //public event EventHandler AlgorithmChanged;150 //private void OnAlgorithmChanged() {151 // var handler = AlgorithmChanged;152 // if (handler != null) handler(this, EventArgs.Empty);153 //}154 162 public event EventHandler QualityChanged; 155 163 private void OnQualityChanged() { 156 164 var handler = QualityChanged; 157 165 if (handler != null) handler(this, EventArgs.Empty); 158 }159 160 //private void RegisterAlgorithmEvents() {161 162 //}163 //private void DeregisterAlgorithmEvents() {164 165 //}166 private void RegisterQualityEvents() {167 BestQuality.ValueChanged += new EventHandler(Quality_ValueChanged);168 }169 private void DeregisterQualityEvents() {170 BestQuality.ValueChanged -= new EventHandler(Quality_ValueChanged);171 166 } 172 167 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/ParameterConfigurationEvaluator.cs
r5207 r5212 40 40 } 41 41 42 public LookupParameter<DoubleArray> ProblemQualityMediansParameter { 43 get { return (LookupParameter<DoubleArray>)Parameters["ProblemQualityMedians"]; } 44 } 45 42 46 public IntValue Repetitions { 43 47 get { return RepetitionsParameter.ActualValue; } … … 51 55 Parameters.Add(new LookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", "Missing description.")); 52 56 Parameters.Add(new LookupParameter<IntValue>(MetaOptimizationProblem.RepetitionsParameterName, "Number of evaluations on one problem.")); 57 Parameters.Add(new LookupParameter<DoubleArray>("ProblemQualityMedians", "")); 53 58 } 54 59 … … 66 71 IItemList<ISingleObjectiveProblem> problems = ProblemsParameter.ActualValue; 67 72 73 double[] medians; 74 if (ProblemQualityMediansParameter.ActualValue == null) { 75 // this is generation zero. no reference qualities for scaling have been calculated yet. calculate a random individuum to get reference values 76 medians = new double[problems.Count]; // todo 77 for (int i = 0; i < medians.Length; i++) { 78 medians[i] = 10; 79 } 80 } else { 81 medians = ProblemQualityMediansParameter.ActualValue.ToArray(); 82 } 83 68 84 // set parameters 69 85 ParameterConfigurationParameter.ActualValue.Parameterize(algorithm); 70 86 algorithm.StoreAlgorithmInEachRun = false; 71 87 72 List< double> qualities = new List<double>();73 List< TimeSpan> executionTimes = new List<TimeSpan>();88 List<List<double>> qualities = new List<List<double>>(); 89 List<List<TimeSpan>> executionTimes = new List<List<TimeSpan>>(); 74 90 algorithm.Engine = new SequentialEngine.SequentialEngine(); 75 91 algorithm.Prepare(true); … … 77 93 foreach (ISingleObjectiveProblem problem in problems) { 78 94 algorithm.Problem = (IProblem)problem.Clone(); 95 var problemQualities = new List<double>(); 96 var problemExecutionTimes = new List<TimeSpan>(); 79 97 80 98 for (int i = 0; i < Repetitions.Value; i++) { … … 86 104 if (algorithm.ExecutionState == ExecutionState.Paused) { 87 105 // this parametercombination was bad. set penalty for this solution 88 qualities.Add(PenaltyQuality); // todo: respect Maximization; problem: this messes up average value; solution: use currently worst quality*289 executionTimes.Add(algorithm.ExecutionTime);106 problemQualities.Add(PenaltyQuality); // todo: respect Maximization; problem: this messes up average value; solution: use currently worst quality*2 107 problemExecutionTimes.Add(algorithm.ExecutionTime); 90 108 } else { 91 qualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value);92 executionTimes.Add(algorithm.ExecutionTime);109 problemQualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value); 110 problemExecutionTimes.Add(algorithm.ExecutionTime); 93 111 94 112 // parameters will be stored in ParameterConfigurationTree anyway. they would be redundant in runs … … 98 116 } 99 117 } 118 qualities.Add(problemQualities); 119 executionTimes.Add(problemExecutionTimes); 100 120 } 101 121 algorithm.Prepare(); 102 122 103 qualities = qualities.OrderBy(x => x).ToList(); // todo: respect Maximization:true/false 104 105 ParameterConfigurationParameter.ActualValue.AverageExecutionTime = new TimeSpanValue(TimeSpan.FromMilliseconds(executionTimes.Average(t => t.TotalMilliseconds))); 123 ParameterConfigurationParameter.ActualValue.AverageExecutionTimes = new ItemList<TimeSpanValue>(executionTimes.Select(t => new TimeSpanValue(TimeSpan.FromMilliseconds(t.Average(ts => ts.TotalMilliseconds))))); 106 124 ParameterConfigurationParameter.ActualValue.Repetitions = (IntValue)Repetitions.Clone(); 107 ParameterConfigurationParameter.ActualValue.BestQualit y = new DoubleValue(qualities.First());108 ParameterConfigurationParameter.ActualValue.AverageQualit y = new DoubleValue(qualities.Average());109 ParameterConfigurationParameter.ActualValue.WorstQualit y = new DoubleValue(qualities.Last());110 ParameterConfigurationParameter.ActualValue.QualityVariance = new DoubleValue(qualities.Variance());111 ParameterConfigurationParameter.ActualValue.QualityStandardDeviation = new DoubleValue(qualities.StandardDeviation());125 ParameterConfigurationParameter.ActualValue.BestQualities = new DoubleArray(qualities.Select(q => q.Min()).ToArray()); // todo: respect Maximization:true/false 126 ParameterConfigurationParameter.ActualValue.AverageQualities = new DoubleArray(qualities.Select(q => q.Average()).ToArray()); 127 ParameterConfigurationParameter.ActualValue.WorstQualities = new DoubleArray(qualities.Select(q => q.Max()).ToArray()); // todo: respect Maximization:true/false 128 ParameterConfigurationParameter.ActualValue.QualityVariances = new DoubleArray(qualities.Select(q => q.Variance()).ToArray()); 129 ParameterConfigurationParameter.ActualValue.QualityStandardDeviations = new DoubleArray(qualities.Select(q => q.StandardDeviation()).ToArray()); 112 130 ParameterConfigurationParameter.ActualValue.Runs = (RunCollection)algorithm.Runs.Clone(); 113 131 114 double quality = ParameterConfigurationParameter.ActualValue.AverageQuality.Value; // todo: also include other measures (executiontime, variance) 115 this.QualityParameter.ActualValue = new DoubleValue(quality); 132 // normalize qualities 133 double[] qualitiesNormalized = new double[problems.Count]; 134 for (int i = 0; i < problems.Count; i++) { 135 qualitiesNormalized[i] = qualities[i].Average() / medians[i]; 136 } 137 ParameterConfigurationParameter.ActualValue.QualitiesNormalized = new DoubleArray(qualitiesNormalized); 138 ParameterConfigurationParameter.ActualValue.AverageQualityNormalized = new DoubleValue(qualitiesNormalized.Average()); 139 140 this.QualityParameter.ActualValue = ParameterConfigurationParameter.ActualValue.AverageQualityNormalized; 116 141 117 142 return base.Apply(); … … 129 154 } 130 155 156 /// <summary> 157 /// Can execute an algorithm synchronously 158 /// </summary> 131 159 public class AlgorithmExecutor { 132 160 private EngineAlgorithm algorithm; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r5184 r5212 109 109 var validIntManipulators = new ItemSet<IIntValueManipulator>( ApplicationManager.Manager.GetInstances<IIntValueManipulator>()); 110 110 var validDoubleManipulators = new ItemSet<IDoubleValueManipulator>(ApplicationManager.Manager.GetInstances<IDoubleValueManipulator>()); 111 Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, new UniformIntValueManipulator()));112 Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, new NormalDoubleValueManipulator()));111 Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, validIntManipulators.First())); 112 Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, validDoubleManipulators.First())); 113 113 114 114 Maximization = new BoolValue(false);
Note: See TracChangeset
for help on using the changeset viewer.