Changeset 12119 for branches/ALPS
- Timestamp:
- 03/04/15 12:53:48 (10 years ago)
- 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 76 76 </PropertyGroup> 77 77 <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> 78 106 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 79 107 <SpecificVersion>False</SpecificVersion> … … 94 122 </ItemGroup> 95 123 <ItemGroup> 124 <Compile Include="AlpsSsGeneticAlgorithm.cs" /> 96 125 <Compile Include="Properties\AssemblyInfo.cs" /> 97 126 <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> 98 133 </ItemGroup> 99 134 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs
r12092 r12119 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using HeuristicLab.Analysis;26 using HeuristicLab.Collections;27 24 using HeuristicLab.Common; 28 25 using HeuristicLab.Core; … … 41 38 [Creatable("Algorithms")] 42 39 [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 { 56 41 #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 }72 42 private IValueParameter<IntArray> PopulationSizeParameter { 73 43 get { return (IValueParameter<IntArray>)Parameters["PopulationSize"]; } … … 76 46 get { return (IValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 77 47 } 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 96 49 public IConstrainedValueParameter<ISelector> SelectorParameter { 97 50 get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; } … … 115 68 116 69 #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 136 70 public IntArray PopulationSize { 137 71 get { return PopulationSizeParameter.Value; } … … 142 76 set { MaximumGenerationsParameter.Value = value; } 143 77 } 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 168 79 public ISelector Selector { 169 80 get { return SelectorParameter.Value; } … … 191 102 } 192 103 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 199 105 private AlpsGeneticAlgorithmMainLoop MainLoop { 200 106 get { return OperatorGraph.Iterate().OfType<AlpsGeneticAlgorithmMainLoop>().First(); } 201 107 } 202 203 #endregion204 205 #region Preconfigured Analyzers206 [Storable]207 private BestAverageWorstQualityAnalyzer qualityAnalyzer;208 [Storable]209 private BestAverageWorstQualityAnalyzer layerQualityAnalyzer;210 108 #endregion 211 109 … … 215 113 private AlpsGeneticAlgorithm(AlpsGeneticAlgorithm original, Cloner cloner) 216 114 : base(original, cloner) { 217 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);218 layerQualityAnalyzer = cloner.Clone(original.layerQualityAnalyzer);219 115 Initialize(); 220 116 } … … 224 120 public AlpsGeneticAlgorithm() 225 121 : 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)));231 122 Parameters.Add(new ValueParameter<IntArray>("PopulationSize", "The size of the population of solutions each layer.", new IntArray(new[] { 100 }))); 232 123 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 });239 124 Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); 240 125 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); … … 303 188 foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name)) 304 189 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(); 317 197 Initialize(); 318 }319 320 public override void Prepare() {321 if (Problem != null)322 base.Prepare();323 198 } 324 199 325 200 #region Events 326 201 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(); 331 203 ParameterizeSolutionsCreator(); 332 204 ParameterizeMainLoop(); 333 205 ParameterizeSelectors(); 334 ParameterizeAnalyzers();335 ParameterizeIterationBasedOperators();336 206 UpdateCrossovers(); 337 207 UpdateMutators(); 338 UpdateAnalyzers(); 339 Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged; 340 base.OnProblemChanged(); 341 } 342 208 } 343 209 protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) { 344 ParameterizeStochasticOperator(Problem.SolutionCreator);210 base.Problem_SolutionCreatorChanged(sender, e); 345 211 ParameterizeSolutionsCreator(); 346 base.Problem_SolutionCreatorChanged(sender, e);347 212 } 348 213 protected override void Problem_EvaluatorChanged(object sender, EventArgs e) { 349 ParameterizeStochasticOperatorForLayer(Problem.Evaluator);214 base.Problem_EvaluatorChanged(sender, e); 350 215 ParameterizeSolutionsCreator(); 351 216 ParameterizeMainLoop(); 352 217 ParameterizeSelectors(); 353 ParameterizeAnalyzers();354 Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;355 base.Problem_EvaluatorChanged(sender, e);356 218 } 357 219 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); 361 221 UpdateCrossovers(); 362 222 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); 367 226 ParameterizeMainLoop(); 368 227 ParameterizeSelectors(); 369 ParameterizeAnalyzers(); 370 } 371 228 } 372 229 void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) { 373 230 PopulationSizeParameter.ValueChanged += PopulationSize_ValueChanged; … … 383 240 void Elites_ValueChanged(object sender, EventArgs e) { 384 241 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 }426 242 } 427 243 #endregion … … 430 246 private void Initialize() { 431 247 PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged; 432 //PopulationSize.ValueChanged += PopulationSize_ValueChanged; TODO433 248 ElitesParameter.ValueChanged += ElitesParameter_ValueChanged; 434 249 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;445 250 } 446 251 private void ParameterizeSolutionsCreator() { 447 SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;448 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;449 252 MainLoop.LayerUpdator.SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 450 253 MainLoop.LayerUpdator.SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; … … 473 276 selector.QualityParameter.Hidden = true; 474 277 } 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;521 278 } 522 279 } … … 555 312 } 556 313 } 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 #endregion571 572 #region AgeLimits calculation573 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 7588 private static IEnumerable<int> LinearAgingScheme() {589 for (int i = 0; ; i++)590 yield return i + 1;591 }592 // 1 2 3 5 8 13 21593 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 36598 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 64606 private static IEnumerable<int> ExponentialAgingScheme(double @base) {607 for (int i = 0; ; i++)608 yield return (int)Math.Pow(@base, i);609 }610 314 #endregion 611 315 } -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj
r12097 r12119 132 132 </ItemGroup> 133 133 <ItemGroup> 134 <Compile Include="AgingSchemeCalculator.cs" /> 135 <Compile Include="Alps.cs" /> 134 136 <Compile Include="Analyzers\OldestAverageYoungestAgeAnalyzer.cs" /> 135 137 <Compile Include="Analyzers\AgeDistributionAnalyzer.cs" /> -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/ShiftToRightMigrator.cs
r12018 r12119 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Operators; 27 using HeuristicLab.Optimization;28 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 28 … … 31 30 [Item("ShiftToRightMigrator", "Migrates the selected sub scopes by shifting them to the next(right) subscope.")] 32 31 [StorableClass] 33 public sealed class ShiftToRightMigrator : SingleSuccessorOperator , IMigrator{32 public sealed class ShiftToRightMigrator : SingleSuccessorOperator/*, IMigrator*/ { 34 33 35 34 [StorableConstructor]
Note: See TracChangeset
for help on using the changeset viewer.