Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3489


Ignore:
Timestamp:
04/22/10 16:34:44 (15 years ago)
Author:
abeham
Message:

updated SASEGASA #839
changed DataTableValuesCollector to plot IEnumerable<DoubleValue>
removed IMigrator from SASEGASAReunificator

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASAMainLoop.cs

    r3479 r3489  
    155155      QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
    156156      ResultsCollector resultsCollector = new ResultsCollector();
     157      Assigner fixedReunificationStepConditionInitializer = new Assigner();
    157158      UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
     159      // MAINLOOP
    158160      OffspringSelectionGeneticAlgorithmMainLoop mainLoop = new OffspringSelectionGeneticAlgorithmMainLoop();
    159       UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor();
     161      // MAINLOOP
    160162      Comparator sasegasaGenVillageGenComparator = new Comparator();
    161163      ConditionalBranch sasegasaGenerationsUpdateBranch = new ConditionalBranch();
    162164      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();
    164171      IntCounter villageMaximumGenerationsCounter = new IntCounter();
     172      DataTableValuesCollector selPressValuesCollector2 = new DataTableValuesCollector();
    165173      Comparator villageCountComparator = new Comparator();
    166174      ConditionalBranch villageTerminationCondition0 = new ConditionalBranch();
     
    172180      BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator3 = new BestAverageWorstQualityCalculator();
    173181      DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
    174       DataTableValuesCollector selPressValuesCollector2 = new DataTableValuesCollector();
    175182      QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
    176183      ConditionalBranch villagesTerminationCondition = new ConditionalBranch();
     
    240247      resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("VillageResults", "Result set for each village"));
    241248      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
     249
     250      fixedReunificationStepConditionInitializer.LeftSideParameter.ActualName = "PerformFixedReunification";
     251      fixedReunificationStepConditionInitializer.RightSideParameter.Value = new BoolValue(false);
    242252
    243253      mainLoop.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     
    273283      sasegasaGenerationsUpdater.RightSideParameter.ActualName = "Generations";
    274284
    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
    279300      villageMaximumGenerationsCounter.ValueParameter.ActualName = "VillageMaximumGenerations";
    280301      villageMaximumGenerationsCounter.Increment = null;
    281302      villageMaximumGenerationsCounter.IncrementParameter.ActualName = "MigrationInterval";
     303
     304      selPressValuesCollector2.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Village", null, "SelectionPressure"));
     305      selPressValuesCollector2.DataTableParameter.ActualName = "VillagesSelectionPressures";
    282306
    283307      // if there's just one island left and we're getting to this point SASEGASA terminates
     
    321345      dataTableValuesCollector2.DataTableParameter.ActualName = "BestQualities";
    322346
    323       selPressValuesCollector2.CollectedValues.Add(new SubScopesLookupParameter<DoubleValue>("Selection Pressure Village", null, "SelectionPressure"));
    324       selPressValuesCollector2.DataTableParameter.ActualName = "VillagesSelectionPressures";
    325 
    326347      qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    327348      qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
     
    330351
    331352      villagesTerminationCondition.ConditionParameter.ActualName = "TerminateVillages";
    332       villageMaximumGenerationsConditionalBranch.ConditionParameter.ActualName = "TerminateMaximumGenerations";
     353      villageMaximumGenerationsConditionalBranch1.ConditionParameter.ActualName = "TerminateMaximumGenerations";
    333354      #endregion
    334355
     
    348369      selPressValuesCollector1.Successor = qualityDifferenceCalculator1;
    349370      qualityDifferenceCalculator1.Successor = resultsCollector;
    350       resultsCollector.Successor = ussp1;
     371      resultsCollector.Successor = fixedReunificationStepConditionInitializer;
     372      fixedReunificationStepConditionInitializer.Successor = ussp1;
    351373      ussp1.Operator = mainLoop;
    352       ussp1.Successor = ussp2;
     374      ussp1.Successor = sasegasaGenerationsCollector;
    353375      mainLoop.Successor = sasegasaGenVillageGenComparator;
    354376      sasegasaGenVillageGenComparator.Successor = sasegasaGenerationsUpdateBranch;
    355377      sasegasaGenerationsUpdateBranch.TrueBranch = sasegasaGenerationsUpdater;
    356378      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;
    363390      villageMaximumGenerationsCounter.Successor = null;
     391      selPressValuesCollector2.Successor = villageCountComparator;
    364392      villageCountComparator.Successor = villageTerminationCondition0;
    365393      villageTerminationCondition0.TrueBranch = null;
     
    372400      bestQualityMemorizer3.Successor = bestAverageWorstQualityCalculator3;
    373401      bestAverageWorstQualityCalculator3.Successor = dataTableValuesCollector2;
    374       dataTableValuesCollector2.Successor = selPressValuesCollector2;
    375       selPressValuesCollector2.Successor = qualityDifferenceCalculator2;
     402      dataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
    376403      qualityDifferenceCalculator2.Successor = villagesTerminationCondition;
    377404      villagesTerminationCondition.FalseBranch = maximumGenerationsTerminationCondition;
    378405      villagesTerminationCondition.TrueBranch = null;
    379406      villagesTerminationCondition.Successor = null;
    380       maximumGenerationsTerminationCondition.FalseBranch = ussp1;
     407      maximumGenerationsTerminationCondition.FalseBranch = fixedReunificationStepConditionInitializer;
    381408      maximumGenerationsTerminationCondition.TrueBranch = null;
    382409      maximumGenerationsTerminationCondition.Successor = null;
  • trunk/sources/HeuristicLab.Analysis/3.3/DataTableValuesCollector.cs

    r3479 r3489  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    5354      foreach (IParameter param in CollectedValues) {
    5455        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++;
    7762          }
    7863        } 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);
    8865        }
    8966      }
    9067      return base.Apply();
    9168    }
     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    }
    9281  }
    9382}
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/SASEGASAReunificator.cs

    r3479 r3489  
    3434  /// scopes by 1 and uniformly partitions the sub sub scopes again, maintaining the order.
    3535  /// </summary>
    36   [Item("SASEGASAReunificator", "This operator merges the villages in a migration phase 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.")]
     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.")]
    3737  [StorableClass]
    38   public class SASEGASAReunificator : SingleSuccessorOperator, IMigrator {
     38  public class SASEGASAReunificator : SingleSuccessorOperator {
    3939
    4040    public LookupParameter<IntValue> VillageCountParameter {
     
    7878      }
    7979
    80       // add remaining sub-sub-scopes to last sub-scope
     80      // add remaining individuals to last village
    8181      scope.SubScopes[scope.SubScopes.Count - 1].SubScopes.AddRange(population);
    8282      population.Clear();
  • trunk/sources/HeuristicLab.Selection/3.3/OffspringSelector.cs

    r3479 r3489  
    113113      winners.AddRange(offspring);
    114114      offspring = children.SubScopes[0].SubScopes; // the losers
     115      losersCount += offspring.Count;
    115116      while (offspring.Count > 0 && ((1 - successRatio) * populationSize > luckyLosers.Count ||
    116117            selectionPressure.Value >= maxSelPress)) {
    117118        luckyLosers.Add(offspring[0]);
    118         losersCount++;
    119119        offspring.RemoveAt(0);
    120120      }
    121       losersCount += offspring.Count;
    122       children.SubScopes.Clear();
    123121
    124122      // calculate actual selection pressure and success ratio
     
    140138      } else {
    141139        // enough children generated
     140        children.SubScopes.Clear();
    142141        while (children.SubScopes.Count < populationSize) {
    143142          if (winners.Count > 0) {
Note: See TracChangeset for help on using the changeset viewer.