Changeset 5927
- Timestamp:
- 04/01/11 17:15:41 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/HeuristicLab.MetaOptimization.Test.csproj
r5522 r5927 53 53 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.ALGLIB-3.1.0.dll</HintPath> 54 54 </Reference> 55 <Reference Include="HeuristicLab.Algorithms.DataAnalysis-3. 3">56 <HintPath> C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.DataAnalysis-3.3.dll</HintPath>57 </Reference> 58 <Reference Include="HeuristicLab.Algorithms.DataAnalysis.Views-3. 3">59 <HintPath> C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.DataAnalysis.Views-3.3.dll</HintPath>55 <Reference Include="HeuristicLab.Algorithms.DataAnalysis-3.4"> 56 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.DataAnalysis-3.4.dll</HintPath> 57 </Reference> 58 <Reference Include="HeuristicLab.Algorithms.DataAnalysis.Views-3.4"> 59 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.DataAnalysis.Views-3.4.dll</HintPath> 60 60 </Reference> 61 61 <Reference Include="HeuristicLab.Algorithms.EvolutionStrategy-3.3"> … … 68 68 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.LocalSearch-3.3.dll</HintPath> 69 69 </Reference> 70 <Reference Include="HeuristicLab.Algorithms.NSGA2-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 71 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.NSGA2-3.3.dll</HintPath> 72 </Reference> 70 73 <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3"> 71 74 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath> 72 75 </Reference> 76 <Reference Include="HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 77 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3.dll</HintPath> 78 </Reference> 73 79 <Reference Include="HeuristicLab.Algorithms.SimulatedAnnealing-3.3"> 74 80 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.SimulatedAnnealing-3.3.dll</HintPath> … … 77 83 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.TabuSearch-3.3.dll</HintPath> 78 84 </Reference> 85 <Reference Include="HeuristicLab.Algorithms.VariableNeighborhoodSearch-3.3"> 86 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.VariableNeighborhoodSearch-3.3.dll</HintPath> 87 </Reference> 79 88 <Reference Include="HeuristicLab.Analysis-3.3"> 80 89 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Analysis-3.3.dll</HintPath> … … 113 122 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.DataAccess-3.3.dll</HintPath> 114 123 </Reference> 124 <Reference Include="HeuristicLab.DebugEngine-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 125 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.DebugEngine-3.3.dll</HintPath> 126 </Reference> 115 127 <Reference Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3"> 116 128 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.dll</HintPath> … … 128 140 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath> 129 141 </Reference> 130 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3. 3">131 <HintPath> C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.dll</HintPath>132 </Reference> 133 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3. 3">134 <HintPath> C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.3.dll</HintPath>142 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4"> 143 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath> 144 </Reference> 145 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4"> 146 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.dll</HintPath> 135 147 </Reference> 136 148 <Reference Include="HeuristicLab.Hive.Contracts-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> … … 236 248 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 237 249 </Reference> 238 <Reference Include="HeuristicLab.Problems.ArtificialAnt-3.3"> 239 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ArtificialAnt-3.3.dll</HintPath> 240 </Reference> 241 <Reference Include="HeuristicLab.Problems.ArtificialAnt.Views-3.3"> 242 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ArtificialAnt.Views-3.3.dll</HintPath> 243 </Reference> 244 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.3"> 245 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis-3.3.dll</HintPath> 246 </Reference> 247 <Reference Include="HeuristicLab.Problems.DataAnalysis.Classification-3.3"> 248 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Classification-3.3.dll</HintPath> 249 </Reference> 250 <Reference Include="HeuristicLab.Problems.DataAnalysis.Classification.Views-3.3"> 251 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Classification.Views-3.3.dll</HintPath> 252 </Reference> 253 <Reference Include="HeuristicLab.Problems.DataAnalysis.Regression-3.3"> 254 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Regression-3.3.dll</HintPath> 255 </Reference> 256 <Reference Include="HeuristicLab.Problems.DataAnalysis.Views-3.3"> 257 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Views-3.3.dll</HintPath> 250 <Reference Include="HeuristicLab.Problems.ArtificialAnt-3.4"> 251 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ArtificialAnt-3.4.dll</HintPath> 252 </Reference> 253 <Reference Include="HeuristicLab.Problems.ArtificialAnt.Views-3.4"> 254 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ArtificialAnt.Views-3.4.dll</HintPath> 255 </Reference> 256 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4"> 257 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath> 258 </Reference> 259 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4"> 260 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath> 261 </Reference> 262 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4"> 263 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.dll</HintPath> 264 </Reference> 265 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4"> 266 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views-3.4.dll</HintPath> 267 </Reference> 268 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4"> 269 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath> 270 </Reference> 271 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4"> 272 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.dll</HintPath> 273 </Reference> 274 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4"> 275 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.dll</HintPath> 276 </Reference> 277 <Reference Include="HeuristicLab.Problems.DataAnalysis.Views-3.4"> 278 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Views-3.4.dll</HintPath> 258 279 </Reference> 259 280 <Reference Include="HeuristicLab.Problems.ExternalEvaluation-3.3"> 260 281 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ExternalEvaluation-3.3.dll</HintPath> 261 282 </Reference> 262 <Reference Include="HeuristicLab.Problems.ExternalEvaluation.GP-3. 3">263 <HintPath> C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ExternalEvaluation.GP-3.3.dll</HintPath>283 <Reference Include="HeuristicLab.Problems.ExternalEvaluation.GP-3.4"> 284 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.ExternalEvaluation.GP-3.4.dll</HintPath> 264 285 </Reference> 265 286 <Reference Include="HeuristicLab.Problems.ExternalEvaluation.GP.Views-3.3"> … … 274 295 <Reference Include="HeuristicLab.Problems.Knapsack.Views-3.3"> 275 296 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.Knapsack.Views-3.3.dll</HintPath> 276 </Reference>277 <Reference Include="HeuristicLab.Problems.MetaOptimization-3.3">278 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.MetaOptimization-3.3.dll</HintPath>279 </Reference>280 <Reference Include="HeuristicLab.Problems.MetaOptimization.Views-3.3">281 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.MetaOptimization.Views-3.3.dll</HintPath>282 297 </Reference> 283 298 <Reference Include="HeuristicLab.Problems.OneMax-3.3"> … … 372 387 <None Include="app.config" /> 373 388 </ItemGroup> 389 <ItemGroup> 390 <ProjectReference Include="..\HeuristicLab.Problems.MetaOptimization.Views\3.3\HeuristicLab.Problems.MetaOptimization.Views-3.3.csproj"> 391 <Project>{59567338-A551-4386-8405-A8C0DF3E376D}</Project> 392 <Name>HeuristicLab.Problems.MetaOptimization.Views-3.3</Name> 393 </ProjectReference> 394 <ProjectReference Include="..\HeuristicLab.Problems.MetaOptimization\3.3\HeuristicLab.Problems.MetaOptimization-3.3.csproj"> 395 <Project>{ABBC1DF6-FCC6-4F86-AB75-B6B3A72E7D17}</Project> 396 <Name>HeuristicLab.Problems.MetaOptimization-3.3</Name> 397 </ProjectReference> 398 </ItemGroup> 374 399 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 375 400 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
r5665 r5927 14 14 using HeuristicLab.Core; 15 15 using HeuristicLab.Data; 16 using HeuristicLab.Encodings.RealVectorEncoding; 16 17 using HeuristicLab.Hive.ExperimentManager; 17 18 using HeuristicLab.Optimization; … … 19 20 using HeuristicLab.PluginInfrastructure; 20 21 using HeuristicLab.PluginInfrastructure.Manager; 22 using HeuristicLab.Problems.DataAnalysis.Symbolic; 23 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression; 21 24 using HeuristicLab.Problems.MetaOptimization; 22 25 using HeuristicLab.Problems.TestFunctions; … … 46 49 //private static int baseAlgorithmMaxGenerations = 1000; 47 50 48 private static int metaAlgorithmPopulationSize = 5;51 private static int metaAlgorithmPopulationSize = 10; 49 52 private static int metaAlgorithmMaxGenerations = 15; 50 private static int metaProblemRepetitions = 2;51 private static int baseAlgorithmMaxGenerations = 5;53 private static int metaProblemRepetitions = 3; 54 private static int baseAlgorithmMaxGenerations = 10; 52 55 private static double mutationProbability = 0.10; 53 56 … … 74 77 //TestNormalCrossover(); 75 78 //TestItemDictionary(); 76 79 80 //TestSymbolicDataAnalysisGrammar(); return; 81 77 82 MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem(); 78 83 metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions); … … 90 95 //Console.WriteLine("Press enter to start"); 91 96 //Console.ReadLine(); 92 TestConfiguration(algorithmVc, new GeneticAlgorithm() { Problem = new SingleObjectiveTestFunctionProblem() });97 TestConfiguration(algorithmVc, typeof(GeneticAlgorithm), metaOptimizationProblem.Problems.First()); 93 98 94 99 Console.WriteLine("Press enter to start"); … … 99 104 100 105 Console.ReadLine(); 106 } 107 108 private void TestSymbolicDataAnalysisGrammar() { 109 var random = new MersenneTwister(); 110 111 var grammar1 = new TypeCoherentExpressionGrammar(); 112 var grammar2 = new TypeCoherentExpressionGrammar(); 113 114 grammar2.Symbols.Single(x => x.Name == "Addition").InitialFrequency = 0.5; 115 116 Console.WriteLine("========== Grammar1: =========="); 117 PrintGrammar(grammar1); 118 Console.WriteLine("========== Grammar2: =========="); 119 PrintGrammar(grammar2); 120 121 122 RealVector v1 = GetInitialFrequenciesAsRealVector(grammar1); 123 RealVector v2 = GetInitialFrequenciesAsRealVector(grammar2); 124 125 for (int i = 0; i < 10; i++) { 126 RealVector v3 = DiscreteCrossover.Apply(random, new ItemArray<RealVector>(new List<RealVector> { v1, v2 })); 127 128 var grammar3 = new TypeCoherentExpressionGrammar(); 129 SetInitialFrequenciesFromRealVector(grammar3, v3); 130 131 Console.WriteLine("\n========== Crossed: =========="); 132 PrintGrammar(grammar3); 133 } 134 135 } 136 137 private static void PrintGrammar(TypeCoherentExpressionGrammar grammar) { 138 foreach (var symbol in grammar.Symbols) { 139 Console.WriteLine("{0} ({1})", symbol.ToString(), symbol.InitialFrequency); 140 } 141 } 142 143 private static RealVector GetInitialFrequenciesAsRealVector(TypeCoherentExpressionGrammar grammar) { 144 var vector = new RealVector(grammar.Symbols.Count()); 145 for (int i = 0; i < grammar.Symbols.Count(); i++) { 146 vector[i] = grammar.Symbols.ElementAt(i).InitialFrequency; 147 } 148 return vector; 149 } 150 151 private static void SetInitialFrequenciesFromRealVector(TypeCoherentExpressionGrammar grammar, RealVector vector) { 152 for (int i = 0; i < grammar.Symbols.Count(); i++) { 153 grammar.Symbols.ElementAt(i).InitialFrequency = vector[i]; 154 } 101 155 } 102 156 … … 384 438 // because creating ThreadLocal<T> takes all the runtime. 385 439 // when the algs are not stored in a list however this effect does not occur. 386 440 387 441 388 442 for (int i = 0; i < 1000; i++) { … … 557 611 private static void TestTypeDiscovery() { 558 612 PluginLoader.pluginAssemblies.Any(); 559 613 560 614 var items = ApplicationManager.Manager.GetInstances(typeof(DoubleArray)).ToArray(); 561 615 … … 638 692 private static ParameterConfigurationTree SetupGAAlgorithm(Type baseLevelAlgorithmType, MetaOptimizationProblem metaOptimizationProblem) { 639 693 metaOptimizationProblem.AlgorithmType.Value = baseLevelAlgorithmType; 640 metaOptimizationProblem.ProblemType.Value = typeof(SingleObjectiveTestFunctionProblem); 641 ParameterConfigurationTree algorithmVc = metaOptimizationProblem.ParameterConfigurationTree; 642 ((IntValue)algorithmVc.AlgorithmConfiguration.ParameterConfigurations.Single(x => x.Name == "MaximumGenerations").ActualValue.Value).Value = baseAlgorithmMaxGenerations; 643 644 metaOptimizationProblem.Problems.Clear(); 645 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 646 Evaluator = new GriewankEvaluator(), 647 ProblemSize = new IntValue(2) 648 }); 694 //metaOptimizationProblem.Problems.Clear(); 695 696 //metaOptimizationProblem.ProblemType.Value = typeof(SingleObjectiveTestFunctionProblem); 697 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 698 // Evaluator = new GriewankEvaluator(), 699 // ProblemSize = new IntValue(2) 700 //}); 649 701 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 650 702 // Evaluator = new GriewankEvaluator(), … … 656 708 //}); 657 709 658 ConfigurePopulationSize(algorithmVc, 15, 20, 1); 710 metaOptimizationProblem.ProblemType.Value = typeof(SymbolicRegressionSingleObjectiveProblem); 711 712 ParameterConfigurationTree algorithmVc = metaOptimizationProblem.ParameterConfigurationTree; 713 ((IntValue)algorithmVc.AlgorithmConfiguration.ParameterConfigurations.Single(x => x.Name == "MaximumGenerations").ActualValue.Value).Value = baseAlgorithmMaxGenerations; 714 715 //ConfigurePopulationSize(algorithmVc, 15, 20, 1); 659 716 ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01); 660 //ConfigureMutationOperator(algorithmVc);717 ConfigureMutationOperator(algorithmVc); 661 718 //ConfigureElites(algorithmVc, 0, 8, 1); 662 719 //ConfigureSelectionOperator(algorithmVc, true); 720 721 ConfigureSymbolicExpressionGrammar(algorithmVc); 722 663 723 return algorithmVc; 664 724 } 665 725 666 private static void TestConfiguration(ParameterConfigurationTree algorithmVc, GeneticAlgorithm baseLevelAlgorithm) { 726 private static void ConfigureSymbolicExpressionGrammar(ParameterConfigurationTree vc) { 727 var pc = vc.ProblemConfiguration.ParameterConfigurations.Single(x => x.Name == "SymbolicExpressionTreeGrammar"); 728 pc.Optimize = true; 729 730 SymbolicExpressionGrammarValueConfiguration symbolicExpressionGrammarVc = null; 731 foreach (var valconf in pc.ValueConfigurations) { 732 if (valconf.ActualValue.Value.ItemName != "TypeCoherentExpressionGrammar") { 733 pc.ValueConfigurations.SetItemCheckedState(valconf, false); 734 } else { 735 symbolicExpressionGrammarVc = valconf as SymbolicExpressionGrammarValueConfiguration; 736 } 737 } 738 symbolicExpressionGrammarVc.Optimize = true; 739 740 var additionPc = symbolicExpressionGrammarVc.ParameterConfigurations.Single(x => x.Name == "Addition"); 741 additionPc.Optimize = true; 742 var initialFrequencyVc = ((ParameterizedValueConfiguration)additionPc.ValueConfigurations.First()).ParameterConfigurations.Single(x => x.Name == "InitialFrequency"); 743 initialFrequencyVc.Optimize = true; 744 } 745 746 private static void TestConfiguration(ParameterConfigurationTree algorithmVc, Type baseLevelAlgorithmType, IProblem problem) { 667 747 IRandom rand = new FastRandom(0); 748 var baseLevelAlgorithm = (GeneticAlgorithm)MetaOptimizationUtil.CreateParameterizedAlgorithmInstance(algorithmVc, baseLevelAlgorithmType, problem); 749 668 750 // set random values 669 751 for (int i = 0; i < 10; i++) { … … 739 821 740 822 // uncheck multiMutator to avoid Michalewicz issue 741 var multiMutator = mutationOperator.ValueConfigurations.Where(x => x.ActualValue.Value != null && x.ActualValue.Value.ItemName.StartsWith("Multi")).SingleOrDefault();742 if (multiMutator != null) {743 mutationOperator.ValueConfigurations.SetItemCheckedState(multiMutator, false);744 }823 //var multiMutator = mutationOperator.ValueConfigurations.Where(x => x.ActualValue.Value != null && x.ActualValue.Value.ItemName.StartsWith("Multi")).SingleOrDefault(); 824 //if (multiMutator != null) { 825 // mutationOperator.ValueConfigurations.SetItemCheckedState(multiMutator, false); 826 //} 745 827 746 828 // add another normal - don't do this with 'new', because ActualNames will not be set correctly. It should be copied from an existing one … … 864 946 var orderedRuns = rc.OrderBy(x => x.Results["AverageQualityNormalized"]); 865 947 866 TableBuilder tb = new TableBuilder("QNorm", "Qualities"/*, "PoSi" /* "MutRa", "Eli", "SelOp", "MutOp", "NrSelSubScopes"*/);948 TableBuilder tb = new TableBuilder("QNorm", "Qualities"/*, "PoSi"*/ ,"MutRa" /*,"Eli", "SelOp"*/, "MutOp"/*, "NrSelSubScopes"*/); 867 949 foreach (IRun run in orderedRuns) { 868 950 //string selector; … … 874 956 875 957 tb.AppendRow( 876 ((DoubleValue)run.Results["AverageQualityNormalized"]).Value.ToString("#0.0000") ,877 ((DoubleArray)run.Results["RunsAverageQualities"]).ToString()878 // ((IntValue)run.Parameters["PopulationSize"]).Value.ToString(),879 //((DoubleValue)run.Parameters["MutationProbability"]).Value.ToString("0.0000"),880 // ((IntValue)run.Parameters["Elites"]).Value.ToString(),881 // Shorten(selector, 20),882 //Shorten(run.Parameters.ContainsKey("Mutator") ? run.Parameters["Mutator"].ToString() : "null", 40),883 // ((ISelector)run.Parameters["Selector"]).NumberOfSelectedSubScopesParameter.Value.ToString()958 ((DoubleValue)run.Results["AverageQualityNormalized"]).Value.ToString("#0.0000") 959 ,((DoubleArray)run.Results["RunsAverageQualities"]).ToString() 960 //,((IntValue)run.Parameters["PopulationSize"]).Value.ToString() 961 ,((DoubleValue)run.Parameters["MutationProbability"]).Value.ToString("0.0000") 962 //,((IntValue)run.Parameters["Elites"]).Value.ToString() 963 //,Shorten(selector, 20) 964 ,Shorten(run.Parameters.ContainsKey("Mutator") ? run.Parameters["Mutator"].ToString() : "null", 40) 965 //,((ISelector)run.Parameters["Selector"]).NumberOfSelectedSubScopesParameter.Value.ToString() 884 966 ); 885 967 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/MetaOptimizationProblemView.Designer.cs
r5313 r5927 31 31 // 32 32 this.parameterCollectionView.AllowDrop = true; 33 this.parameterCollectionView.Size = new System.Drawing.Size(604, 3 53);33 this.parameterCollectionView.Size = new System.Drawing.Size(604, 373); 34 34 this.parameterCollectionView.DragDrop += new System.Windows.Forms.DragEventHandler(this.parameterCollectionView_DragDrop); 35 35 this.parameterCollectionView.DragEnter += new System.Windows.Forms.DragEventHandler(this.parameterCollectionView_DragEnterOver); … … 40 40 this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 41 41 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 42 this.nameTextBox.Size = new System.Drawing.Size(532, 20); 43 // 44 // descriptionTextBox 45 // 46 this.descriptionTextBox.Size = new System.Drawing.Size(532, 20); 42 this.nameTextBox.Size = new System.Drawing.Size(542, 20); 47 43 // 48 44 // createExperimentButton … … 50 46 this.createExperimentButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 51 47 | System.Windows.Forms.AnchorStyles.Right))); 52 this.createExperimentButton.Location = new System.Drawing.Point(0, 4 11);48 this.createExperimentButton.Location = new System.Drawing.Point(0, 405); 53 49 this.createExperimentButton.Name = "createExperimentButton"; 54 50 this.createExperimentButton.Size = new System.Drawing.Size(604, 24); … … 64 60 this.Controls.Add(this.createExperimentButton); 65 61 this.Name = "MetaOptimizationProblemView"; 66 this.Size = new System.Drawing.Size(604, 43 7);62 this.Size = new System.Drawing.Size(604, 431); 67 63 this.Controls.SetChildIndex(this.createExperimentButton, 0); 64 this.Controls.SetChildIndex(this.infoLabel, 0); 68 65 this.Controls.SetChildIndex(this.nameTextBox, 0); 69 66 this.Controls.SetChildIndex(this.nameLabel, 0); 70 this.Controls.SetChildIndex(this.descriptionLabel, 0);71 this.Controls.SetChildIndex(this.descriptionTextBox, 0);72 67 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 73 68 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/MetaOptimizationProblemView.resx
r5313 r5927 121 121 <value>107, 17</value> 122 122 </metadata> 123 <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">124 <value>107, 17</value>125 </metadata>126 123 <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 127 124 <value>17, 17</value> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/OptimizableView.cs
r5665 r5927 68 68 this.viewHost.Content = pvc.ParameterConfigurations; 69 69 } 70 71 //var symbolicVc = Content as SymbolicExpressionGrammarValueConfiguration; 72 //if (symbolicVc != null) { 73 // this.viewHost.ViewsLabelVisible = false; 74 // this.viewHost.Content = symbolicVc.ParameterConfigurations; 75 //} 70 76 } else { 71 77 throw new NotSupportedException("Only IParameterConfiguration and IValueConfiguration types are allowed."); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurationTree.cs
r5665 r5927 208 208 ProblemConfiguration.Parameterize(problem); 209 209 210 //((IAlgorithm)AlgorithmConfiguration.ActualValue.Value).CollectParameterValues(this.Parameters);210 algorithm.CollectParameterValues(this.Parameters); 211 211 //((IProblem)ProblemConfiguration.ActualValue.Value).CollectParameterValues(this.Parameters); 212 } 212 //CollectAlgorithmParameterValues((IAlgorithm)AlgorithmConfiguration.ActualValue.Value, parameters); 213 } 214 215 //protected virtual void CollectAlgorithmParameterValues(IAlgorithm algorithm, IDictionary<string, IItem> values) { 216 // var algorithmValues = new Dictionary<string, IItem>(); 217 // algorithm.CollectParameterValues(algorithmValues); 218 // foreach (var value in algorithmValues) { 219 // values.Add("Algorithm." + value.Key, value.Value); 220 // } 221 //} 213 222 214 223 public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions) { … … 297 306 } 298 307 } 308 309 public override void CollectOptimizedParameterNames(List<string> parameterNames, string prefix) { 310 AlgorithmConfiguration.CollectOptimizedParameterNames(parameterNames, string.Empty); 311 ProblemConfiguration.CollectOptimizedParameterNames(parameterNames, string.Empty); 312 } 313 314 299 315 } 300 316 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5665 r5927 9 9 using HeuristicLab.Core; 10 10 using HeuristicLab.Data; 11 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 11 12 using HeuristicLab.Parameters; 12 13 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 25 26 [Storable] 26 27 protected bool optimize; 27 public bool Optimize {28 public virtual bool Optimize { 28 29 get { return optimize; } 29 30 set { … … 33 34 PopulateValueConfigurations(); 34 35 } else { 35 this.ValueConfigurations.Clear();36 ClearValueConfigurations(); 36 37 } 37 38 OnOptimizeChanged(); … … 42 43 43 44 [Storable] 44 pr ivateImage itemImage;45 public virtualImage ItemImage {45 protected Image itemImage; 46 public override Image ItemImage { 46 47 get { return itemImage ?? base.ItemImage; } 47 48 } … … 160 161 } 161 162 } 162 163 public ParameterConfiguration(string parameterName, Type type, IItem actualValue, IEnumerable<IValueConfiguration> valueConfigurations) { 164 this.ParameterName = parameterName; 165 this.parameterDataType = type; 166 this.valueDataType = type; 167 this.discoverValidValues = false; 168 this.validValues = null; // maybe use values from valueConfigurations 169 this.validTypes = new Type[] { type }; 170 this.IsNullable = false; 171 this.itemImage = valueConfigurations.Count() > 0 ? valueConfigurations.FirstOrDefault().ItemImage : null; 172 this.ValueConfigurations = new CheckedValueConfigurationList(valueConfigurations); 173 this.ActualValue = new ConstrainedValue(actualValue, type, CreateValidValues(), this.IsNullable); 174 } 175 public ParameterConfiguration(string parameterName, Type type, IItem actualValue) { 176 this.ParameterName = parameterName; 177 this.parameterDataType = type; 178 this.valueDataType = type; 179 this.discoverValidValues = false; 180 this.validValues = null; 181 this.validTypes = new Type[] { type }; 182 this.IsNullable = false; 183 this.itemImage = actualValue.ItemImage; 184 this.ValueConfigurations = new CheckedValueConfigurationList(); 185 this.ActualValue = new ConstrainedValue(actualValue, type, CreateValidValues(), this.IsNullable); 186 if (Optimize) { 187 PopulateValueConfigurations(); 188 } 189 } 163 190 public ParameterConfiguration() { } 164 191 [StorableConstructor] … … 180 207 if (this.valueConfigurations != null) RegisterValueConfigurationEvents(); 181 208 } 209 210 182 211 public override IDeepCloneable Clone(Cloner cloner) { 183 212 return new ParameterConfiguration(this, cloner); … … 208 237 } 209 238 210 pr ivatevoid PopulateValueConfigurations() {239 protected virtual void PopulateValueConfigurations() { 211 240 foreach (Type t in this.validTypes) { 212 241 if (t == typeof(NullValue)) { … … 220 249 } 221 250 if (val != null) { // val can be null when ValidValues does not contain the type (this can happen when discoverValidValues=false) 251 IValueConfiguration valueConfiguration; 222 252 if (val is IParameterizedItem) { 223 this.ValueConfigurations.Add(new ParameterizedValueConfiguration(val, val.GetType(), true), true);253 valueConfiguration = new ParameterizedValueConfiguration(val, val.GetType(), true); 224 254 } else { 225 this.ValueConfigurations.Add(new RangeValueConfiguration(val, val.GetType()), true); 255 if (val is ISymbolicExpressionGrammar) { 256 valueConfiguration = new SymbolicExpressionGrammarValueConfiguration((ISymbolicExpressionGrammar)val); 257 } else { 258 valueConfiguration = new RangeValueConfiguration(val, val.GetType()); 259 } 226 260 } 227 } 228 } 229 } 261 this.ValueConfigurations.Add(valueConfiguration, true); 262 } 263 } 264 } 265 } 266 267 protected virtual void ClearValueConfigurations() { 268 this.ValueConfigurations.Clear(); 230 269 } 231 270 … … 260 299 public IItem CreateItem(Type type) { 261 300 // no valid values; just instantiate 262 if (validValues == null) 263 return (IItem)Activator.CreateInstance(type); 301 try { 302 if (validValues == null) 303 return (IItem)Activator.CreateInstance(type); 304 } 305 catch (MissingMemberException) { 306 return null; // can happen, when ApplicationManager.Manager.GetTypes(type, OnlyInstantiable=true) returns objects which have no default constructor 307 } 264 308 265 309 if (type == typeof(NullValue)) … … 279 323 try { 280 324 var val = CreateItem(t); 281 validValues.Add(val);325 if (val != null) validValues.Add(val); 282 326 } 283 327 catch (MissingMethodException) { /* Constructor is missing, don't use those types */ } … … 415 459 416 460 public void Parameterize(IValueParameter parameter) { 461 if (parameter is IFixedValueParameter) 462 return; 463 417 464 if (Optimize) { 418 465 if (this.ActualValue.Value is IParameterizedItem) { 419 466 ((ParameterizedValueConfiguration)this.ValueConfigurations[actualValueConfigurationIndex]).Parameterize((IParameterizedItem)this.ActualValue.Value); 467 } 468 if (this.ActualValue.Value is ISymbolicExpressionGrammar) { 469 ((SymbolicExpressionGrammarValueConfiguration)this.ValueConfigurations[actualValueConfigurationIndex]).Parameterize((ISymbolicExpressionGrammar)this.ActualValue.Value); 420 470 } 421 471 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/SingleValuedParameterConfiguration.cs
r5665 r5927 1 using System.Linq; 1 using System; 2 using System.Linq; 2 3 using HeuristicLab.Common; 3 4 using HeuristicLab.Core; … … 14 15 : base(parameterName, valueParameter, false) { 15 16 this.Optimize = true; 17 base.PopulateValueConfigurations(); 16 18 this.ValueConfigurations.Single().Optimize = true; 19 } 20 public SingleValuedParameterConfiguration(string parameterName, IValueConfiguration valueConfiguration) { 21 this.ParameterName = parameterName; 22 this.parameterDataType = valueConfiguration.ActualValue.ValueDataType; 23 this.valueDataType = valueConfiguration.ActualValue.ValueDataType; 24 this.discoverValidValues = false; 25 this.validValues = new ItemSet<IItem> { valueConfiguration.ActualValue.Value }; 26 this.validTypes = new Type[] {valueConfiguration.ActualValue.ValueDataType}; 27 this.IsNullable = false; 28 this.itemImage = valueConfiguration.ItemImage; 29 this.ValueConfigurations = new CheckedValueConfigurationList { valueConfiguration }; 30 this.ValueConfigurations.Single().Optimize = true; 31 valueConfiguration.ToStringChanged += new EventHandler(valueConfiguration_ToStringChanged); 32 this.ActualValue = new ConstrainedValue( 33 valueConfiguration.ActualValue.Value, 34 valueConfiguration.ActualValue.ValueDataType, 35 this.validValues, 36 this.IsNullable); 17 37 } 18 38 public SingleValuedParameterConfiguration() { } … … 24 44 } 25 45 #endregion 46 47 protected override void PopulateValueConfigurations() { 48 // don't change valueconfigurations, since it only contains the one element specified in constructor 49 } 50 51 protected override void ClearValueConfigurations() { 52 // do nothing 53 } 54 55 public override string ToString() { 56 if (this.valueConfigurations.First() is SymbolValueConfiguration) { 57 var syVc = (SymbolValueConfiguration)this.valueConfigurations.First(); 58 if (this.Optimize) { 59 return syVc.ToString() + " (Optimize)"; 60 } else { 61 return syVc.ToString(); 62 } 63 } else { 64 return base.ToString(); 65 } 66 } 67 68 private void valueConfiguration_ToStringChanged(object sender, EventArgs e) { 69 OnToStringChanged(); 70 } 26 71 } 27 72 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs
r5361 r5927 1 using System; 2 using System.Collections.Generic; 1 using System.Collections.Generic; 3 2 using System.Linq; 4 using System.Text; 3 using HeuristicLab.Collections; 4 using HeuristicLab.Common; 5 5 using HeuristicLab.Core; 6 using HeuristicLab.Common;7 6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 using HeuristicLab.Collections;9 7 10 8 namespace HeuristicLab.Problems.MetaOptimization { … … 29 27 RegisterEvents(); 30 28 } 29 public CheckedValueConfigurationList(IEnumerable<IValueConfiguration> collection) 30 : base(collection) { 31 validValues = null; 32 // event wiring not needed 33 } 31 34 public CheckedValueConfigurationList() { 32 35 RegisterEvents(); … … 43 46 RegisterEvents(); 44 47 } 48 45 49 public override IDeepCloneable Clone(Cloner cloner) { 46 50 return new CheckedValueConfigurationList(this, cloner); … … 61 65 } 62 66 63 void CheckedValueConfigurationList_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {67 private void CheckedValueConfigurationList_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 64 68 foreach (var item in e.Items) { 65 69 var matchingItems = this.Where(x => x != item.Value && x.ActualValue.ValueDataType == item.Value.ActualValue.ValueDataType); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ParameterizedValueConfiguration.cs
r5665 r5927 20 20 get { return base.Optimize; } 21 21 set { 22 base.Optimize = value; 23 if (optimize) { 24 ClearParameterConfigurations(); 25 if (this.actualValue.Value is IParameterizedNamedItem) PopulateParameterConfigurations(this.actualValue.Value as IParameterizedNamedItem, this.discoverValidValues); 26 } else { 27 ClearParameterConfigurations(); 22 if (this.optimize != value) { 23 base.Optimize = value; 24 if (optimize) { 25 ClearParameterConfigurations(); 26 PopulateParameterConfigurations(this.actualValue.Value, this.discoverValidValues); 27 } else { 28 ClearParameterConfigurations(); 29 } 28 30 } 29 31 } … … 35 37 ClearParameterConfigurations(); 36 38 base.ActualValue = value; 37 if (this.actualValue.Value != null) PopulateParameterConfigurations(this.actualValue.Value as IParameterizedNamedItem, this.discoverValidValues);39 if (this.Optimize && this.actualValue.Value != null) PopulateParameterConfigurations(this.actualValue.Value, this.discoverValidValues); 38 40 } 39 41 } … … 66 68 #endregion 67 69 68 protected virtual void PopulateParameterConfigurations(IParameterizedNamedItem parameterizedItem, bool discoverValidValues) { 69 foreach (var childParameter in parameterizedItem.Parameters) { 70 IValueParameter valueParameter = childParameter as IValueParameter; 71 if (valueParameter != null) { 72 var pc = new ParameterConfiguration(valueParameter.Name, valueParameter, discoverValidValues); 73 this.parameterConfigurations.Add(pc); 70 protected virtual void PopulateParameterConfigurations(IItem item, bool discoverValidValues) { 71 var parameterizedItem = item as IParameterizedItem; 72 if (parameterizedItem != null) { 73 foreach (var childParameter in parameterizedItem.Parameters) { 74 IValueParameter valueParameter = childParameter as IValueParameter; 75 if (valueParameter != null) { 76 var pc = new ParameterConfiguration(valueParameter.Name, valueParameter, discoverValidValues); 77 this.parameterConfigurations.Add(pc); 78 } 74 79 } 75 80 } … … 126 131 } 127 132 128 public IEnumerable<string> GetOptimizedParameterNames() {133 public virtual IEnumerable<string> GetOptimizedParameterNames() { 129 134 var list = new List<string>(); 130 this.CollectOptimizedParameterNames(list, "");135 this.CollectOptimizedParameterNames(list, string.Empty); 131 136 return list; 132 137 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5665 r5927 20 20 [Storable] 21 21 protected bool isOptimizable; 22 public bool IsOptimizable {22 public virtual bool IsOptimizable { 23 23 get { return isOptimizable; } 24 24 set { … … 36 36 set { 37 37 if (optimize != value) { 38 if (value == true && !this.IsOptimizable) 39 throw new NotSupportedException("This value is not optimizable."); 40 38 41 optimize = value; 39 42 OnOptimizeChanged(); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/AlgorithmSubScopesCreator.cs
r5665 r5927 59 59 for (int j = 0; j < problems.Count; j++) { 60 60 IScope child = new Scope(string.Format("Problem {0}, Repetition {1}", j, i)); 61 var algorithm = (IAlgorithm)Activator.CreateInstance(algorithmType); 62 algorithm.Problem = (IProblem)problems[j].Clone(); 63 ((EngineAlgorithm)algorithm).Engine = new SequentialEngine.SequentialEngine(); 64 65 //((GeneticAlgorithm)algorithm).PopulationSize.Value = 10; 66 //((GeneticAlgorithm)algorithm).MaximumGenerations.Value = 10; 67 68 parameterConfiguration.Parameterize(algorithm); 61 var algorithm = MetaOptimizationUtil.CreateParameterizedAlgorithmInstance(parameterConfiguration, algorithmType, (IProblem)problems[j].Clone()); 69 62 child.Variables.Add(new Variable("Algorithm", algorithm)); 70 63 child.Variables.Add(new Variable("ProblemIndex", new IntValue(j))); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj
r5665 r5927 102 102 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath> 103 103 </Reference> 104 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4"> 105 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath> 106 </Reference> 104 107 <Reference Include="HeuristicLab.Operators-3.3"> 105 108 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath> … … 117 120 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 118 121 </Reference> 119 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.3"> 120 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis-3.3.dll</HintPath> 122 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4"> 123 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath> 124 </Reference> 125 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4"> 126 <HintPath>..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath> 121 127 </Reference> 122 128 <Reference Include="HeuristicLab.Problems.TestFunctions-3.3"> … … 148 154 <Compile Include="Encoding\AlgorithmProblemItem.cs" /> 149 155 <Compile Include="Encoding\ParameterConfigurations\SingleValuedParameterConfiguration.cs" /> 156 <Compile Include="Encoding\SymbolicRegression\SymbolValueConfiguration.cs" /> 157 <Compile Include="Encoding\SymbolicRegression\SymbolicExpressionGrammarValueConfiguration.cs" /> 150 158 <Compile Include="Encoding\ValueConfigurations\RangeValueConfiguration.cs" /> 151 159 <Compile Include="Encoding\ValueConfigurations\ParameterizedValueConfiguration.cs" /> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r5665 r5927 38 38 [Creatable("Problems")] 39 39 [StorableClass] 40 public sealed class MetaOptimizationProblem : SingleObjective Problem<IParameterConfigurationEvaluator, IParameterConfigurationCreator>, IStorableContent {40 public sealed class MetaOptimizationProblem : SingleObjectiveHeuristicOptimizationProblem<IParameterConfigurationEvaluator, IParameterConfigurationCreator>, IStorableContent { 41 41 public string Filename { get; set; } 42 42 43 43 public const string AlgorithmTypeParameterName = "AlgorithmType"; 44 44 public const string ProblemTypeParameterName = "ProblemType"; … … 272 272 273 273 // special for DataAnalysisProblem: Because of wiring between algorithm and problem, ParameterConfigurationTree needs to be recreated on Reset event 274 var dap = e.Items.Single().Value as DataAnalysisProblem;274 var dap = e.Items.Single().Value as IDataAnalysisProblem; 275 275 if (dap != null) { 276 276 dap.Reset += new EventHandler(DataAnalysisProblem_Reset); … … 283 283 ParameterConfigurationTreeParameter.ActualValue = null; 284 284 285 var dap = e.Items.Single().Value as DataAnalysisProblem;285 var dap = e.Items.Single().Value as IDataAnalysisProblem; 286 286 if (dap != null) { 287 287 dap.Reset -= new EventHandler(DataAnalysisProblem_Reset); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationUtil.cs
r5359 r5927 1 1 using System; 2 using System.Collections.Generic; 2 3 using System.Linq; 3 using System.Threading;4 using HeuristicLab.Common;5 4 using HeuristicLab.Core; 6 5 using HeuristicLab.Data; 7 using HeuristicLab.Operators;8 6 using HeuristicLab.Optimization; 9 using HeuristicLab.Parameters;10 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;11 using System.Collections.Generic;12 using HeuristicLab.Algorithms.GeneticAlgorithm;13 using System.Threading.Tasks;14 using System.Diagnostics;15 using System.Reflection;16 7 17 8 namespace HeuristicLab.Problems.MetaOptimization { … … 52 43 return parameterConfigurationTree.AverageQualityNormalized.Value; 53 44 } 45 46 /// <summary> 47 /// Creates a new instance of algorithmType, sets the given problem and parameterizes it with the given configuration 48 /// </summary> 49 public static IAlgorithm CreateParameterizedAlgorithmInstance(ParameterConfigurationTree parameterConfigurationTree, Type algorithmType, IProblem problem, bool randomize = false, IRandom random = null) { 50 var algorithm = (IAlgorithm)Activator.CreateInstance(algorithmType); 51 algorithm.Problem = problem; 52 ((EngineAlgorithm)algorithm).Engine = new SequentialEngine.SequentialEngine(); 53 if(randomize) parameterConfigurationTree.Randomize(random); 54 parameterConfigurationTree.Parameterize(algorithm); 55 return algorithm; 56 } 54 57 } 55 58 }
Note: See TracChangeset
for help on using the changeset viewer.