Changeset 7215 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3
- Timestamp:
- 12/20/11 13:54:57 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure
- Property svn:ignore
-
old new 4 4 *.suo 5 5 *.vsp 6 Doxygen 6 7 Google.ProtocolBuffers-0.9.1.dll 7 8 HeuristicLab 3.3.5.1.ReSharper.user 8 9 HeuristicLab 3.3.6.0.ReSharper.user 9 10 HeuristicLab.4.5.resharper.user 11 HeuristicLab.ExtLibs.6.0.ReSharper.user 10 12 HeuristicLab.resharper.user 11 13 ProtoGen.exe … … 16 18 bin 17 19 protoc.exe 18 HeuristicLab.ExtLibs.6.0.ReSharper.user19 Doxygen
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs
r5809 r7215 261 261 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 262 262 #endregion 263 263 264 264 Initialize(); 265 265 } … … 619 619 IslandAnalyzer.Operators.Clear(); 620 620 Analyzer.Operators.Clear(); 621 IslandAnalyzer.Operators.Add(islandQualityAnalyzer );622 IslandAnalyzer.Operators.Add(islandSelectionPressureAnalyzer );621 IslandAnalyzer.Operators.Add(islandQualityAnalyzer, islandQualityAnalyzer.EnabledByDefault); 622 IslandAnalyzer.Operators.Add(islandSelectionPressureAnalyzer, islandSelectionPressureAnalyzer.EnabledByDefault); 623 623 if (Problem != null) { 624 624 foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) { 625 625 foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>()) 626 626 param.Depth = 2; 627 Analyzer.Operators.Add(analyzer );627 Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 628 628 } 629 629 } 630 Analyzer.Operators.Add(qualityAnalyzer); 631 Analyzer.Operators.Add(selectionPressureAnalyzer); 632 Analyzer.Operators.Add(successfulOffspringAnalyzer); 633 Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false); 630 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 631 Analyzer.Operators.Add(selectionPressureAnalyzer, selectionPressureAnalyzer.EnabledByDefault); 632 Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault); 634 633 } 635 634 private IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs
r5809 r7215 209 209 successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); 210 210 #endregion 211 211 212 212 Initialize(); 213 213 } … … 470 470 foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>()) 471 471 param.Depth = 1; 472 Analyzer.Operators.Add(analyzer );472 Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 473 473 } 474 474 } 475 Analyzer.Operators.Add(qualityAnalyzer); 476 Analyzer.Operators.Add(selectionPressureAnalyzer); 477 Analyzer.Operators.Add(successfulOffspringAnalyzer); 478 Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false); 475 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 476 Analyzer.Operators.Add(selectionPressureAnalyzer, selectionPressureAnalyzer.EnabledByDefault); 477 Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault); 479 478 } 480 479 private OffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs
r5809 r7215 557 557 VillageAnalyzer.Operators.Clear(); 558 558 Analyzer.Operators.Clear(); 559 VillageAnalyzer.Operators.Add(villageQualityAnalyzer );560 VillageAnalyzer.Operators.Add(villageSelectionPressureAnalyzer );559 VillageAnalyzer.Operators.Add(villageQualityAnalyzer, villageQualityAnalyzer.EnabledByDefault); 560 VillageAnalyzer.Operators.Add(villageSelectionPressureAnalyzer, villageSelectionPressureAnalyzer.EnabledByDefault); 561 561 if (Problem != null) { 562 562 foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) { 563 563 foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>()) 564 564 param.Depth = 2; 565 Analyzer.Operators.Add(analyzer );565 Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 566 566 } 567 567 } 568 Analyzer.Operators.Add(qualityAnalyzer); 569 Analyzer.Operators.Add(selectionPressureAnalyzer); 570 Analyzer.Operators.Add(successfulOffspringAnalyzer); 571 Analyzer.Operators.SetItemCheckedState(successfulOffspringAnalyzer, false); 568 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 569 Analyzer.Operators.Add(selectionPressureAnalyzer, selectionPressureAnalyzer.EnabledByDefault); 570 Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault); 572 571 } 573 572 private SASEGASAMainLoop FindMainLoop(IOperator start) { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SuccessfulOffspringAnalysis/SuccessfulOffspringAnalyzer.cs
r5725 r7215 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Text; 25 using HeuristicLab.Analysis; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HeuristicLab. Persistence.Default.CompositeSerializers.Storable;28 using HeuristicLab.Data; 28 29 using HeuristicLab.Operators; 29 30 using HeuristicLab.Optimization; 30 using HeuristicLab.Common;31 31 using HeuristicLab.Parameters; 32 using HeuristicLab.Data; 33 using HeuristicLab.Analysis; 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 33 35 34 namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm { … … 40 39 [StorableClass] 41 40 public sealed class SuccessfulOffspringAnalyzer : SingleSuccessorOperator, IAnalyzer { 41 public bool EnabledByDefault { 42 get { return false; } 43 } 44 42 45 public ValueParameter<StringValue> SuccessfulOffspringFlagParameter { 43 46 get { return (ValueParameter<StringValue>)Parameters["SuccessfulOffspringFlag"]; } … … 53 56 54 57 public LookupParameter<ResultCollection> SuccessfulOffspringAnalysisParameter { 55 get { return (LookupParameter<ResultCollection>)Parameters["SuccessfulOffspringAnalysis"]; 58 get { return (LookupParameter<ResultCollection>)Parameters["SuccessfulOffspringAnalysis"]; } 56 59 } 57 60 … … 63 66 get { return (ValueParameter<IntValue>)Parameters["Depth"]; } 64 67 } 65 68 66 69 public override IDeepCloneable Clone(Cloner cloner) { 67 70 return new SuccessfulOffspringAnalyzer(this, cloner); 68 } 71 } 69 72 [StorableConstructor] 70 73 private SuccessfulOffspringAnalyzer(bool deserializing) : base(deserializing) { } … … 72 75 public SuccessfulOffspringAnalyzer() 73 76 : base() { 74 75 76 77 Parameters.Add(new LookupParameter<IntValue>("Generations", "The current number of generations."));78 79 77 Parameters.Add(new ValueParameter<StringValue>("SuccessfulOffspringFlag", "The name of the flag which indicates if the individual was successful.", new StringValue("SuccessfulOffspring"))); 78 Parameters.Add(new ValueParameter<ItemCollection<StringValue>>("CollectedValues", "The properties of the successful offspring that should be collected.", new ItemCollection<StringValue>())); 79 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the succedd progress analysis results should be stored.")); 80 Parameters.Add(new LookupParameter<IntValue>("Generations", "The current number of generations.")); 81 Parameters.Add(new LookupParameter<ResultCollection>("SuccessfulOffspringAnalysis", "The successful offspring analysis which is created.")); 82 Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1))); 80 83 } 81 84 … … 88 91 89 92 ItemCollection<StringValue> collectedValues = CollectedValuesParameter.Value; 90 91 92 93 94 95 96 if (child.Variables.ContainsKey(collected.Value) &&97 child.Variables.ContainsKey(successfulOffspringFlag) &&98 99 100 93 foreach (StringValue collected in collectedValues) { 94 //collect the values of the successful offspring 95 Dictionary<String, int> counts = new Dictionary<String, int>(); 96 for (int i = 0; i < scopes.Count; i++) { 97 IScope child = scopes[i]; 98 string successfulOffspringFlag = SuccessfulOffspringFlagParameter.Value.Value; 99 if (child.Variables.ContainsKey(collected.Value) && 100 child.Variables.ContainsKey(successfulOffspringFlag) && 101 (child.Variables[successfulOffspringFlag].Value is BoolValue) && 102 (child.Variables[successfulOffspringFlag].Value as BoolValue).Value) { 103 String key = child.Variables[collected.Value].Value.ToString(); 101 104 102 if (!counts.ContainsKey(key)) 103 counts.Add(key, 1); 104 else 105 counts[key]++; 106 } 105 if (!counts.ContainsKey(key)) 106 counts.Add(key, 1); 107 else 108 counts[key]++; 109 } 110 } 111 112 //create a data table containing the collected values 113 ResultCollection successfulOffspringAnalysis; 114 115 if (SuccessfulOffspringAnalysisParameter.ActualValue == null) { 116 successfulOffspringAnalysis = new ResultCollection(); 117 SuccessfulOffspringAnalysisParameter.ActualValue = successfulOffspringAnalysis; 118 } else { 119 successfulOffspringAnalysis = SuccessfulOffspringAnalysisParameter.ActualValue; 120 } 121 122 string resultKey = "SuccessfulOffspringAnalyzer Results"; 123 if (!results.ContainsKey(resultKey)) { 124 results.Add(new Result(resultKey, successfulOffspringAnalysis)); 125 } else { 126 results[resultKey].Value = successfulOffspringAnalysis; 127 } 128 129 DataTable successProgressAnalysis; 130 if (!successfulOffspringAnalysis.ContainsKey(collected.Value)) { 131 successProgressAnalysis = new DataTable(); 132 successProgressAnalysis.Name = collected.Value; 133 successfulOffspringAnalysis.Add(new Result(collected.Value, successProgressAnalysis)); 134 } else { 135 successProgressAnalysis = successfulOffspringAnalysis[collected.Value].Value as DataTable; 136 } 137 138 int successfulCount = 0; 139 foreach (string key in counts.Keys) { 140 successfulCount += counts[key]; 141 } 142 143 foreach (String value in counts.Keys) { 144 DataRow row; 145 if (!successProgressAnalysis.Rows.ContainsKey(value)) { 146 row = new DataRow(value); 147 int iterations = GenerationsParameter.ActualValue.Value; 148 149 //fill up all values seen the first time 150 for (int i = 1; i < iterations; i++) 151 row.Values.Add(0); 152 153 successProgressAnalysis.Rows.Add(row); 154 } else { 155 row = successProgressAnalysis.Rows[value]; 107 156 } 108 157 109 //create a data table containing the collected values110 ResultCollection successfulOffspringAnalysis;158 row.Values.Add(counts[value] / (double)successfulCount); 159 } 111 160 112 if (SuccessfulOffspringAnalysisParameter.ActualValue == null) { 113 successfulOffspringAnalysis = new ResultCollection(); 114 SuccessfulOffspringAnalysisParameter.ActualValue = successfulOffspringAnalysis; 115 } else { 116 successfulOffspringAnalysis = SuccessfulOffspringAnalysisParameter.ActualValue; 117 } 118 119 string resultKey = "SuccessfulOffspringAnalyzer Results"; 120 if (!results.ContainsKey(resultKey)) { 121 results.Add(new Result(resultKey, successfulOffspringAnalysis)); 122 } else { 123 results[resultKey].Value = successfulOffspringAnalysis; 124 } 125 126 DataTable successProgressAnalysis; 127 if (!successfulOffspringAnalysis.ContainsKey(collected.Value)) { 128 successProgressAnalysis = new DataTable(); 129 successProgressAnalysis.Name = collected.Value; 130 successfulOffspringAnalysis.Add(new Result(collected.Value, successProgressAnalysis)); 131 } else { 132 successProgressAnalysis = successfulOffspringAnalysis[collected.Value].Value as DataTable; 133 } 134 135 int successfulCount = 0; 136 foreach (string key in counts.Keys) { 137 successfulCount += counts[key]; 138 } 139 140 foreach(String value in counts.Keys) { 141 DataRow row; 142 if (!successProgressAnalysis.Rows.ContainsKey(value)) { 143 row = new DataRow(value); 144 int iterations = GenerationsParameter.ActualValue.Value; 145 146 //fill up all values seen the first time 147 for (int i = 1; i < iterations; i++) 148 row.Values.Add(0); 149 150 successProgressAnalysis.Rows.Add(row); 151 } else { 152 row = successProgressAnalysis.Rows[value]; 153 } 154 155 row.Values.Add(counts[value] / (double)successfulCount); 156 } 157 158 //fill up all values that are not present in the current generation 159 foreach (DataRow row in successProgressAnalysis.Rows) { 160 if (!counts.ContainsKey(row.Name)) 161 row.Values.Add(0); 162 } 163 } 161 //fill up all values that are not present in the current generation 162 foreach (DataRow row in successProgressAnalysis.Rows) { 163 if (!counts.ContainsKey(row.Name)) 164 row.Values.Add(0); 165 } 166 } 164 167 165 168 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.