Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12119 for branches/ALPS


Ignore:
Timestamp:
03/04/15 12:53:48 (10 years ago)
Author:
pfleck
Message:

#2350

  • Created base class Alps which manages ALPS specific parameters, events and parameterization.
  • Created empty AlpsGeneticAlgorithm.
  • Removed code from AlpsGeneticAlgorithm because the base class handles this now.
  • Created AgingSchemeCalculator to separate calculating of the age-limits from the algorithms.
  • ShiftToRightMigrator does no longer implement IMigrator to avoid conflicts with IslandGA.
Location:
branches/ALPS
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/HeuristicLab.Algorithms.ALPS.SteadyState-3.3.csproj

    r12115 r12119  
    7676  </PropertyGroup>
    7777  <ItemGroup>
     78    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     79      <SpecificVersion>False</SpecificVersion>
     80      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     81    </Reference>
     82    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     83      <SpecificVersion>False</SpecificVersion>
     84      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     85    </Reference>
     86    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     87      <SpecificVersion>False</SpecificVersion>
     88      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     89    </Reference>
     90    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     91      <SpecificVersion>False</SpecificVersion>
     92      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     93    </Reference>
     94    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     95      <SpecificVersion>False</SpecificVersion>
     96      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     97    </Reference>
     98    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     99      <SpecificVersion>False</SpecificVersion>
     100      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     101    </Reference>
     102    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     103      <SpecificVersion>False</SpecificVersion>
     104      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     105    </Reference>
    78106    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    79107      <SpecificVersion>False</SpecificVersion>
     
    94122  </ItemGroup>
    95123  <ItemGroup>
     124    <Compile Include="AlpsSsGeneticAlgorithm.cs" />
    96125    <Compile Include="Properties\AssemblyInfo.cs" />
    97126    <Compile Include="Plugin.cs" />
     127  </ItemGroup>
     128  <ItemGroup>
     129    <ProjectReference Include="..\..\HeuristicLab.Algorithms.ALPS\3.3\HeuristicLab.Algorithms.ALPS-3.3.csproj">
     130      <Project>{59F354CB-FE13-4253-AED2-AD86372BEC27}</Project>
     131      <Name>HeuristicLab.Algorithms.ALPS-3.3</Name>
     132    </ProjectReference>
    98133  </ItemGroup>
    99134  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs

    r12092 r12119  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    25 using HeuristicLab.Analysis;
    26 using HeuristicLab.Collections;
    2724using HeuristicLab.Common;
    2825using HeuristicLab.Core;
     
    4138  [Creatable("Algorithms")]
    4239  [StorableClass]
    43   public sealed class AlpsGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
    44     public string Filename { get; set; }
    45 
    46     #region Problem Properties
    47     public override Type ProblemType {
    48       get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
    49     }
    50     public new ISingleObjectiveHeuristicOptimizationProblem Problem {
    51       get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
    52       set { base.Problem = value; }
    53     }
    54     #endregion
    55 
     40  public sealed class AlpsGeneticAlgorithm : Alps {
    5641    #region Parameter Properties
    57     private IValueParameter<IntValue> SeedParameter {
    58       get { return (IValueParameter<IntValue>)Parameters["Seed"]; }
    59     }
    60     private IValueParameter<BoolValue> SetSeedRandomlyParameter {
    61       get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    62     }
    63     private IFixedValueParameter<MultiAnalyzer> AnalyzerParameter {
    64       get { return (IFixedValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
    65     }
    66     private IFixedValueParameter<MultiAnalyzer> LayerAnalyzerParameter {
    67       get { return (IFixedValueParameter<MultiAnalyzer>)Parameters["LayerAnalyzer"]; }
    68     }
    69     private IValueParameter<IntValue> NumberOfLayersParameter {
    70       get { return (IValueParameter<IntValue>)Parameters["NumberOfLayers"]; }
    71     }
    7242    private IValueParameter<IntArray> PopulationSizeParameter {
    7343      get { return (IValueParameter<IntArray>)Parameters["PopulationSize"]; }
     
    7646      get { return (IValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
    7747    }
    78     private IValueParameter<AgingScheme> AgingSchemeParameter {
    79       get { return (IValueParameter<AgingScheme>)Parameters["AgingScheme"]; }
    80     }
    81     private IValueParameter<IntValue> AgeGapParameter {
    82       get { return (IValueParameter<IntValue>)Parameters["AgeGap"]; }
    83     }
    84     private IValueParameter<IntArray> AgeLimitsParameter {
    85       get { return (IValueParameter<IntArray>)Parameters["AgeLimits"]; }
    86     }
    87     private IValueParameter<ReductionOperation> AgeInheritanceParameter {
    88       get { return (IValueParameter<ReductionOperation>)Parameters["AgeInheritance"]; }
    89     }
    90     private IValueParameter<IntValue> MatingPoolRangeParameter {
    91       get { return (IValueParameter<IntValue>)Parameters["MatingPoolRange"]; }
    92     }
    93     private IValueParameter<PercentValue> MatingPoolSelectionPercentageParameter {
    94       get { return (IValueLookupParameter<PercentValue>)Parameters["MatingPoolSelectionPercentage"]; }
    95     }
     48
    9649    public IConstrainedValueParameter<ISelector> SelectorParameter {
    9750      get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
     
    11568
    11669    #region Properties
    117     public IntValue Seed {
    118       get { return SeedParameter.Value; }
    119       set { SeedParameter.Value = value; }
    120     }
    121     public BoolValue SetSeedRandomly {
    122       get { return SetSeedRandomlyParameter.Value; }
    123       set { SetSeedRandomlyParameter.Value = value; }
    124     }
    125     public MultiAnalyzer Analyzer {
    126       get { return AnalyzerParameter.Value; }
    127     }
    128     public MultiAnalyzer LayerAnalyzer {
    129       get { return LayerAnalyzerParameter.Value; }
    130     }
    131     public IntValue NumberOfLayers {
    132       get { return NumberOfLayersParameter.Value; }
    133       set { NumberOfLayersParameter.Value = value; }
    134     }
    135 
    13670    public IntArray PopulationSize {
    13771      get { return PopulationSizeParameter.Value; }
     
    14276      set { MaximumGenerationsParameter.Value = value; }
    14377    }
    144     public AgingScheme AgingScheme {
    145       get { return AgingSchemeParameter.Value; }
    146       set { AgingSchemeParameter.Value = value; }
    147     }
    148     public IntValue AgeGap {
    149       get { return AgeGapParameter.Value; }
    150       set { AgeGapParameter.Value = value; }
    151     }
    152     public IntArray AgeLimits {
    153       get { return AgeLimitsParameter.Value; }
    154       set { AgeLimitsParameter.Value = value; }
    155     }
    156     public ReductionOperation AgeInheritance {
    157       get { return AgeInheritanceParameter.Value; }
    158       set { AgeInheritanceParameter.Value = value; }
    159     }
    160     public IntValue MatingPoolRange {
    161       get { return MatingPoolRangeParameter.Value; }
    162       set { MatingPoolRangeParameter.Value = value; }
    163     }
    164     public PercentValue MatingPoolSelectionPercentage {
    165       get { return MatingPoolSelectionPercentageParameter.Value; }
    166       set { MatingPoolSelectionPercentageParameter.Value = value; }
    167     }
     78
    16879    public ISelector Selector {
    16980      get { return SelectorParameter.Value; }
     
    191102    }
    192103
    193     private RandomCreator GlobalRandomCreator {
    194       get { return (RandomCreator)OperatorGraph.InitialOperator; }
    195     }
    196     private SolutionsCreator SolutionsCreator {
    197       get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
    198     }
     104
    199105    private AlpsGeneticAlgorithmMainLoop MainLoop {
    200106      get { return OperatorGraph.Iterate().OfType<AlpsGeneticAlgorithmMainLoop>().First(); }
    201107    }
    202 
    203     #endregion
    204 
    205     #region Preconfigured Analyzers
    206     [Storable]
    207     private BestAverageWorstQualityAnalyzer qualityAnalyzer;
    208     [Storable]
    209     private BestAverageWorstQualityAnalyzer layerQualityAnalyzer;
    210108    #endregion
    211109
     
    215113    private AlpsGeneticAlgorithm(AlpsGeneticAlgorithm original, Cloner cloner)
    216114      : base(original, cloner) {
    217       qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
    218       layerQualityAnalyzer = cloner.Clone(original.layerQualityAnalyzer);
    219115      Initialize();
    220116    }
     
    224120    public AlpsGeneticAlgorithm()
    225121      : base() {
    226       Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    227       Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    228       Parameters.Add(new FixedValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
    229       Parameters.Add(new FixedValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));
    230       Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(10)));
    231122      Parameters.Add(new ValueParameter<IntArray>("PopulationSize", "The size of the population of solutions each layer.", new IntArray(new[] { 100 })));
    232123      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000)));
    233       Parameters.Add(new ValueParameter<AgingScheme>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new AgingScheme(AgingSchemes.Polynomial)));
    234       Parameters.Add(new ValueParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers", new IntValue(20)));
    235       Parameters.Add(new ValueParameter<IntArray>("AgeLimits", new IntArray(new int[0])) { Hidden = true });
    236       Parameters.Add(new ValueParameter<ReductionOperation>("AgeInheritance", "The operator for determining the age of an offspring based the parents' age.", new ReductionOperation(ReductionOperations.Max)) { Hidden = true });
    237       Parameters.Add(new ValueParameter<IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1)) { Hidden = true });
    238       Parameters.Add(new ValueParameter<PercentValue>("MatingPoolSelectionPercentage", "Percentage of the previous layers used for creating a mating pool.", new PercentValue(1.0, restrictToUnitInterval: true)) { Hidden = true });
    239124      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
    240125      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
     
    303188      foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name))
    304189        SelectorParameter.ValidValues.Add(selector);
    305       var porportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(s => s is ProportionalSelector);
    306       if (porportionalSelector != null) SelectorParameter.Value = porportionalSelector;
    307 
    308       ParameterizeSelectors();
    309 
    310       qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
    311       layerQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
    312 
    313       RecalculateAgeLimits();
    314       ParameterizeAnalyzers();
    315       UpdateAnalyzers();
    316 
     190      var tournamentSelector = SelectorParameter.ValidValues.OfType<TournamentSelector>().FirstOrDefault();
     191      if (tournamentSelector != null) {
     192        tournamentSelector.GroupSizeParameter.Value = new IntValue(5);
     193        SelectorParameter.Value = tournamentSelector;
     194      }
     195
     196      ParameterizeSelectors();
    317197      Initialize();
    318     }
    319 
    320     public override void Prepare() {
    321       if (Problem != null)
    322         base.Prepare();
    323198    }
    324199
    325200    #region Events
    326201    protected override void OnProblemChanged() {
    327       ParameterizeStochasticOperator(Problem.SolutionCreator);
    328       ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
    329       foreach (var @operator in Problem.Operators.OfType<IOperator>())
    330         ParameterizeStochasticOperator(@operator);
     202      base.OnProblemChanged();
    331203      ParameterizeSolutionsCreator();
    332204      ParameterizeMainLoop();
    333205      ParameterizeSelectors();
    334       ParameterizeAnalyzers();
    335       ParameterizeIterationBasedOperators();
    336206      UpdateCrossovers();
    337207      UpdateMutators();
    338       UpdateAnalyzers();
    339       Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    340       base.OnProblemChanged();
    341     }
    342 
     208    }
    343209    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
    344       ParameterizeStochasticOperator(Problem.SolutionCreator);
     210      base.Problem_SolutionCreatorChanged(sender, e);
    345211      ParameterizeSolutionsCreator();
    346       base.Problem_SolutionCreatorChanged(sender, e);
    347212    }
    348213    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
    349       ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
     214      base.Problem_EvaluatorChanged(sender, e);
    350215      ParameterizeSolutionsCreator();
    351216      ParameterizeMainLoop();
    352217      ParameterizeSelectors();
    353       ParameterizeAnalyzers();
    354       Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    355       base.Problem_EvaluatorChanged(sender, e);
    356218    }
    357219    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
    358       foreach (var @operator in Problem.Operators.OfType<IOperator>())
    359         ParameterizeStochasticOperator(@operator);
    360       ParameterizeIterationBasedOperators();
     220      base.Problem_OperatorsChanged(sender, e);
    361221      UpdateCrossovers();
    362222      UpdateMutators();
    363       UpdateAnalyzers();
    364       base.Problem_OperatorsChanged(sender, e);
    365     }
    366     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     223    }
     224    protected override void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     225      base.Evaluator_QualityParameter_ActualNameChanged(sender, e);
    367226      ParameterizeMainLoop();
    368227      ParameterizeSelectors();
    369       ParameterizeAnalyzers();
    370     }
    371 
     228    }
    372229    void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
    373230      PopulationSizeParameter.ValueChanged += PopulationSize_ValueChanged;
     
    383240    void Elites_ValueChanged(object sender, EventArgs e) {
    384241      ParameterizeSelectors();
    385     }
    386     private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
    387       AgeGap.ValueChanged += AgeGap_ValueChanged;
    388       RecalculateAgeLimits();
    389     }
    390     private void AgeGap_ValueChanged(object sender, EventArgs e) {
    391       RecalculateAgeLimits();
    392     }
    393     private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
    394       AgingScheme.ValueChanged += AgingScheme_ValueChanged;
    395       RecalculateAgeLimits();
    396     }
    397     private void AgingScheme_ValueChanged(object sender, EventArgs e) {
    398       RecalculateAgeLimits();
    399     }
    400     private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
    401       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
    402       RecalculateAgeLimits();
    403     }
    404     private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
    405       RecalculateAgeLimits();
    406     }
    407     private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
    408       foreach (var analyzer in e.Items) {
    409         foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
    410           parameter.Depth = 2;
    411         }
    412       }
    413     }
    414     private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
    415       foreach (var analyzer in e.Items) {
    416         IParameter resultParameter;
    417         if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
    418           var lookupParameter = resultParameter as ILookupParameter<ResultCollection>;
    419           if (lookupParameter != null)
    420             lookupParameter.ActualName = "LayerResults";
    421         }
    422         foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
    423           parameter.Depth = 1;
    424         }
    425       }
    426242    }
    427243    #endregion
     
    430246    private void Initialize() {
    431247      PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged;
    432       //PopulationSize.ValueChanged += PopulationSize_ValueChanged; TODO
    433248      ElitesParameter.ValueChanged += ElitesParameter_ValueChanged;
    434249      Elites.ValueChanged += Elites_ValueChanged;
    435       if (Problem != null)
    436         Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    437       AgeGapParameter.ValueChanged += AgeGapParameter_ValueChanged;
    438       AgeGap.ValueChanged += AgeGap_ValueChanged;
    439       AgingSchemeParameter.ValueChanged += AgingSchemeParameter_ValueChanged;
    440       AgingScheme.ValueChanged += AgingScheme_ValueChanged;
    441       NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged;
    442       NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
    443       Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded;
    444       LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded;
    445250    }
    446251    private void ParameterizeSolutionsCreator() {
    447       SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    448       SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
    449252      MainLoop.LayerUpdator.SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    450253      MainLoop.LayerUpdator.SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     
    473276          selector.QualityParameter.Hidden = true;
    474277        }
    475       }
    476     }
    477     private void ParameterizeAnalyzers() {
    478       qualityAnalyzer.ResultsParameter.ActualName = "Results";
    479       qualityAnalyzer.ResultsParameter.Hidden = true;
    480       qualityAnalyzer.QualityParameter.Depth = 2;
    481       layerQualityAnalyzer.ResultsParameter.ActualName = "Results";
    482       layerQualityAnalyzer.ResultsParameter.Hidden = true;
    483       layerQualityAnalyzer.QualityParameter.Depth = 1;
    484       if (Problem != null) {
    485         qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    486         qualityAnalyzer.MaximizationParameter.Hidden = true;
    487         qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    488         qualityAnalyzer.QualityParameter.Hidden = true;
    489         qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    490         qualityAnalyzer.BestKnownQualityParameter.Hidden = true;
    491         layerQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    492         layerQualityAnalyzer.MaximizationParameter.Hidden = true;
    493         layerQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    494         layerQualityAnalyzer.QualityParameter.Hidden = true;
    495         layerQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    496         layerQualityAnalyzer.BestKnownQualityParameter.Hidden = true;
    497       }
    498     }
    499     private void ParameterizeIterationBasedOperators() {
    500       if (Problem != null) {
    501         foreach (var @operator in Problem.Operators.OfType<IIterationBasedOperator>()) {
    502           @operator.IterationsParameter.ActualName = "Generations";
    503           @operator.IterationsParameter.Hidden = true;
    504           @operator.MaximumIterationsParameter.ActualName = "MaximumGenerations";
    505           @operator.MaximumIterationsParameter.Hidden = true;
    506         }
    507       }
    508     }
    509     private void ParameterizeStochasticOperator(IOperator @operator) {
    510       var stochasticOperator = @operator as IStochasticOperator;
    511       if (stochasticOperator != null) {
    512         stochasticOperator.RandomParameter.ActualName = GlobalRandomCreator.RandomParameter.ActualName;
    513         stochasticOperator.RandomParameter.Hidden = true;
    514       }
    515     }
    516     private void ParameterizeStochasticOperatorForLayer(IOperator @operator) {
    517       var stochasticOperator = @operator as IStochasticOperator;
    518       if (stochasticOperator != null) {
    519         stochasticOperator.RandomParameter.ActualName = "LocalRandom";
    520         stochasticOperator.RandomParameter.Hidden = true;
    521278      }
    522279    }
     
    555312      }
    556313    }
    557     private void UpdateAnalyzers() {
    558       Analyzer.Operators.Clear();
    559       LayerAnalyzer.Operators.Clear();
    560 
    561       Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
    562       LayerAnalyzer.Operators.Add(layerQualityAnalyzer, layerQualityAnalyzer.EnabledByDefault);
    563 
    564       if (Problem != null) {
    565         foreach (var analyzer in Problem.Operators.OfType<IAnalyzer>()) {
    566           Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
    567         }
    568       }
    569     }
    570     #endregion
    571 
    572     #region AgeLimits calculation
    573     private void RecalculateAgeLimits() {
    574       IEnumerable<int> scheme;
    575       switch (AgingScheme.Value) {
    576         case AgingSchemes.Linear: scheme = LinearAgingScheme(); break;
    577         case AgingSchemes.Fibonacci: scheme = FibonacciAgingScheme(); break;
    578         case AgingSchemes.Polynomial: scheme = PolynomialAgingScheme(2); break;
    579         case AgingSchemes.Exponential: scheme = ExponentialAgingScheme(2); break;
    580         default: throw new NotSupportedException("Aging Scheme " + AgingScheme.Value + " is not supported.");
    581       }
    582 
    583       int ageGap = AgeGap.Value;
    584       AgeLimits = new IntArray(scheme.Select(a => a * ageGap).Take(NumberOfLayers.Value).ToArray());
    585     }
    586 
    587     // 1 2 3 4 5 6 7
    588     private static IEnumerable<int> LinearAgingScheme() {
    589       for (int i = 0; ; i++)
    590         yield return i + 1;
    591     }
    592     // 1 2 3 5 8 13 21
    593     private static IEnumerable<int> FibonacciAgingScheme() {
    594       for (int i = 1, next = 2, temp; ; temp = next, next = i + next, i = temp)
    595         yield return i;
    596     }
    597     // (n^2): 1 2 4 9 16 25 36
    598     private static IEnumerable<int> PolynomialAgingScheme(double exp) {
    599       yield return 1;
    600       yield return 2;
    601       for (int i = 2; ; i++)
    602         yield return (int)Math.Pow(i, exp);
    603 
    604     }
    605     // 1 2 4 8 16 32 64
    606     private static IEnumerable<int> ExponentialAgingScheme(double @base) {
    607       for (int i = 0; ; i++)
    608         yield return (int)Math.Pow(@base, i);
    609     }
    610314    #endregion
    611315  }
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj

    r12097 r12119  
    132132  </ItemGroup>
    133133  <ItemGroup>
     134    <Compile Include="AgingSchemeCalculator.cs" />
     135    <Compile Include="Alps.cs" />
    134136    <Compile Include="Analyzers\OldestAverageYoungestAgeAnalyzer.cs" />
    135137    <Compile Include="Analyzers\AgeDistributionAnalyzer.cs" />
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/ShiftToRightMigrator.cs

    r12018 r12119  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Operators;
    27 using HeuristicLab.Optimization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
     
    3130  [Item("ShiftToRightMigrator", "Migrates the selected sub scopes by shifting them to the next(right) subscope.")]
    3231  [StorableClass]
    33   public sealed class ShiftToRightMigrator : SingleSuccessorOperator, IMigrator {
     32  public sealed class ShiftToRightMigrator : SingleSuccessorOperator/*, IMigrator*/ {
    3433
    3534    [StorableConstructor]
Note: See TracChangeset for help on using the changeset viewer.