Changeset 5522
- Timestamp:
- 02/21/11 00:46:33 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/HeuristicLab.MetaOptimization.Test.csproj
r5267 r5522 44 44 </PropertyGroup> 45 45 <ItemGroup> 46 <Reference Include="ALGLIB-2.5.0">47 <HintPath>C:\Program Files\HeuristicLab 3.3\ALGLIB-2.5.0.dll</HintPath>48 </Reference>49 46 <Reference Include="ALGLIB-3.1.0"> 50 47 <HintPath>C:\Program Files\HeuristicLab 3.3\ALGLIB-3.1.0.dll</HintPath> … … 52 49 <Reference Include="Google.ProtocolBuffers-0.9.1"> 53 50 <HintPath>C:\Program Files\HeuristicLab 3.3\Google.ProtocolBuffers-0.9.1.dll</HintPath> 54 </Reference>55 <Reference Include="HeuristicLab.ALGLIB-2.5.0">56 <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.ALGLIB-2.5.0.dll</HintPath>57 51 </Reference> 58 52 <Reference Include="HeuristicLab.ALGLIB-3.1.0"> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
r5361 r5522 23 23 using HeuristicLab.Hive.ExperimentManager; 24 24 using System.Threading.Tasks; 25 using HeuristicLab.PluginInfrastructure.Manager; 26 using System.Reflection; 25 27 26 28 namespace HeuristicLab.MetaOptimization.Test { 27 29 class Program { 30 static void Main(string[] args) { 31 //PluginLoader.pluginAssemblies.Any(); 32 PluginManager pm = new PluginManager(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); 33 pm.DiscoverAndCheckPlugins(); 34 35 pm.Run(pm.Applications.Where(x => x.Name == "TestApp").SingleOrDefault()); 36 } 37 } 38 39 [Plugin("TestPlugin", "1.0.0.0")] 40 [PluginFile("HeuristicLab.MetaOptimization.Test.exe", PluginFileType.Assembly)] 41 public class TestPlugin : PluginBase { } 42 43 [Application("TestApp")] 44 public class TestApp : ApplicationBase { 28 45 //private static int metaAlgorithmPopulationSize = 50; 29 46 //private static int metaAlgorithmMaxGenerations = 30; … … 31 48 //private static int baseAlgorithmMaxGenerations = 1000; 32 49 33 private static int metaAlgorithmPopulationSize = 10;34 private static int metaAlgorithmMaxGenerations = 10;50 private static int metaAlgorithmPopulationSize = 20; 51 private static int metaAlgorithmMaxGenerations = 20; 35 52 private static int metaProblemRepetitions = 2; 36 private static int baseAlgorithmMaxGenerations = 20;53 private static int baseAlgorithmMaxGenerations = 10; 37 54 private static double mutationProbability = 0.10; 38 55 39 static void Main(string[] args) {56 public override void Run() { 40 57 ContentManager.Initialize(new PersistenceContentManager()); 41 58 42 59 //TestTableBuilder(); 43 60 //TestShorten(); 44 61 62 //TestSimilarities(); return; 45 63 //TestIntSampling(); 46 64 //TestDoubleSampling(); return; … … 51 69 //TestCombinations3(); 52 70 //TestEnumeratorCollectionEnumerator(); 53 TestCombinations4(); return;71 //TestCombinations4(); return; 54 72 //TestAlgorithmPerformanceIssue(); 55 73 //TestWaitAny(); … … 59 77 //TestItemDictionary(); 60 78 61 79 62 80 63 81 MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem(); … … 87 105 } 88 106 107 private static void TestSimilarities() { 108 Console.WriteLine("\nDoubleRange:"); 109 var doubleRange = new DoubleValueRange(new DoubleValue(0), new DoubleValue(10), new DoubleValue(1)); 110 var a = new DoubleValue(5.0); 111 112 for (double d = 0; d < 10; d += 0.1) { 113 var similarity = doubleRange.CalculateSimilarity(a, new DoubleValue(d)); 114 Console.WriteLine("{0}: {1}", d, similarity); 115 } 116 117 Console.WriteLine("\nPecentRange:"); 118 var percentRange = new PercentValueRange(new PercentValue(0), new PercentValue(1), new PercentValue(1)); 119 var b = new PercentValue(0.05); 120 121 for (double d = 0; d < 1; d += 0.01) { 122 var similarity = percentRange.CalculateSimilarity(b, new PercentValue(d)); 123 Console.WriteLine("{0}: {1}", d, similarity); 124 } 125 126 Console.WriteLine("\nIntRange:"); 127 var intRange = new IntValueRange(new IntValue(50), new IntValue(100), new IntValue(1)); 128 var c = new IntValue(90); 129 130 for (int i = 0; i < 100; i++) { 131 var similarity = intRange.CalculateSimilarity(c, new IntValue(i)); 132 Console.WriteLine("{0}: {1}", i, similarity); 133 } 134 135 Console.WriteLine("\nValueConfigurations:"); 136 var vc1 = SetupGAAlgorithm(typeof(GeneticAlgorithm), new MetaOptimizationProblem()); 137 vc1.ParameterConfigurations.Single(x => x.Name == "Elites").Optimize = true; 138 vc1.ParameterConfigurations.Single(x => x.Name == "PopulationSize").Optimize = true; 139 vc1.ParameterConfigurations.Single(x => x.Name == "MutationProbability").Optimize = true; 140 vc1.ParameterConfigurations.Single(x => x.Name == "Selector").Optimize = true; 141 142 var vc2 = (IValueConfiguration)vc1.Clone(); 143 Console.WriteLine("Assert(1): {0}", vc1.CalculateSimilarity(vc2)); 144 145 ((IntValue)vc2.ParameterConfigurations.Single(x => x.Name == "PopulationSize").ValueConfigurations[0].ActualValue.Value).Value = 75; 146 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 147 148 ((PercentValue)vc2.ParameterConfigurations.Single(x => x.Name == "MutationProbability").ValueConfigurations[0].ActualValue.Value).Value = 0.15; 149 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 150 151 ((PercentValue)vc2.ParameterConfigurations.Single(x => x.Name == "MutationProbability").ValueConfigurations[0].ActualValue.Value).Value = 0.25; 152 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 153 ((PercentValue)vc2.ParameterConfigurations.Single(x => x.Name == "MutationProbability").ValueConfigurations[0].ActualValue.Value).Value = 0.35; 154 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 155 ((PercentValue)vc2.ParameterConfigurations.Single(x => x.Name == "MutationProbability").ValueConfigurations[0].ActualValue.Value).Value = 0.45; 156 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 157 ((PercentValue)vc2.ParameterConfigurations.Single(x => x.Name == "MutationProbability").ValueConfigurations[0].ActualValue.Value).Value = 0.55; 158 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 159 160 vc2.ParameterConfigurations.Single(x => x.Name == "Selector").ActualValueConfigurationIndex = 3; 161 Console.WriteLine("{0}", vc1.CalculateSimilarity(vc2)); 162 163 var random = new Random.MersenneTwister(0); 164 for (int i = 0; i < 10; i++) { 165 vc2.Randomize(random); 166 Console.WriteLine("Randomized: {0}", vc1.CalculateSimilarity(vc2)); 167 } 168 } 169 89 170 private static void TestItemDictionary() { 90 171 var dict = new ItemDictionary<StringValue, RunCollection>(); … … 116 197 using (var sw = new StreamWriter("normalCrossover-IntValue.txt")) { 117 198 for (int i = 0; i < 10000; i++) { 118 sw.WriteLine(NormalIntValueCrossover.ApplyStatic(random, new IntValue(i1), new IntValue(i2), intRange));199 sw.WriteLine(NormalIntValueCrossover.ApplyStatic(random, new IntValue(i1), new IntValue(i2), intRange)); 119 200 } 120 201 } … … 557 638 ProblemSize = new IntValue(2) 558 639 }); 559 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {560 Evaluator = new GriewankEvaluator(),561 ProblemSize = new IntValue(20)562 });563 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {564 Evaluator = new GriewankEvaluator(),565 ProblemSize = new IntValue(500)566 });640 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 641 // Evaluator = new GriewankEvaluator(), 642 // ProblemSize = new IntValue(20) 643 //}); 644 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 645 // Evaluator = new GriewankEvaluator(), 646 // ProblemSize = new IntValue(500) 647 //}); 567 648 568 649 ConfigurePopulationSize(algorithmVc, 0, 20, 1); 569 //ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01);570 //ConfigureMutationOperator(algorithmVc);650 ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01); 651 ConfigureMutationOperator(algorithmVc); 571 652 ConfigureElites(algorithmVc, 0, 30, 1); 572 //ConfigureSelectionOperator(algorithmVc, true);653 ConfigureSelectionOperator(algorithmVc, true); 573 654 return algorithmVc; 574 655 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.sln
r5207 r5522 10 10 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F96C8DD1-9B68-4F2D-AD4F-1A174F596041}" 11 11 ProjectSection(SolutionItems) = preProject 12 HeuristicLab.MetaOptimization.vsmdi = HeuristicLab.MetaOptimization.vsmdi13 Local.testsettings = Local.testsettings14 12 Performance1.psess = Performance1.psess 15 13 PreBuildEvent.cmd = PreBuildEvent.cmd 16 TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings17 14 EndProjectSection 18 15 EndProject 19 16 Global 20 GlobalSection(TestCaseManagementSettings) = postSolution21 CategoryFile = HeuristicLab.MetaOptimization.vsmdi22 EndGlobalSection23 17 GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 18 Debug|Any CPU = Debug|Any CPU -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5361 r5522 493 493 } 494 494 } 495 496 public double CalculateSimilarity(IOptimizable optimizable) { 497 var other = (IParameterConfiguration)optimizable; 498 if (this.ActualValueConfigurationIndex == other.ActualValueConfigurationIndex) { 499 return this.ValueConfigurations[this.ActualValueConfigurationIndex].CalculateSimilarity(other.ValueConfigurations[other.ActualValueConfigurationIndex]); 500 } else { 501 return 0.0; 502 } 503 } 495 504 } 496 505 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/ConstrainedValue.cs
r5231 r5522 86 86 #endregion 87 87 88 void value_ToStringChanged(object sender, EventArgs e) {88 private void value_ToStringChanged(object sender, EventArgs e) { 89 89 OnToStringChanged(); 90 90 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/DoubleValueRange.cs
r5337 r5522 48 48 return solutions; 49 49 } 50 51 protected override double CalculateSimilarityValue(DoubleValue a, DoubleValue b) { 52 double range = UpperBound.Value - LowerBound.Value; 53 double diff = Math.Abs(a.Value - b.Value); 54 return Math.Max(0, (range - (diff*2)) / range); 55 } 50 56 } 51 57 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/IntValueRange.cs
r5337 r5522 47 47 return solutions; 48 48 } 49 50 protected override double CalculateSimilarityValue(IntValue a, IntValue b) { 51 double range = UpperBound.Value - LowerBound.Value; 52 double diff = Math.Abs(a.Value - b.Value); 53 return Math.Max(0, (range - (diff * 2)) / range); 54 } 49 55 } 50 56 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/PercentValueRange.cs
r5337 r5522 52 52 return solutions; 53 53 } 54 55 protected override double CalculateSimilarityValue(PercentValue a, PercentValue b) { 56 double range = UpperBound.Value - LowerBound.Value; 57 double diff = Math.Abs(a.Value - b.Value); 58 return Math.Max(0, (range - (diff * 2)) / range); 59 } 54 60 } 55 61 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/Range.cs
r5144 r5522 208 208 209 209 protected abstract T GetRandomSample(IRandom random); 210 210 211 IItem IRange.GetRandomValue(IRandom random) { 211 212 return GetRandomValue(random); … … 216 217 return GetCombinations().Cast<IItem>().ToArray(); 217 218 } 219 220 public virtual double CalculateSimilarity(IItem a, IItem b) { 221 return CalculateSimilarityValue((T)a, (T)b); 222 } 223 224 protected abstract double CalculateSimilarityValue(T a, T b); 218 225 } 219 226 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5361 r5522 326 326 return list; 327 327 } 328 329 public double CalculateSimilarity(IOptimizable optimizable) { 330 var other = (IValueConfiguration)optimizable; 331 if (rangeConstraint != null) { 332 return this.RangeConstraint.CalculateSimilarity(this.ActualValue.Value, other.ActualValue.Value); 333 } else { 334 double sum = 0; 335 int count = 0; 336 for (int i = 0; i < ParameterConfigurations.Count; i++) { 337 if (this.ParameterConfigurations.ElementAt(i).Optimize) { 338 sum += this.ParameterConfigurations.ElementAt(i).CalculateSimilarity(other.ParameterConfigurations.ElementAt(i)); 339 count++; 340 } 341 } 342 return count == 0 ? 1.0 : sum / (double)count; 343 } 344 } 328 345 } 329 346 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj
r5359 r5522 75 75 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath> 76 76 </Reference> 77 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 78 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Analysis-3.3.dll</HintPath> 79 </Reference> 77 80 <Reference Include="HeuristicLab.Collections-3.3"> 78 81 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath> … … 119 122 <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 120 123 <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath> 124 </Reference> 125 <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 126 <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Selection-3.3.dll</HintPath> 121 127 </Reference> 122 128 <Reference Include="HeuristicLab.SequentialEngine-3.3"> … … 133 139 <ItemGroup> 134 140 <Compile Include="Analyzers\BestParameterConfigurationAnalyzer.cs" /> 141 <Compile Include="Analyzers\PMOPopulationDiversityAnalyzer.cs" /> 135 142 <Compile Include="ConstrainedTypeValue.cs" /> 136 143 <Compile Include="MetaOptimizationUtil.cs" /> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs
r5340 r5522 20 20 string ParameterInfoString { get; } 21 21 void CollectOptimizedParameterNames(List<string> parameterNames, string prefix); 22 double CalculateSimilarity(IOptimizable optimizable); 22 23 23 24 /// <summary> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IRange.cs
r5144 r5522 18 18 19 19 IEnumerable<IItem> GetCombinations(); 20 21 double CalculateSimilarity(IItem a, IItem b); 20 22 } 21 23 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r5359 r5522 107 107 get { return Operators.OfType<SolutionCacheAnalyzer>().FirstOrDefault(); } 108 108 } 109 private PMOPopulationDiversityAnalyzer PMOPopulationDiversityAnalyzer { 110 get { return Operators.OfType<PMOPopulationDiversityAnalyzer>().FirstOrDefault(); } 111 } 109 112 #endregion 110 113 … … 170 173 Operators.Add(new ReferenceQualityAnalyzer()); 171 174 Operators.Add(new SolutionCacheAnalyzer()); 175 Operators.Add(new PMOPopulationDiversityAnalyzer()); 172 176 } 173 177 private void ParameterizeSolutionCreator() { … … 185 189 if (RunsAnalyzer != null) { 186 190 RunsAnalyzer.ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName; 191 } 192 if (PMOPopulationDiversityAnalyzer != null) { 193 PMOPopulationDiversityAnalyzer.SolutionParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName; 194 PMOPopulationDiversityAnalyzer.StoreHistoryParameter.Value.Value = true; 187 195 } 188 196 }
Note: See TracChangeset
for help on using the changeset viewer.