- Timestamp:
- 04/22/10 16:34:44 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASAMainLoop.cs
r3479 r3489 155 155 QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator(); 156 156 ResultsCollector resultsCollector = new ResultsCollector(); 157 Assigner fixedReunificationStepConditionInitializer = new Assigner(); 157 158 UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor(); 159 // MAINLOOP 158 160 OffspringSelectionGeneticAlgorithmMainLoop mainLoop = new OffspringSelectionGeneticAlgorithmMainLoop(); 159 UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor();161 // MAINLOOP 160 162 Comparator sasegasaGenVillageGenComparator = new Comparator(); 161 163 ConditionalBranch sasegasaGenerationsUpdateBranch = new ConditionalBranch(); 162 164 Assigner sasegasaGenerationsUpdater = new Assigner(); 163 ConditionalBranch villageMaximumGenerationsConditionalBranch = new ConditionalBranch(); 165 ConditionalBranch villageMaximumGenerationsConditionalBranch1 = new ConditionalBranch(); 166 Assigner fixedReunificationStepConditionUpdater = new Assigner(); 167 ResultsCollector sasegasaGenerationsCollector = new ResultsCollector(); 168 UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor(); 169 ConditionalBranch villageMaximumGenerationsConditionalBranch2 = new ConditionalBranch(); 170 Assigner villageMaximumGenerationsToGenerationsAssigner = new Assigner(); 164 171 IntCounter villageMaximumGenerationsCounter = new IntCounter(); 172 DataTableValuesCollector selPressValuesCollector2 = new DataTableValuesCollector(); 165 173 Comparator villageCountComparator = new Comparator(); 166 174 ConditionalBranch villageTerminationCondition0 = new ConditionalBranch(); … … 172 180 BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator3 = new BestAverageWorstQualityCalculator(); 173 181 DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector(); 174 DataTableValuesCollector selPressValuesCollector2 = new DataTableValuesCollector();175 182 QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator(); 176 183 ConditionalBranch villagesTerminationCondition = new ConditionalBranch(); … … 240 247 resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("VillageResults", "Result set for each village")); 241 248 resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name; 249 250 fixedReunificationStepConditionInitializer.LeftSideParameter.ActualName = "PerformFixedReunification"; 251 fixedReunificationStepConditionInitializer.RightSideParameter.Value = new BoolValue(false); 242 252 243 253 mainLoop.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name; … … 273 283 sasegasaGenerationsUpdater.RightSideParameter.ActualName = "Generations"; 274 284 275 // check if the village has terminated due to reaching maximum generations (in that case we need to increase maximum generations by the migration interval) 276 villageMaximumGenerationsConditionalBranch.ConditionParameter.ActualName = "TerminateMaximumGenerations"; 277 278 // if the village terminated because of maximum generations (inter-migration period) its maximum generations are updated 285 // check if the village has terminated due to reaching maximum generations (in that case we need to increase in each village the maximum generations by the migration interval) 286 villageMaximumGenerationsConditionalBranch1.ConditionParameter.ActualName = "TerminateMaximumGenerations"; 287 288 fixedReunificationStepConditionUpdater.LeftSideParameter.ActualName = "PerformFixedReunification"; 289 fixedReunificationStepConditionUpdater.RightSideParameter.Value = new BoolValue(true); 290 291 sasegasaGenerationsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations", null, "SASEGASAGenerations")); 292 293 villageMaximumGenerationsConditionalBranch2.ConditionParameter.ActualName = "PerformFixedReunification"; 294 295 // if the village terminated because of maximum generations first set the maxgen of a village back to its generation 296 villageMaximumGenerationsToGenerationsAssigner.LeftSideParameter.ActualName = "VillageMaximumGenerations"; 297 villageMaximumGenerationsToGenerationsAssigner.RightSideParameter.ActualName = "Generations"; 298 299 // if the village terminated because of maximum generations and then increase the maximum generations by the fixed migration interval 279 300 villageMaximumGenerationsCounter.ValueParameter.ActualName = "VillageMaximumGenerations"; 280 301 villageMaximumGenerationsCounter.Increment = null; 281 302 villageMaximumGenerationsCounter.IncrementParameter.ActualName = "MigrationInterval"; 303 304 selPressValuesCollector2.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Village", null, "SelectionPressure")); 305 selPressValuesCollector2.DataTableParameter.ActualName = "VillagesSelectionPressures"; 282 306 283 307 // if there's just one island left and we're getting to this point SASEGASA terminates … … 321 345 dataTableValuesCollector2.DataTableParameter.ActualName = "BestQualities"; 322 346 323 selPressValuesCollector2.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Village", null, "SelectionPressure"));324 selPressValuesCollector2.DataTableParameter.ActualName = "VillagesSelectionPressures";325 326 347 qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 327 348 qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; … … 330 351 331 352 villagesTerminationCondition.ConditionParameter.ActualName = "TerminateVillages"; 332 villageMaximumGenerationsConditionalBranch .ConditionParameter.ActualName = "TerminateMaximumGenerations";353 villageMaximumGenerationsConditionalBranch1.ConditionParameter.ActualName = "TerminateMaximumGenerations"; 333 354 #endregion 334 355 … … 348 369 selPressValuesCollector1.Successor = qualityDifferenceCalculator1; 349 370 qualityDifferenceCalculator1.Successor = resultsCollector; 350 resultsCollector.Successor = ussp1; 371 resultsCollector.Successor = fixedReunificationStepConditionInitializer; 372 fixedReunificationStepConditionInitializer.Successor = ussp1; 351 373 ussp1.Operator = mainLoop; 352 ussp1.Successor = ussp2;374 ussp1.Successor = sasegasaGenerationsCollector; 353 375 mainLoop.Successor = sasegasaGenVillageGenComparator; 354 376 sasegasaGenVillageGenComparator.Successor = sasegasaGenerationsUpdateBranch; 355 377 sasegasaGenerationsUpdateBranch.TrueBranch = sasegasaGenerationsUpdater; 356 378 sasegasaGenerationsUpdateBranch.FalseBranch = null; 357 sasegasaGenerationsUpdateBranch.Successor = null; 358 ussp2.Operator = villageMaximumGenerationsConditionalBranch; 359 ussp2.Successor = villageCountComparator; 360 villageMaximumGenerationsConditionalBranch.TrueBranch = villageMaximumGenerationsCounter; 361 villageMaximumGenerationsConditionalBranch.FalseBranch = null; 362 villageMaximumGenerationsConditionalBranch.Successor = null; 379 sasegasaGenerationsUpdateBranch.Successor = villageMaximumGenerationsConditionalBranch1; 380 villageMaximumGenerationsConditionalBranch1.TrueBranch = fixedReunificationStepConditionUpdater; 381 villageMaximumGenerationsConditionalBranch1.FalseBranch = null; 382 villageMaximumGenerationsConditionalBranch1.Successor = null; 383 sasegasaGenerationsCollector.Successor = ussp2; 384 ussp2.Operator = villageMaximumGenerationsConditionalBranch2; 385 ussp2.Successor = selPressValuesCollector2; 386 villageMaximumGenerationsConditionalBranch2.TrueBranch = villageMaximumGenerationsToGenerationsAssigner; 387 villageMaximumGenerationsConditionalBranch2.FalseBranch = null; 388 villageMaximumGenerationsConditionalBranch2.Successor = null; 389 villageMaximumGenerationsToGenerationsAssigner.Successor = villageMaximumGenerationsCounter; 363 390 villageMaximumGenerationsCounter.Successor = null; 391 selPressValuesCollector2.Successor = villageCountComparator; 364 392 villageCountComparator.Successor = villageTerminationCondition0; 365 393 villageTerminationCondition0.TrueBranch = null; … … 372 400 bestQualityMemorizer3.Successor = bestAverageWorstQualityCalculator3; 373 401 bestAverageWorstQualityCalculator3.Successor = dataTableValuesCollector2; 374 dataTableValuesCollector2.Successor = selPressValuesCollector2; 375 selPressValuesCollector2.Successor = qualityDifferenceCalculator2; 402 dataTableValuesCollector2.Successor = qualityDifferenceCalculator2; 376 403 qualityDifferenceCalculator2.Successor = villagesTerminationCondition; 377 404 villagesTerminationCondition.FalseBranch = maximumGenerationsTerminationCondition; 378 405 villagesTerminationCondition.TrueBranch = null; 379 406 villagesTerminationCondition.Successor = null; 380 maximumGenerationsTerminationCondition.FalseBranch = ussp1;407 maximumGenerationsTerminationCondition.FalseBranch = fixedReunificationStepConditionInitializer; 381 408 maximumGenerationsTerminationCondition.TrueBranch = null; 382 409 maximumGenerationsTerminationCondition.Successor = null; -
trunk/sources/HeuristicLab.Analysis/3.3/DataTableValuesCollector.cs
r3479 r3489 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 53 54 foreach (IParameter param in CollectedValues) { 54 55 if (param.ActualValue is DoubleValue) { 55 DoubleValue data = param.ActualValue as DoubleValue; 56 DataRow row; 57 table.Rows.TryGetValue(param.Name, out row); 58 if (row == null) { 59 row = new DataRow(param.Name, param.Description); 60 row.Values.Add(data.Value); 61 table.Rows.Add(row); 62 } else { 63 row.Values.Add(data.Value); 64 } 65 } else if (param.ActualValue is ItemArray<DoubleValue>) { 66 ItemArray<DoubleValue> dataArray = param.ActualValue as ItemArray<DoubleValue>; 67 DataRow row; 68 for (int i = 0; i < dataArray.Length; i++) { 69 table.Rows.TryGetValue(param.Name + i.ToString(), out row); 70 if (row == null) { 71 row = new DataRow(param.Name + i.ToString(), param.Description); 72 row.Values.Add(dataArray[i].Value); 73 table.Rows.Add(row); 74 } else { 75 row.Values.Add(dataArray[i].Value); 76 } 56 AddValue(table, (param.ActualValue as DoubleValue).Value, param.Name, param.Description); 57 } else if (param.ActualValue is IEnumerable<DoubleValue>) { 58 int counter = 0; 59 foreach (DoubleValue data in (param.ActualValue as IEnumerable<DoubleValue>)) { 60 AddValue(table, data.Value, param.Name + counter.ToString(), param.Description); 61 counter++; 77 62 } 78 63 } else { 79 DataRow row; 80 table.Rows.TryGetValue(param.Name, out row); 81 if (row == null) { 82 row = new DataRow(param.Name, param.Description); 83 row.Values.Add(double.NaN); 84 table.Rows.Add(row); 85 } else { 86 row.Values.Add(double.NaN); 87 } 64 AddValue(table, double.NaN, param.Name, param.Description); 88 65 } 89 66 } 90 67 return base.Apply(); 91 68 } 69 70 private void AddValue(DataTable table, double data, string name, string description) { 71 DataRow row; 72 table.Rows.TryGetValue(name, out row); 73 if (row == null) { 74 row = new DataRow(name, description); 75 row.Values.Add(data); 76 table.Rows.Add(row); 77 } else { 78 row.Values.Add(data); 79 } 80 } 92 81 } 93 82 } -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/SASEGASAReunificator.cs
r3479 r3489 34 34 /// scopes by 1 and uniformly partitions the sub sub scopes again, maintaining the order. 35 35 /// </summary> 36 [Item("SASEGASAReunificator", "This operator merges the villages in a migration phaseand redistributes the individuals. It is implemented as described in Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications, CRC Press.")]36 [Item("SASEGASAReunificator", "This operator merges the villages (sub-scopes) and redistributes the individuals. It is implemented as described in Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications, CRC Press.")] 37 37 [StorableClass] 38 public class SASEGASAReunificator : SingleSuccessorOperator , IMigrator{38 public class SASEGASAReunificator : SingleSuccessorOperator { 39 39 40 40 public LookupParameter<IntValue> VillageCountParameter { … … 78 78 } 79 79 80 // add remaining sub-sub-scopes to last sub-scope80 // add remaining individuals to last village 81 81 scope.SubScopes[scope.SubScopes.Count - 1].SubScopes.AddRange(population); 82 82 population.Clear(); -
trunk/sources/HeuristicLab.Selection/3.3/OffspringSelector.cs
r3479 r3489 113 113 winners.AddRange(offspring); 114 114 offspring = children.SubScopes[0].SubScopes; // the losers 115 losersCount += offspring.Count; 115 116 while (offspring.Count > 0 && ((1 - successRatio) * populationSize > luckyLosers.Count || 116 117 selectionPressure.Value >= maxSelPress)) { 117 118 luckyLosers.Add(offspring[0]); 118 losersCount++;119 119 offspring.RemoveAt(0); 120 120 } 121 losersCount += offspring.Count;122 children.SubScopes.Clear();123 121 124 122 // calculate actual selection pressure and success ratio … … 140 138 } else { 141 139 // enough children generated 140 children.SubScopes.Clear(); 142 141 while (children.SubScopes.Count < populationSize) { 143 142 if (winners.Count > 0) {
Note: See TracChangeset
for help on using the changeset viewer.