Changeset 5653
- Timestamp:
- 03/10/11 10:44:42 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization
- Files:
-
- 8 added
- 2 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test
- Property svn:ignore
-
old new 2 2 obj 3 3 HeuristicLab.MetaOptimization.Test.csproj.user 4 *.vs10x
-
- Property svn:ignore
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
r5576 r5653 2 2 using System.Collections; 3 3 using System.Collections.Generic; 4 using System.Diagnostics; 4 5 using System.IO; 5 6 using System.Linq; 7 using System.Reflection; 6 8 using System.Text; 7 9 using System.Threading; 10 using System.Threading.Tasks; 8 11 using HeuristicLab.Algorithms.EvolutionStrategy; 9 12 using HeuristicLab.Algorithms.GeneticAlgorithm; … … 11 14 using HeuristicLab.Core; 12 15 using HeuristicLab.Data; 16 using HeuristicLab.Hive.ExperimentManager; 13 17 using HeuristicLab.Optimization; 18 using HeuristicLab.Parameters; 14 19 using HeuristicLab.PluginInfrastructure; 20 using HeuristicLab.PluginInfrastructure.Manager; 15 21 using HeuristicLab.Problems.MetaOptimization; 16 22 using HeuristicLab.Problems.TestFunctions; 17 23 using HeuristicLab.Random; 18 24 using HeuristicLab.Selection; 19 using HeuristicLab.Parameters;20 using HeuristicLab.Operators;21 using System.Diagnostics;22 using HeuristicLab.Encodings.RealVectorEncoding;23 using HeuristicLab.Hive.ExperimentManager;24 using System.Threading.Tasks;25 using HeuristicLab.PluginInfrastructure.Manager;26 using System.Reflection;27 25 28 26 namespace HeuristicLab.MetaOptimization.Test { … … 70 68 //TestEnumeratorCollectionEnumerator(); 71 69 //TestCombinations4(); return; 72 //TestAlgorithmPerformanceIssue(); 70 //TestAlgorithmPerformanceIssue(); return; 73 71 //TestWaitAny(); 74 72 //TestExecutionTimeUpdateInvervalPerformance(); … … 76 74 //TestNormalCrossover(); 77 75 //TestItemDictionary(); 78 79 80 76 81 77 MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem(); 82 78 metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions); … … 87 83 //EvolutionStrategy metaLevelAlgorithm = GetMetaES(metaOptimizationProblem); 88 84 89 IValueConfigurationalgorithmVc = SetupGAAlgorithm(typeof(GeneticAlgorithm), metaOptimizationProblem);85 var algorithmVc = SetupGAAlgorithm(typeof(GeneticAlgorithm), metaOptimizationProblem); 90 86 91 87 //TestToString(algorithmVc); … … 94 90 //Console.WriteLine("Press enter to start"); 95 91 //Console.ReadLine(); 96 //TestConfiguration(algorithmVc, baseLevelAlgorithm);92 //TestConfiguration(algorithmVc, new GeneticAlgorithm()); 97 93 98 94 //Console.WriteLine("Press enter to start"); … … 140 136 vc1.ParameterConfigurations.Single(x => x.Name == "Selector").Optimize = true; 141 137 142 var vc2 = ( IValueConfiguration)vc1.Clone();138 var vc2 = (ParameterConfigurationTree)vc1.Clone(); 143 139 Console.WriteLine("Assert(1): {0}", vc1.CalculateSimilarity(vc2)); 144 140 … … 289 285 swx.Start(); 290 286 ((EngineAlgorithm)alg).ExecutionTimeChanged += new EventHandler(Program_ExecutionTimeChanged); 291 var executor = new AlgorithmExecutor((EngineAlgorithm)alg); 292 executor.StartSync(); 287 ((EngineAlgorithm)alg).StartSync(); 293 288 ((EngineAlgorithm)alg).ExecutionTimeChanged -= new EventHandler(Program_ExecutionTimeChanged); 294 289 swx.Stop(); … … 369 364 Queue<TimeSpan> latestExecutionTimes = new Queue<TimeSpan>(); 370 365 int size = 10; 366 var random = new Random.MersenneTwister(0); 371 367 372 368 GeneticAlgorithm ga = new GeneticAlgorithm(); … … 374 370 ga.MaximumGenerations.Value = 1; 375 371 ga.Engine = new SequentialEngine.SequentialEngine(); 376 throw new NotImplementedException("TODO: Set ga parameters correctly");372 ga.Problem = new SingleObjectiveTestFunctionProblem(); 377 373 378 374 MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem(); 379 metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions);375 //metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions); 380 376 GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem); 381 377 ParameterConfigurationTree algorithmVc = SetupGAAlgorithm(typeof(GeneticAlgorithm), metaOptimizationProblem); 378 algorithmVc.Randomize(random); 382 379 Stopwatch sw = new Stopwatch(); 383 380 381 var algs = new Queue<IAlgorithm>(); // keep them in memory 382 // -> BINGO! -> .NET cannot hold more than 16 algorithms with their ThreadLocal<T> objects efficiently, 383 // so if they are kept in memory, runtime at the 17. execution drops significantly 384 // because creating ThreadLocal<T> takes all the runtime. 385 // when the algs are not stored in a list however this effect does not occur. 386 387 384 388 for (int i = 0; i < 1000; i++) { 385 sw.Start();386 389 GeneticAlgorithm clonedGa = (GeneticAlgorithm)ga.Clone(); 387 390 clonedGa.Name = "CLONED GA"; 388 algorithmVc.Parameterize(clonedGa); 391 //algorithmVc.Randomize(random); 392 //algorithmVc.Parameterize(clonedGa); 389 393 clonedGa.Prepare(true); 390 var executor = new AlgorithmExecutor(clonedGa); 391 executor.StartSync(); 394 sw.Start(); 395 algs.Enqueue(clonedGa); 396 397 if (algs.Count > 24) 398 algs.Dequeue(); 399 clonedGa.StartSync(); 392 400 sw.Stop(); 393 401 latestExecutionTimes.Enqueue(sw.Elapsed); … … 549 557 private static void TestTypeDiscovery() { 550 558 PluginLoader.pluginAssemblies.Any(); 551 559 552 560 var items = ApplicationManager.Manager.GetInstances(typeof(DoubleArray)).ToArray(); 553 561 … … 634 642 ((IntValue)algorithmVc.ParameterConfigurations.Single(x => x.Name == "MaximumGenerations").ActualValue.Value).Value = baseAlgorithmMaxGenerations; 635 643 644 metaOptimizationProblem.Problems.Clear(); 636 645 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 637 646 Evaluator = new GriewankEvaluator(), 638 647 ProblemSize = new IntValue(2) 639 648 }); 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 });648 649 ConfigurePopulationSize(algorithmVc,5, 20, 1);650 ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01);649 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 650 // Evaluator = new GriewankEvaluator(), 651 // ProblemSize = new IntValue(20) 652 //}); 653 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 654 // Evaluator = new GriewankEvaluator(), 655 // ProblemSize = new IntValue(500) 656 //}); 657 658 //ConfigurePopulationSize(algorithmVc, 15, 20, 1); 659 //ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01); 651 660 ConfigureMutationOperator(algorithmVc); 652 //ConfigureElites(algorithmVc, 0, 30, 1);653 ConfigureSelectionOperator(algorithmVc, true);661 //ConfigureElites(algorithmVc, 0, 8, 1); 662 //ConfigureSelectionOperator(algorithmVc, true); 654 663 return algorithmVc; 655 664 } 656 665 657 private static void TestConfiguration( IValueConfigurationalgorithmVc, GeneticAlgorithm baseLevelAlgorithm) {666 private static void TestConfiguration(ParameterConfigurationTree algorithmVc, GeneticAlgorithm baseLevelAlgorithm) { 658 667 IRandom rand = new FastRandom(0); 659 668 // set random values 660 669 for (int i = 0; i < 10; i++) { 661 IValueConfiguration clonedVc = (IValueConfiguration)algorithmVc.Clone();670 var clonedVc = (ParameterConfigurationTree)algorithmVc.Clone(); 662 671 GeneticAlgorithm newAlg = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 663 672 clonedVc.Randomize(rand); … … 676 685 // mutate 677 686 for (int i = 0; i < 10; i++) { 678 IValueConfiguration clonedVc = (IValueConfiguration)algorithmVc.Clone();687 var clonedVc = (ParameterConfigurationTree)algorithmVc.Clone(); 679 688 GeneticAlgorithm newAlg = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 680 689 ParameterConfigurationManipulator.Apply(rand, clonedVc, new UniformIntValueManipulator(), new NormalDoubleValueManipulator()); … … 692 701 // cross 693 702 for (int i = 0; i < 10; i++) { 694 IValueConfiguration clonedVc1 = (IValueConfiguration)algorithmVc.Clone();695 IValueConfiguration clonedVc2 = (IValueConfiguration)algorithmVc.Clone();703 var clonedVc1 = (ParameterConfigurationTree)algorithmVc.Clone(); 704 var clonedVc2 = (ParameterConfigurationTree)algorithmVc.Clone(); 696 705 697 706 GeneticAlgorithm first = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); … … 725 734 } 726 735 727 private static void ConfigureMutationOperator( IValueConfigurationalgorithmVc) {736 private static void ConfigureMutationOperator(ParameterConfigurationTree algorithmVc) { 728 737 var mutationOperator = algorithmVc.ParameterConfigurations.Where(x => x.Name == "Mutator").SingleOrDefault(); 729 738 mutationOperator.Optimize = true; … … 735 744 } 736 745 737 // add another normal 738 mutationOperator.ValueConfigurations.Add(newValueConfiguration(new NormalAllPositionsManipulator(), typeof(NormalAllPositionsManipulator)), true);739 } 740 741 private static void ConfigureSelectionOperator( IValueConfigurationalgorithmVc, bool configureTournamenSize) {746 // add another normal - don't do this with 'new', because ActualNames will not be set correctly. It should be copied from an existing one 747 // mutationOperator.ValueConfigurations.Add(new ParameterizedValueConfiguration(new NormalAllPositionsManipulator(), typeof(NormalAllPositionsManipulator)), true); 748 } 749 750 private static void ConfigureSelectionOperator(ParameterConfigurationTree algorithmVc, bool configureTournamenSize) { 742 751 var selectionOperatorPc = algorithmVc.ParameterConfigurations.Where(x => x.Name == "Selector").SingleOrDefault(); 743 752 selectionOperatorPc.Optimize = true; … … 748 757 if (configureTournamenSize) { 749 758 vc.Optimize = true; 750 ConfigureTournamentGroupSize( vc);759 ConfigureTournamentGroupSize((ParameterizedValueConfiguration)vc); 751 760 } 752 761 } else if (vc.ActualValue.ValueDataType == typeof(RandomSelector)) { … … 758 767 } 759 768 760 private static void ConfigureTournamentGroupSize( IValueConfiguration tournamentVc) {769 private static void ConfigureTournamentGroupSize(ParameterizedValueConfiguration tournamentVc) { 761 770 var groupSizePc = tournamentVc.ParameterConfigurations.Where(x => x.ParameterName == "GroupSize").SingleOrDefault(); 762 771 groupSizePc.Optimize = true; 763 764 groupSize Pc.ValueConfigurations.First().Optimize = true;765 groupSize Pc.ValueConfigurations.First().RangeConstraint.LowerBound = new IntValue(0);766 groupSize Pc.ValueConfigurations.First().RangeConstraint.UpperBound = new IntValue(10);767 groupSize Pc.ValueConfigurations.First().RangeConstraint.StepSize = new IntValue(1);768 } 769 770 private static void ConfigurePopulationSize( IValueConfiguration algorithmVc, int lower, int upper, int stepsize) {772 var groupSizeVc = (RangeValueConfiguration)groupSizePc.ValueConfigurations.First(); 773 groupSizeVc.Optimize = true; 774 groupSizeVc.RangeConstraint.LowerBound = new IntValue(0); 775 groupSizeVc.RangeConstraint.UpperBound = new IntValue(10); 776 groupSizeVc.RangeConstraint.StepSize = new IntValue(1); 777 } 778 779 private static void ConfigurePopulationSize(ParameterizedValueConfiguration algorithmVc, int lower, int upper, int stepsize) { 771 780 var populationSizePc = algorithmVc.ParameterConfigurations.Where(x => x.Name == "PopulationSize").SingleOrDefault(); 772 781 populationSizePc.Optimize = true; 773 var populationSizeVc = populationSizePc.ValueConfigurations.First();782 var populationSizeVc = (RangeValueConfiguration)populationSizePc.ValueConfigurations.First(); 774 783 populationSizeVc.Optimize = true; 775 784 populationSizeVc.RangeConstraint.LowerBound = new IntValue(lower); … … 778 787 } 779 788 780 private static void ConfigureMutationRate( IValueConfiguration algorithmVc, double lower, double upper, double stepsize) {789 private static void ConfigureMutationRate(ParameterizedValueConfiguration algorithmVc, double lower, double upper, double stepsize) { 781 790 var mutationRatePc = algorithmVc.ParameterConfigurations.Where(x => x.Name == "MutationProbability").SingleOrDefault(); 782 791 mutationRatePc.Optimize = true; 783 var mutationRateVc = mutationRatePc.ValueConfigurations.First();792 var mutationRateVc = (RangeValueConfiguration)mutationRatePc.ValueConfigurations.First(); 784 793 mutationRateVc.Optimize = true; 785 794 mutationRateVc.RangeConstraint.LowerBound = new PercentValue(lower); … … 788 797 } 789 798 790 private static void ConfigureElites( IValueConfiguration algorithmVc, int from, int to, int stepSize) {799 private static void ConfigureElites(ParameterizedValueConfiguration algorithmVc, int from, int to, int stepSize) { 791 800 var elitesPc = algorithmVc.ParameterConfigurations.Where(x => x.Name == "Elites").SingleOrDefault(); 792 801 elitesPc.Optimize = true; 793 var elitesVc = elitesPc.ValueConfigurations.First();802 var elitesVc = (RangeValueConfiguration)elitesPc.ValueConfigurations.First(); 794 803 elitesVc.Optimize = true; 795 804 elitesVc.RangeConstraint.LowerBound = new IntValue(from); … … 855 864 var orderedRuns = rc.OrderBy(x => x.Results["AverageQualityNormalized"]); 856 865 857 TableBuilder tb = new TableBuilder("QNorm", "Qualities" , "PoSi", "MutRa", /*"Eli",*/ "SelOp", "MutOp", "NrSelSubScopes");866 TableBuilder tb = new TableBuilder("QNorm", "Qualities"/*, "PoSi"/* "MutRa", "Eli", "SelOp", "MutOp", "NrSelSubScopes"*/); 858 867 foreach (IRun run in orderedRuns) { 859 string selector;860 if (run.Parameters["Selector"] is TournamentSelector) {861 selector = string.Format("{0} ({1})", run.Parameters["Selector"].ToString(), ((TournamentSelector)run.Parameters["Selector"]).GroupSizeParameter.Value.ToString());862 } else {863 selector = string.Format("{0}", run.Parameters["Selector"].ToString());864 }868 //string selector; 869 //if (run.Parameters["Selector"] is TournamentSelector) { 870 // selector = string.Format("{0} ({1})", run.Parameters["Selector"].ToString(), ((TournamentSelector)run.Parameters["Selector"]).GroupSizeParameter.Value.ToString()); 871 //} else { 872 // selector = string.Format("{0}", run.Parameters["Selector"].ToString()); 873 //} 865 874 866 875 tb.AppendRow( 867 876 ((DoubleValue)run.Results["AverageQualityNormalized"]).Value.ToString("#0.0000"), 868 ((DoubleArray)run.Results["RunsAverageQualities"]).ToString() ,869 ((IntValue)run.Parameters["PopulationSize"]).Value.ToString(),870 ((DoubleValue)run.Parameters["MutationProbability"]).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"), 871 880 //((IntValue)run.Parameters["Elites"]).Value.ToString(), 872 Shorten(selector, 20), 873 Shorten(run.Parameters.ContainsKey("Mutator") ? run.Parameters["Mutator"].ToString() : "null", 40), 874 ((ISelector)run.Parameters["Selector"]).NumberOfSelectedSubScopesParameter.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() 884 ); 875 885 } 876 886 sb.AppendLine(tb.ToString()); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.sln
r5522 r5653 10 10 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F96C8DD1-9B68-4F2D-AD4F-1A174F596041}" 11 11 ProjectSection(SolutionItems) = preProject 12 Performance1.psess = Performance1.psess13 12 PreBuildEvent.cmd = PreBuildEvent.cmd 14 13 EndProjectSection -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3
- Property svn:ignore
-
old new 3 3 HeuristicLab.Problems.MetaOptimization.Views-3.3.csproj.user 4 4 HeuristicLabProblemsMetaOptimizationViewsPlugin.cs 5 *.vs10x
-
- Property svn:ignore
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/OptimizableView.cs
r5087 r5653 1 1 using System; 2 using System.Collections.Generic;3 using System.ComponentModel;4 using System.Drawing;5 using System.Data;6 using System.Linq;7 using System.Text;8 2 using HeuristicLab.Core.Views; 3 using HeuristicLab.Data; 9 4 using HeuristicLab.MainForm; 10 using HeuristicLab.Parameters;11 using HeuristicLab.Core;12 using HeuristicLab.Data;13 5 14 6 namespace HeuristicLab.Problems.MetaOptimization.Views.ValueConfigurationViews { … … 47 39 if (Content.Optimize) { 48 40 this.viewHost.ViewType = null; 49 if (Content is IParameterConfiguration) { 41 42 var pc = Content as IParameterConfiguration; 43 var vc = Content as IValueConfiguration; 44 45 if (pc != null) { 50 46 this.viewHost.Content = ((IParameterConfiguration)Content).ValueConfigurations; 51 } else if (Content is IValueConfiguration) { 52 if (Content.ActualValue.ValueDataType == typeof(IntValue) || 47 } else if(vc != null) { 48 var rvc = Content as RangeValueConfiguration; 49 if (rvc != null) { 50 if (Content.ActualValue.ValueDataType == typeof(IntValue) || 53 51 Content.ActualValue.ValueDataType == typeof(DoubleValue) || 54 52 Content.ActualValue.ValueDataType == typeof(PercentValue)) { 55 this.viewHost.ViewsLabelVisible = true; 56 this.viewHost.Content = ((IValueConfiguration)Content).RangeConstraint; 57 } else if(Content.ActualValue.ValueDataType == typeof(BoolValue)) { 58 this.viewHost.Content = null; // no configuration required 59 } else { 53 this.viewHost.ViewsLabelVisible = true; 54 this.viewHost.Content = rvc.RangeConstraint; 55 } else if (Content.ActualValue.ValueDataType == typeof(BoolValue)) { 56 this.viewHost.Content = null; // no configuration required 57 } 58 } 59 60 var pvc = Content as ParameterizedValueConfiguration; 61 if (pvc != null) { 60 62 this.viewHost.ViewsLabelVisible = false; 61 this.viewHost.Content = ((IValueConfiguration)Content).ParameterConfigurations;63 this.viewHost.Content = pvc.ParameterConfigurations; 62 64 } 63 65 } else { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ValueConfigurationViews/ValueConfigurationCheckedItemList.cs
r5277 r5653 1 1 using System; 2 using System.Collections.Generic;3 using System.ComponentModel;4 using System.Drawing;5 using System.Data;6 2 using System.Linq; 7 using System.Text; 3 using System.Windows.Forms; 4 using HeuristicLab.Collections; 5 using HeuristicLab.Core; 8 6 using HeuristicLab.Core.Views; 9 7 using HeuristicLab.MainForm; 10 using HeuristicLab.Core;11 using System.Windows.Forms;12 8 using HeuristicLab.PluginInfrastructure; 13 using HeuristicLab.Collections;14 9 15 10 namespace HeuristicLab.Problems.MetaOptimization.Views { … … 76 71 if (value is NullValue) { 77 72 return new NullValueConfiguration(); 73 } else if(value is IParameterizedItem) { 74 return new ParameterizedValueConfiguration(value, value.GetType()); 78 75 } else { 79 return new ValueConfiguration(value, value.GetType());80 } 76 return new RangeValueConfiguration(value, value.GetType()); 77 } 81 78 } 82 79 catch (Exception ex) { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
- Property svn:ignore
-
old new 3 3 obj 4 4 HeuristicLabProblemsMetaOptimizationPlugin.cs 5 *.vs10x
-
- Property svn:ignore
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Analyzers/ReferenceQualityAnalyzer.cs
r5359 r5653 68 68 DoubleArray referenceQualities = new DoubleArray(ProblemsParameter.ActualValue.Count); 69 69 for (int pi = 0; pi < ProblemsParameter.ActualValue.Count; pi++) { 70 referenceQualities[pi] = solutions. Select(x => x.AverageQualities[pi]).Min(); // todo: respect minimization / maximization70 referenceQualities[pi] = solutions.Where(x => x.AverageQualities != null).Select(x => x.AverageQualities[pi]).Min(); // todo: respect minimization / maximization 71 71 } 72 72 return referenceQualities; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Crossovers/ParameterConfigurationCrossover.cs
r5293 r5653 97 97 98 98 private static void Cross(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { 99 var vc = configuartion as IValueConfiguration;99 var vc = configuartion as RangeValueConfiguration; 100 100 var pc = configuartion as IParameterConfiguration; 101 101 if (vc != null) { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Manipulators/ParameterConfigurationManipulator.cs
r5303 r5653 1 using System ;2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;1 using System.Linq; 2 using HeuristicLab.Common; 3 using HeuristicLab.Core; 4 using HeuristicLab.Data; 5 5 using HeuristicLab.Operators; 6 6 using HeuristicLab.Optimization; 7 using HeuristicLab.Core;8 7 using HeuristicLab.Parameters; 9 using HeuristicLab.Common;10 8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 11 using HeuristicLab.Data;12 9 13 10 namespace HeuristicLab.Problems.MetaOptimization { … … 55 52 56 53 protected static void Mutate(IRandom random, IOptimizable configuration, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { 57 var vc = configuration as IValueConfiguration;54 var vc = configuration as RangeValueConfiguration; 58 55 var pc = configuration as IParameterConfiguration; 59 56 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterCombinationsEnumerator.cs
r5357 r5653 1 1 using System; 2 using System.Collections; 2 3 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 using System.Collections;6 4 using HeuristicLab.Core; 7 5 … … 25 23 if (!initialized) 26 24 throw new SystemException("Enumeration not started. Call MoveNext!"); 27 return Current; 25 return Current; 28 26 } 29 27 } … … 94 92 } 95 93 96 var vc = node as IValueConfiguration; 97 if (vc != null) { 98 if (vc.RangeConstraint != null) { 99 valueEnumerator = new EnumeratorCollectionEnumerator<IItem>(); 100 valueEnumerator.AddEnumerator(vc.RangeConstraint.GetCombinations().GetEnumerator()); 101 valueEnumerator.Reset(); 102 enumerators.Add(valueEnumerator); 103 } else { 104 foreach (var parameterConfiguration in vc.ParameterConfigurations) { 105 if (parameterConfiguration.Optimize) { 106 var enumerator = new ParameterCombinationsEnumerator(parameterConfiguration); 107 enumerator.Reset(); 108 enumerators.Add(enumerator); 109 } 94 var rangeVc = node as RangeValueConfiguration; 95 if (rangeVc != null) { 96 valueEnumerator = new EnumeratorCollectionEnumerator<IItem>(); 97 valueEnumerator.AddEnumerator(rangeVc.RangeConstraint.GetCombinations().GetEnumerator()); 98 valueEnumerator.Reset(); 99 enumerators.Add(valueEnumerator); 100 } 101 102 var parameterizedVc = node as ParameterizedValueConfiguration; 103 if (parameterizedVc != null) { 104 foreach (var parameterConfiguration in parameterizedVc.ParameterConfigurations) { 105 if (parameterConfiguration.Optimize) { 106 var enumerator = new ParameterCombinationsEnumerator(parameterConfiguration); 107 enumerator.Reset(); 108 enumerators.Add(enumerator); 110 109 } 111 enumerators.Reverse(); // this makes the list of combinations better readable112 110 } 111 enumerators.Reverse(); // this makes the list of combinations better readable 113 112 } 114 113 } … … 129 128 } 130 129 131 public void Dispose() { 130 public void Dispose() { } 132 131 133 132 public T Current { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurationTree.cs
r5576 r5653 1 1 using System; 2 using System.Collections; 2 3 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 4 using HeuristicLab.Common; 5 5 using HeuristicLab.Core; 6 using HeuristicLab.Common; 6 using HeuristicLab.Data; 7 using HeuristicLab.Optimization; 7 8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 using HeuristicLab.Optimization;9 using HeuristicLab.Data;10 using System.Collections;11 9 12 10 namespace HeuristicLab.Problems.MetaOptimization { 13 11 // todo: storable, name, descr, ... 14 12 [StorableClass] 15 public class ParameterConfigurationTree : ValueConfiguration, IEnumerable {13 public class ParameterConfigurationTree : ParameterizedValueConfiguration, IEnumerable { 16 14 17 15 [Storable] … … 189 187 public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions) { 190 188 Experiment experiment = new Experiment(); 191 foreach ( IValueConfiguration combination in this) {189 foreach (ParameterizedValueConfiguration combination in this) { 192 190 IAlgorithm clonedAlg = (IAlgorithm)algorithm.Clone(); 193 191 clonedAlg.Name = combination.ParameterInfoString; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5522 r5653 2 2 using System.Collections; 3 3 using System.Collections.Generic; 4 using System.Drawing; 4 5 using System.Linq; 6 using System.Text; 7 using HeuristicLab.Collections; 5 8 using HeuristicLab.Common; 6 9 using HeuristicLab.Core; … … 9 12 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 10 13 using HeuristicLab.PluginInfrastructure; 11 using System.Text;12 using System.Reflection;13 using HeuristicLab.Optimization;14 using HeuristicLab.Collections;15 using System.Drawing;16 14 17 15 namespace HeuristicLab.Problems.MetaOptimization { … … 147 145 this.ActualValue = new ConstrainedValue( 148 146 valueParameter.Value != null ? valueParameter.Value : null, // don't clone here; otherwise settings of a non-optimized ValueParameter will not be synchronized with the ConstrainedValue 149 valueParameter.DataType, 150 this.validValues != null ? new ItemSet<IItem>(this.validValues) : CreateValidValues(), 147 valueParameter.DataType, 148 this.validValues != null ? new ItemSet<IItem>(this.validValues) : CreateValidValues(), 151 149 this.IsNullable); 152 150 if (Optimize) { … … 200 198 if (this.ActualValue != null) this.ActualValue.ToStringChanged -= new EventHandler(ActualValue_ToStringChanged); 201 199 } 202 200 203 201 private void PopulateValueConfigurations() { 204 202 foreach (Type t in this.validTypes) { … … 212 210 val = CreateItem(t); 213 211 } 214 this.ValueConfigurations.Add(new ValueConfiguration(val, val.GetType()), true); 212 if (val is IParameterizedItem) { 213 this.ValueConfigurations.Add(new ParameterizedValueConfiguration(val, val.GetType()), true); 214 } else { 215 this.ValueConfigurations.Add(new RangeValueConfiguration(val, val.GetType()), true); 216 } 215 217 } 216 218 } … … 224 226 // return only one type for ValueTypeValues<> (Int, Double, Percent, Bool). Otherwise 2 types would be returned for DoubleValue (PercentValue which is derived) 225 227 if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), parameter.DataType)) 226 return new List<Type> { parameter.DataType }; 227 228 return new List<Type> { parameter.DataType }; 229 228 230 if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) { 229 231 // use existing validvalues if known … … 252 254 if (type == typeof(NullValue)) 253 255 return new NullValue(); 254 256 255 257 // copy value from ValidValues; this ensures that previously set ActualNames for a type are kept 256 258 IItem value = this.validValues.Where(v => v.GetType() == type).SingleOrDefault(); 257 if (value != null) 259 if (value != null) 258 260 return value; 259 261 … … 404 406 if (Optimize) { 405 407 if (this.ActualValue.Value is IParameterizedItem) { 406 this.ValueConfigurations[actualValueConfigurationIndex].Parameterize((IParameterizedItem)this.ActualValue.Value);408 ((ParameterizedValueConfiguration)this.ValueConfigurations[actualValueConfigurationIndex]).Parameterize((IParameterizedItem)this.ActualValue.Value); 407 409 } 408 410 } 409 411 var clonedValue = this.ActualValue.Value != null ? (IItem)this.ActualValue.Value.Clone() : null; 410 AdaptValidValues(parameter, clonedValue);412 if(clonedValue != null) AdaptValidValues(parameter, clonedValue); 411 413 parameter.Value = clonedValue; 412 414 } … … 433 435 foreach (var vc in this.ValueConfigurations) { 434 436 if (this.ValueConfigurations.ItemChecked(vc)) { 435 vc.Randomize(random);437 if (vc.Optimize) vc.Randomize(random); 436 438 } 437 439 } … … 447 449 foreach (var vc in this.ValueConfigurations) { 448 450 if (this.ValueConfigurations.ItemChecked(vc)) { 449 vc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator);451 if (vc.Optimize) vc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator); 450 452 } 451 453 } … … 459 461 for (int i = 0; i < this.ValueConfigurations.Count; i++) { 460 462 if (this.ValueConfigurations.ItemChecked(this.ValueConfigurations[i])) { 461 this.ValueConfigurations[i].Cross(random, otherPc.ValueConfigurations[i], cross, intValueCrossover, doubleValueCrossover);463 if (this.ValueConfigurations[i].Optimize) this.ValueConfigurations[i].Cross(random, otherPc.ValueConfigurations[i], cross, intValueCrossover, doubleValueCrossover); 462 464 } 463 465 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/NullValueConfiguration.cs
r5112 r5653 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 using System.Collections.Generic; 2 using HeuristicLab.Common; 5 3 using HeuristicLab.Core; 6 4 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 7 using HeuristicLab.Common;8 5 9 6 namespace HeuristicLab.Problems.MetaOptimization { … … 12 9 13 10 public NullValueConfiguration() { 14 this.ParameterConfigurations = new ItemList<IParameterConfiguration>();15 11 this.ActualValue = new ConstrainedValue(null, null, null, true); 16 12 this.IsOptimizable = false; … … 28 24 return "null"; 29 25 } 26 27 public override void Randomize(IRandom random) { } 28 29 public override void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { } 30 31 public override void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { } 32 33 public override double CalculateSimilarity(IOptimizable optimizable) { 34 return 1.0; 35 } 36 37 public override string ParameterInfoString { 38 get { return "null"; } 39 } 40 41 public override void CollectOptimizedParameterNames(List<string> parameterNames, string prefix) { } 42 43 public override List<IOptimizable> GetAllOptimizables() { 44 return new List<IOptimizable>(); 45 } 30 46 } 31 47 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5522 r5653 1 1 using System; 2 using System.Collections.Generic; 3 using System.Drawing; 2 4 using System.Linq; 3 5 using HeuristicLab.Common; 4 6 using HeuristicLab.Core; 5 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 6 using HeuristicLab.Data;7 using System.Drawing;8 using HeuristicLab.Encodings.RealVectorEncoding;9 using HeuristicLab.Encodings.IntegerVectorEncoding;10 8 using HeuristicLab.PluginInfrastructure; 11 using System.Collections.Generic;12 using System.Text;13 9 14 10 namespace HeuristicLab.Problems.MetaOptimization { 15 11 // TODO: ItemName/Descr, storability 16 12 [StorableClass] 17 public class ValueConfiguration : NamedItem, IValueConfiguration {13 public abstract class ValueConfiguration : NamedItem, IValueConfiguration { 18 14 public override bool CanChangeName { 19 15 get { return true; } … … 38 34 [Storable] 39 35 protected bool optimize; 40 public bool Optimize {36 public virtual bool Optimize { 41 37 get { return optimize; } 42 38 set { 43 39 if (optimize != value) { 44 40 optimize = value; 45 if (optimize) {46 ClearParameterConfigurations();47 if (this.actualValue.Value is IParameterizedNamedItem) PopulateParameterConfigurations(this.actualValue.Value as IParameterizedNamedItem);48 } else {49 ClearParameterConfigurations();50 }51 41 OnOptimizeChanged(); 52 42 OnToStringChanged(); 53 43 } 54 44 } 55 }56 57 [Storable]58 protected IItemCollection<IParameterConfiguration> parameterConfigurations = new ItemCollection<IParameterConfiguration>();59 public IItemCollection<IParameterConfiguration> ParameterConfigurations {60 get { return new ReadOnlyItemCollection<IParameterConfiguration>(this.parameterConfigurations); }61 protected set { this.parameterConfigurations = value; }62 45 } 63 46 … … 69 52 if (this.actualValue != value) { 70 53 DeregisterActualValueEvents(); 71 ClearParameterConfigurations();72 54 this.actualValue = value; 73 if (this.actualValue.Value is IParameterizedNamedItem) PopulateParameterConfigurations(this.actualValue.Value as IParameterizedNamedItem);74 55 OnValueChanged(); 75 56 OnToStringChanged(); 76 RegisterActualValueEvents();77 }78 }79 }80 81 [Storable]82 protected IRange rangeConstraint;83 public IRange RangeConstraint {84 get { return rangeConstraint; }85 private set {86 if (rangeConstraint != value) {87 DeregisterRangeConstraintEvents();88 rangeConstraint = value;89 57 RegisterActualValueEvents(); 90 58 } … … 106 74 #region Constructors and Cloning 107 75 public ValueConfiguration(IItem value, Type valueDataType) { 108 this.ParameterConfigurations = new ItemList<IParameterConfiguration>();109 76 var validTypes = ApplicationManager.Manager.GetTypes(valueDataType).OrderBy(x => x.Name).ToArray(); 110 77 this.ActualValue = new ConstrainedValue(value, valueDataType, new ItemSet<IItem> { value }, false); 111 78 this.IsOptimizable = true; 112 if (actualValue.ValueDataType == typeof(IntValue)) {113 RangeConstraint = new IntValueRange(new IntValue(0), (IntValue)value, new IntValue(1));114 } else if (actualValue.ValueDataType == typeof(DoubleValue)) {115 RangeConstraint = new DoubleValueRange(new DoubleValue(0), (DoubleValue)value, new DoubleValue(0.01));116 } else if (actualValue.ValueDataType == typeof(PercentValue)) {117 RangeConstraint = new PercentValueRange(new PercentValue(0), new PercentValue(1), new PercentValue(0.01));118 } else if (actualValue.ValueDataType == typeof(BoolValue)) {119 this.IsOptimizable = false; // there is nothing to configure for bools120 } else {121 RangeConstraint = null;122 }123 79 } 124 80 … … 128 84 protected ValueConfiguration(ValueConfiguration original, Cloner cloner) 129 85 : base(original, cloner) { 130 this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations);131 86 this.actualValue = cloner.Clone(original.ActualValue); 132 this.rangeConstraint = cloner.Clone(original.RangeConstraint);133 87 this.isOptimizable = original.isOptimizable; 134 88 this.optimize = original.optimize; 135 89 this.number = original.number; 136 90 RegisterActualValueEvents(); 137 RegisterRangeConstraintEvents();138 }139 public override IDeepCloneable Clone(Cloner cloner) {140 return new ValueConfiguration(this, cloner);141 }142 [StorableHook(HookType.AfterDeserialization)]143 private void AfterDeserialization() {144 RegisterRangeConstraintEvents();145 91 } 146 92 #endregion 147 93 148 protected virtual void PopulateParameterConfigurations(IParameterizedNamedItem parameterizedItem) {149 foreach (var childParameter in parameterizedItem.Parameters) {150 var pc = ParameterConfiguration.Create(parameterizedItem, childParameter);151 if (pc != null) this.parameterConfigurations.Add(pc);152 }153 }154 protected virtual void ClearParameterConfigurations() {155 parameterConfigurations.Clear();156 }157 158 private void RegisterRangeConstraintEvents() {159 if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged);160 }161 private void DeregisterRangeConstraintEvents() {162 if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged -= new EventHandler(RangeConstraint_ToStringChanged);163 }164 94 private void RegisterActualValueEvents() { 165 95 if (this.actualValue != null) this.actualValue.ToStringChanged += new EventHandler(actualValue_ToStringChanged); … … 170 100 171 101 #region Events 172 void actualValue_ToStringChanged(object sender, EventArgs e) { 173 OnToStringChanged(); 174 } 175 void RangeConstraint_ToStringChanged(object sender, EventArgs e) { 102 private void actualValue_ToStringChanged(object sender, EventArgs e) { 176 103 OnToStringChanged(); 177 104 } … … 212 139 #endregion 213 140 214 public override string ToString() {215 if (ActualValue != null && ActualValue.Value != null) {216 string name = NumberedName;217 218 if (ActualValue.Value is IParameterizedItem) {219 if (Optimize) {220 return string.Format("{0} (Optimize)", name);221 } else {222 return string.Format("{0}", name);223 }224 } else {225 if (Optimize) {226 return string.Format("{0} (Optimize: {1})", name, RangeConstraint);227 } else {228 return string.Format("{0}: {1}", name, ActualValue.Value);229 }230 }231 } else {232 return base.ToString();233 }234 }235 236 141 public string NumberedName { 237 142 get { … … 244 149 } 245 150 246 public string ParameterInfoString { 247 get { 248 StringBuilder sb = new StringBuilder(); 249 if (this.Optimize && this.ParameterConfigurations.Count > 0) { 250 var parameterInfos = new List<string>(); 251 foreach (var pc in this.ParameterConfigurations) { 252 if (pc.Optimize) parameterInfos.Add(pc.ParameterInfoString); 253 } 254 sb.Append(string.Join(", ", parameterInfos.ToArray())); 255 } 256 return sb.ToString(); 257 } 258 } 259 260 public virtual void Parameterize(IParameterizedItem item) { 261 foreach (IParameterConfiguration pc in this.ParameterConfigurations) { 262 pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]); 263 } 264 } 265 266 public void Randomize(IRandom random) { 267 if (Optimize) { 268 if (rangeConstraint != null) { 269 this.actualValue.Value = rangeConstraint.GetRandomValue(random); 270 } else { 271 foreach (IParameterConfiguration pc in this.ParameterConfigurations) { 272 pc.Randomize(random); 273 } 274 } 275 } 276 } 277 278 public void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { 279 if (Optimize) { 280 if (rangeConstraint != null) { 281 mutate(random, this, intValueManipulator, doubleValueManipulator); 282 } else { 283 foreach (IParameterConfiguration pc in this.ParameterConfigurations) { 284 pc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator); 285 } 286 } 287 } 288 } 289 290 public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { 291 if (Optimize) { 292 if (rangeConstraint != null) { 293 cross(random, this, other, intValueCrossover, doubleValueCrossover); 294 } else { 295 IValueConfiguration otherVc = (IValueConfiguration)other; 296 for (int i = 0; i < this.ParameterConfigurations.Count; i++) { 297 this.ParameterConfigurations.ElementAt(i).Cross(random, otherVc.ParameterConfigurations.ElementAt(i), cross, intValueCrossover, doubleValueCrossover); 298 } 299 } 300 } 301 } 302 303 public List<IOptimizable> GetAllOptimizables() { 304 var list = new List<IOptimizable>(); 305 foreach (var pc in ParameterConfigurations) { 306 if (pc.Optimize) { 307 if (pc.ValueConfigurations.CheckedItems.Count() > 1) list.Add(pc); // only add if there are more than 1 choices. otherwise it makes no sense to optimize which VC is selected 308 list.AddRange(pc.GetAllOptimizables()); 309 } 310 } 311 return list; 312 } 313 314 public void CollectOptimizedParameterNames(List<string> parameterNames, string prefix) { 315 foreach (var pc in ParameterConfigurations) { 316 if (pc.Optimize) { 317 parameterNames.Add(prefix + pc.ParameterName); 318 pc.CollectOptimizedParameterNames(parameterNames, prefix + pc.ParameterName + "."); 319 } 320 } 321 } 322 323 public IEnumerable<string> GetOptimizedParameterNames() { 324 var list = new List<string>(); 325 this.CollectOptimizedParameterNames(list, ""); 326 return list; 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 } 151 public abstract void Randomize(IRandom random); 152 public abstract void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator); 153 public abstract void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover); 154 public abstract double CalculateSimilarity(IOptimizable optimizable); 155 public abstract string ParameterInfoString { get; } 156 public abstract void CollectOptimizedParameterNames(List<string> parameterNames, string prefix); 157 public abstract List<IOptimizable> GetAllOptimizables(); 345 158 } 346 159 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj
r5576 r5653 143 143 <Compile Include="Analyzers\PMOPopulationDiversityAnalyzer.cs" /> 144 144 <Compile Include="ConstrainedTypeValue.cs" /> 145 <Compile Include="Encoding\ValueConfigurations\RangeValueConfiguration.cs" /> 146 <Compile Include="Encoding\ValueConfigurations\ParameterizedValueConfiguration.cs" /> 147 <Compile Include="Evaluators\AlgorithmEvaluator.cs" /> 148 <Compile Include="Evaluators\AlgorithmRunsAnalyzer.cs" /> 149 <Compile Include="Evaluators\AlgorithmSubScopesCreator.cs" /> 150 <Compile Include="Evaluators\PMOEvaluator.cs" /> 145 151 <Compile Include="MetaOptimizationUtil.cs" /> 146 152 <Compile Include="Operators\Crossovers\MultiIntValueCrossover.cs" /> … … 167 173 <Compile Include="Encoding\ValueConfigurations\ValueConfiguration.cs" /> 168 174 <Compile Include="Encoding\ValueConfigurations\CheckedValueConfigurationCollection.cs" /> 169 <Compile Include=" Evaluators\AlgorithmExecutor.cs" />175 <Compile Include="AlgorithmExecutor.cs" /> 170 176 <Compile Include="Interfaces\IParameterConfigurationCrossover.cs" /> 171 177 <Compile Include="Interfaces\ICheckedValueConfigurationCollection.cs" /> … … 185 191 <Compile Include="Interfaces\IParameterConfigurationOperator.cs" /> 186 192 <Compile Include="Interfaces\IRange.cs" /> 187 <Compile Include="Evaluators\ParameterConfigurationEvaluator.cs" />188 193 <Compile Include="Interfaces\IParameterConfigurationEvaluator.cs" /> 189 194 <Compile Include="Interfaces\IParameterConfiguration.cs" /> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs
r5522 r5653 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 3 using HeuristicLab.Core; 6 using HeuristicLab.Common;7 4 8 5 namespace HeuristicLab.Problems.MetaOptimization { -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IValueConfiguration.cs
r5359 r5653 1 1 using System; 2 2 using HeuristicLab.Core; 3 using HeuristicLab.Data;4 using System.Collections.Generic;5 3 6 4 namespace HeuristicLab.Problems.MetaOptimization { 7 5 public interface IValueConfiguration : IOptimizable, IItem { 8 IItemCollection<IParameterConfiguration> ParameterConfigurations { get; }9 IRange RangeConstraint { get; }10 6 int Number { get; set; } // if larger than 0 it will be visible in the name. this can be used when multiple ValueConfiguration with the same name exist in a list 11 7 string NumberedName { get; } … … 13 9 event EventHandler ValueChanged; 14 10 15 void Parameterize(IParameterizedItem item);11 //void Parameterize(IParameterizedItem item); 16 12 } 17 13 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r5576 r5653 137 137 Maximization = new BoolValue(false); 138 138 SolutionCreator = new RandomParameterConfigurationCreator(); 139 Evaluator = new P arameterConfigurationEvaluator();139 Evaluator = new PMOEvaluator(); 140 140 141 141 InitializeOperators(); … … 186 186 } 187 187 private void ParameterizeEvaluator() { 188 ((P arameterConfigurationEvaluator)Evaluator).ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName;188 ((PMOEvaluator)Evaluator).ParameterConfigurationParameter.ActualName = ((RandomParameterConfigurationCreator)SolutionCreator).ParameterConfigurationParameter.ActualName; 189 189 } 190 190 private void ParameterizeAnalyzer() { … … 246 246 IAlgorithm instance = (IAlgorithm)Activator.CreateInstance(AlgorithmType.Value); 247 247 this.ProblemType.ValidTypes = ApplicationManager.Manager.GetTypes(instance.ProblemType, true).ToList(); 248 this.ProblemType.Value = this.ProblemType.ValidTypes. Where(t => t != typeof(MetaOptimizationProblem)).FirstOrDefault();248 this.ProblemType.Value = this.ProblemType.ValidTypes.SingleOrDefault(t => t == typeof(SingleObjectiveTestFunctionProblem)) ?? this.ProblemType.ValidTypes.Where(t => t != typeof(MetaOptimizationProblem)).FirstOrDefault(); 249 249 if (ProblemType.Value != null) { 250 250 ParameterConfigurationTreeParameter.ActualValue = new ParameterConfigurationTree(CreateAlgorithm(AlgorithmType.Value, ProblemType.Value)); 251 Problems.Add((IProblem)Activator.CreateInstance(this.ProblemType.Value)); 251 252 } else { 252 253 ParameterConfigurationTreeParameter.ActualValue = null;
Note: See TracChangeset
for help on using the changeset viewer.