Changeset 13686 for branches/IslandALPS
- Timestamp:
- 03/11/16 12:15:15 (9 years ago)
- Location:
- branches/IslandALPS
- Files:
-
- 4 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/IslandALPS
-
Property
svn:global-ignores
set to
.vs
-
Property
svn:global-ignores
set to
-
branches/IslandALPS/IslandALPS/3.3
- Property svn:global-ignores
-
old new 1 1 .vs 2 2 obj 3 *.user
-
- Property svn:global-ignores
-
branches/IslandALPS/IslandALPS/3.3/GroupedLayerOperator.cs
r13595 r13686 115 115 } 116 116 117 //TODO: Copied from ResultsHistoryWiper, When integrate create static apply method and delete this117 //TODO: HL-INTEGRATION :Copied from ResultsHistoryWiper, When integrate create static apply method and delete this 118 118 private static void ClearHistoryRecursively(ResultCollection results) { 119 119 var values = results.Select(r => r.Value); -
branches/IslandALPS/IslandALPS/3.3/HeuristicLab.Algorithms.IslandALPS-3.3.csproj
r13604 r13686 105 105 </ItemGroup> 106 106 <ItemGroup> 107 <Compile Include="IslandAlpsAlgorithmMainLoop.cs" /> 107 108 <Compile Include="LayerMigrator.cs" /> 109 <Compile Include="Offspring Selection\IslandAlpsOffspringSelectionAlgorithm.cs" /> 110 <Compile Include="Offspring Selection\IslandAlpsOffspringSelectionAlgorithmMainLoop.cs" /> 108 111 <Compile Include="ResultsExtractor.cs" /> 109 112 <Compile Include="IslandALPSAlgorithm.cs" /> 110 <Compile Include="IslandALPSAlgorthmsMainLoop.cs" />111 113 <Compile Include="Plugin.cs" /> 112 114 <Compile Include="Properties\AssemblyInfo.cs" /> … … 116 118 <None Include="HeuristicLab.snk" /> 117 119 </ItemGroup> 120 <ItemGroup /> 118 121 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 119 122 <PropertyGroup> -
branches/IslandALPS/IslandALPS/3.3/IslandALPSAlgorithm.cs
r13604 r13686 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Security.Policy;5 4 using HeuristicLab.Algorithms.ALPS; 6 5 using HeuristicLab.Analysis; … … 41 40 42 41 #region ALPSParameter 43 private IValueParameter<IntValue> AgeGapParameter { 44 get { return (IValueParameter<IntValue>) Parameters["AgeGap"]; } 45 } 46 private IValueParameter<EnumValue<AgingScheme>> AgingSchemeParameter { 47 get { return (IValueParameter<EnumValue<AgingScheme>>)Parameters["AgingScheme"]; } 48 } 49 private IValueParameter<DoubleValue> AgeInheritanceParameter { 50 get { return (IValueParameter<DoubleValue>) Parameters["AgeInheritance"]; } 51 } 52 private IValueParameter<IntArray> AgeLimitsParameter { 53 get { return (IValueParameter<IntArray>) Parameters["AgeLimits"]; } 54 } 55 private IValueParameter<BoolValue> ReduceToPopulationSizeParameter { 56 get { return (IValueParameter<BoolValue>) Parameters["ReduceToPopulationSize"]; } 57 } 58 private IValueParameter<IntValue> NumberOfLayersParameter { 59 get { return (IValueParameter<IntValue>) Parameters["NumberOfLayers"]; } 60 } 61 private IValueParameter<MultiAnalyzer> LayerAnalyzerParameter { 62 get { return (IValueParameter<MultiAnalyzer>)Parameters["LayerAnalyzer"]; } 63 } 64 private IValueParameter<MultiAnalyzer> GroupAnalyzerParameter { 65 get { return (IValueParameter<MultiAnalyzer>)Parameters["GroupAnalyzer"]; } 66 } 67 private IValueParameter<BoolValue> PlusSelectionParameter { 68 get { return (IValueParameter<BoolValue>)Parameters["PlusSelection"]; } 69 } 42 43 public IValueParameter<IntValue> AgeGapParameter { get { return (IValueParameter<IntValue>) Parameters["AgeGap"]; } } 44 45 public IValueParameter<EnumValue<AgingScheme>> AgingSchemeParameter { get { return (IValueParameter<EnumValue<AgingScheme>>) Parameters["AgingScheme"]; } } 46 public IValueParameter<DoubleValue> AgeInheritanceParameter { get { return (IValueParameter<DoubleValue>) Parameters["AgeInheritance"]; } } 47 public IValueParameter<IntArray> AgeLimitsParameter { get { return (IValueParameter<IntArray>) Parameters["AgeLimits"]; } } 48 public IValueParameter<BoolValue> ReduceToPopulationSizeParameter { get { return (IValueParameter<BoolValue>) Parameters["ReduceToPopulationSize"]; } } 49 public IValueParameter<IntValue> NumberOfLayersParameter { get { return (IValueParameter<IntValue>) Parameters["NumberOfLayers"]; } } 50 public IValueParameter<MultiAnalyzer> LayerAnalyzerParameter { get { return (IValueParameter<MultiAnalyzer>) Parameters["LayerAnalyzer"]; } } 51 public IValueParameter<MultiAnalyzer> GroupAnalyzerParameter { get { return (IValueParameter<MultiAnalyzer>) Parameters["GroupAnalyzer"]; } } 52 public IValueParameter<BoolValue> PlusSelectionParameter { get { return (IValueParameter<BoolValue>) Parameters["PlusSelection"]; } } 70 53 #endregion 71 54 72 55 #region IslandParameter 73 private IValueParameter<MultiAnalyzer> IslandAnalyzerParameter { 74 get { return (IValueParameter<MultiAnalyzer>) Parameters["IslandAnalyzer"]; } 75 } 76 private IValueParameter<IntValue> NumberOfIslandsParameter { 77 get { return (IValueParameter<IntValue>) Parameters["NumberOfIslands"]; } 78 } 79 private IValueParameter<PercentValue> MigrationRateParameter { 80 get { return (IValueParameter<PercentValue>)Parameters["MigrationRate"]; } 81 } 82 private IValueParameter<IntValue> MigrationIntervalParameter { 83 get { return (IValueParameter<IntValue>)Parameters["MigrationInterval"]; } 84 } 85 public IConstrainedValueParameter<IMigrator> MigratorParameter { 86 get { return (IConstrainedValueParameter<IMigrator>)Parameters["Migrator"]; } 87 } 88 public IConstrainedValueParameter<ISelector> EmigrantsSelectorParameter { 89 get { return (IConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; } 90 } 91 public IConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter { 92 get { return (IConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; } 93 } 56 57 public IValueParameter<MultiAnalyzer> IslandAnalyzerParameter { get { return (IValueParameter<MultiAnalyzer>) Parameters["IslandAnalyzer"]; } } 58 public IValueParameter<IntValue> NumberOfIslandsParameter { get { return (IValueParameter<IntValue>) Parameters["NumberOfIslands"]; } } 59 public IValueParameter<PercentValue> MigrationRateParameter { get { return (IValueParameter<PercentValue>) Parameters["MigrationRate"]; } } 60 public IValueParameter<IntValue> MigrationIntervalParameter { get { return (IValueParameter<IntValue>) Parameters["MigrationInterval"]; } } 61 public IConstrainedValueParameter<IMigrator> MigratorParameter { get { return (IConstrainedValueParameter<IMigrator>) Parameters["Migrator"]; } } 62 public IConstrainedValueParameter<ISelector> EmigrantsSelectorParameter { get { return (IConstrainedValueParameter<ISelector>) Parameters["EmigrantsSelector"]; } } 63 public IConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter { get { return (IConstrainedValueParameter<IReplacer>) Parameters["ImmigrationReplacer"]; } } 94 64 #endregion 95 65 96 66 #region GeneralParameter 97 private IValueParameter<IntValue> SeedParameter { 98 get { return (IValueParameter<IntValue>) Parameters["Seed"]; } 99 } 100 private IValueParameter<BoolValue> SetSeedRandomlyParameter { 101 get { return (IValueParameter<BoolValue>) Parameters["SetSeedRandomly"]; } 102 } 103 private IValueParameter<IntValue> PopulationSizeParameter { 104 get { return (IValueParameter<IntValue>) Parameters["PopulationSize"]; } 105 } 106 private IValueParameter<MultiAnalyzer> AnalyzerParameter { 107 get { return (IValueParameter<MultiAnalyzer>) Parameters["Analyzer"]; } 108 } 109 public IConstrainedValueParameter<ISelector> SelectorParameter { 110 get { return (IConstrainedValueParameter<ISelector>) Parameters["Selector"]; } 111 } 112 public IConstrainedValueParameter<ICrossover> CrossoverParameter { 113 get { return (IConstrainedValueParameter<ICrossover>) Parameters["Crossover"]; } 114 } 115 private IValueParameter<PercentValue> MutationProbabilityParameter { 116 get { return (IValueParameter<PercentValue>) Parameters["MutationProbability"]; } 117 } 118 public IConstrainedValueParameter<IManipulator> MutatorParameter { 119 get { return (IConstrainedValueParameter<IManipulator>) Parameters["Mutator"]; } 120 } 121 private IValueParameter<IntValue> ElitesParameter { 122 get { return (IValueParameter<IntValue>) Parameters["Elites"]; } 123 } 124 private IFixedValueParameter<BoolValue> ReevaluateElitesParameter { 125 get { return (IFixedValueParameter<BoolValue>) Parameters["ReevaluateElites"]; } 126 } 127 private IValueParameter<MultiTerminator> TerminatorParameter { 128 get { return (IValueParameter<MultiTerminator>) Parameters["Terminator"]; } 129 } 130 #endregion 67 68 public IValueParameter<IntValue> SeedParameter { get { return (IValueParameter<IntValue>) Parameters["Seed"]; } } 69 public IValueParameter<BoolValue> SetSeedRandomlyParameter { get { return (IValueParameter<BoolValue>) Parameters["SetSeedRandomly"]; } } 70 public IValueParameter<IntValue> PopulationSizeParameter { get { return (IValueParameter<IntValue>) Parameters["PopulationSize"]; } } 71 public IValueParameter<MultiAnalyzer> AnalyzerParameter { get { return (IValueParameter<MultiAnalyzer>) Parameters["Analyzer"]; } } 72 public IConstrainedValueParameter<ISelector> SelectorParameter { get { return (IConstrainedValueParameter<ISelector>) Parameters["Selector"]; } } 73 public IConstrainedValueParameter<ICrossover> CrossoverParameter { get { return (IConstrainedValueParameter<ICrossover>) Parameters["Crossover"]; } } 74 public IValueParameter<PercentValue> MutationProbabilityParameter { get { return (IValueParameter<PercentValue>) Parameters["MutationProbability"]; } } 75 public IConstrainedValueParameter<IManipulator> MutatorParameter { get { return (IConstrainedValueParameter<IManipulator>) Parameters["Mutator"]; } } 76 public IValueParameter<IntValue> ElitesParameter { get { return (IValueParameter<IntValue>) Parameters["Elites"]; } } 77 public IFixedValueParameter<BoolValue> ReevaluateElitesParameter { get { return (IFixedValueParameter<BoolValue>) Parameters["ReevaluateElites"]; } } 78 public IValueParameter<MultiTerminator> TerminatorParameter { get { return (IValueParameter<MultiTerminator>) Parameters["Terminator"]; } } 79 #endregion 80 131 81 #endregion 132 82 133 83 #region Properties 84 134 85 public IntValue Seed { 135 86 get { return SeedParameter.Value; } 136 87 set { SeedParameter.Value = value; } 137 88 } 89 138 90 public BoolValue SetSeedRandomly { 139 91 get { return SetSeedRandomlyParameter.Value; } 140 92 set { SetSeedRandomlyParameter.Value = value; } 141 93 } 94 142 95 public IntValue PopulationSize { 143 96 get { return PopulationSizeParameter.Value; } 144 97 set { PopulationSizeParameter.Value = value; } 145 98 } 99 146 100 public IntValue NumberOfIslands { 147 101 get { return NumberOfIslandsParameter.Value; } 148 102 set { NumberOfIslandsParameter.Value = value; } 149 103 } 104 150 105 public MultiAnalyzer Analyzer { 151 106 get { return AnalyzerParameter.Value; } 152 107 set { AnalyzerParameter.Value = value; } 153 108 } 109 154 110 public MultiAnalyzer IslandAnalyzer { 155 111 get { return IslandAnalyzerParameter.Value; } 156 112 set { IslandAnalyzerParameter.Value = value; } 157 113 } 114 158 115 public MultiAnalyzer LayerAnalyzer { 159 116 get { return LayerAnalyzerParameter.Value; } 160 117 set { LayerAnalyzerParameter.Value = value; } 161 118 } 119 162 120 public MultiAnalyzer GroupAnalyzer { 163 121 get { return GroupAnalyzerParameter.Value; } 164 122 set { GroupAnalyzerParameter.Value = value; } 165 123 } 124 166 125 public ISelector Selector { 167 126 get { return SelectorParameter.Value; } 168 127 set { SelectorParameter.Value = value; } 169 128 } 129 170 130 public ICrossover Crossover { 171 131 get { return CrossoverParameter.Value; } 172 132 set { CrossoverParameter.Value = value; } 173 133 } 134 174 135 public PercentValue MutationProbability { 175 136 get { return MutationProbabilityParameter.Value; } 176 137 set { MutationProbabilityParameter.Value = value; } 177 138 } 139 178 140 public IManipulator Mutator { 179 141 get { return MutatorParameter.Value; } 180 142 set { MutatorParameter.Value = value; } 181 143 } 144 182 145 public IntValue Elites { 183 146 get { return ElitesParameter.Value; } 184 147 set { ElitesParameter.Value = value; } 185 148 } 149 186 150 public bool ReevaluteElites { 187 151 get { return ReevaluateElitesParameter.Value.Value; } 188 152 set { ReevaluateElitesParameter.Value.Value = value; } 189 153 } 154 190 155 public MultiTerminator Terminators { 191 156 get { return TerminatorParameter.Value; } 192 157 } 158 193 159 public EnumValue<AgingScheme> AgingScheme { 194 160 get { return AgingSchemeParameter.Value; } 195 161 set { AgingSchemeParameter.Value = value; } 196 162 } 163 197 164 public IntValue AgeGap { 198 165 get { return AgeGapParameter.Value; } 199 166 set { AgeGapParameter.Value = value; } 200 167 } 168 201 169 public DoubleValue AgeInheritance { 202 170 get { return AgeInheritanceParameter.Value; } 203 171 set { AgeInheritanceParameter.Value = value; } 204 172 } 173 205 174 public IntArray AgeLimits { 206 175 get { return AgeLimitsParameter.Value; } 207 176 set { AgeLimitsParameter.Value = value; } 208 177 } 178 209 179 public IntValue NumberOfLayers { 210 180 get { return NumberOfLayersParameter.Value; } 211 181 set { NumberOfLayersParameter.Value = value; } 212 182 } 183 213 184 #endregion 214 185 215 186 #region Helper Properties 216 187 217 private IslandAlpsAlgor thmsMainLoop MainLoop {218 get { return OperatorGraph.Iterate().OfType<IslandAlpsAlgor thmsMainLoop>().First(); }188 private IslandAlpsAlgorithmMainLoop MainLoop { 189 get { return OperatorGraph.Iterate().OfType<IslandAlpsAlgorithmMainLoop>().First(); } 219 190 } 220 191 … … 246 217 247 218 [StorableConstructor] 248 private IslandAlpsAlgorithm(bool deserializing) : base(deserializing) { 249 } 219 private IslandAlpsAlgorithm(bool deserializing) : base(deserializing) {} 250 220 251 221 [StorableHook(HookType.AfterDeserialization)] … … 273 243 274 244 public IslandAlpsAlgorithm() { 275 #region add Parameter 276 #region ALPSParameter 277 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(5))); 278 Parameters.Add(new ValueParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(0.5))); 279 Parameters.Add(new ValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) { Hidden = true }); 280 Parameters.Add(new ValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(ALPS.AgingScheme.Polynomial))); 281 Parameters.Add(new ValueParameter<BoolValue>("ReduceToPopulationSize", ".", new BoolValue(true))); 282 283 Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "", new IntValue(10))); 284 Parameters.Add(new ValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer())); 285 Parameters.Add(new ValueParameter<MultiAnalyzer>("GroupAnalyzer", "The operator used to analyze each layergroup.", new MultiAnalyzer())); 286 Parameters.Add(new ValueParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation.", new BoolValue(false))); 287 288 #endregion 289 #region IslandParameter 290 Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5))); 291 Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "How many individuals should migrate.", new PercentValue(0.15))); 292 Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number Generations before a migration occurs.", new IntValue(20))); 293 Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); 294 Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy.")); 295 Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated.")); 296 Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants.")); 297 298 #endregion 299 #region GeneralParameter 300 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 301 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 302 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100))); 303 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer())); 304 Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); 305 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 306 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 307 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 308 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 309 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true }); 310 Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator())); 311 #endregion 312 313 #endregion 245 246 AddParameters(); 314 247 315 248 #region create Operators … … 330 263 var globalEvaluatedSolutionsCounter = new DataReducer {Name = "Count GlobalSolutions"}; 331 264 var resultsCollector = new ResultsCollector(); 332 var mainLoop = new IslandAlpsAlgor thmsMainLoop();265 var mainLoop = new IslandAlpsAlgorithmMainLoop(); 333 266 334 267 #endregion … … 351 284 352 285 #region Create Analyzers 353 354 286 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 355 287 islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); … … 360 292 #region Create terminators 361 293 362 generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { 363 Name = "Generations" 364 }; 365 evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, 366 new IntValue(int.MaxValue)) {Name = "Evaluations"}; 294 generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" }; 295 evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) {Name = "Evaluations"}; 367 296 qualityTerminator = new SingleObjectiveQualityTerminator {Name = "Quality"}; 368 297 executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5))); … … 432 361 globalEvaluatedSolutionsCounter.Successor = resultsCollector; 433 362 resultsCollector.Successor = mainLoop; 434 363 435 364 #endregion 365 436 366 #region parametrize 367 437 368 ParameterizeAnalyzers(); 438 369 UpdateAnalyzers(); … … 441 372 ParameterizeAgeLimits(); 442 373 ParametrizeMigration(); 374 443 375 #endregion 444 376 445 377 InitializeEventHandler(); 378 } 379 380 private void AddParameters() { 381 #region ALPSParameter 382 383 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(5))); 384 Parameters.Add(new ValueParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(1))); 385 Parameters.Add(new ValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) {Hidden = true}); 386 Parameters.Add(new ValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(ALPS.AgingScheme.Polynomial))); 387 Parameters.Add(new ValueParameter<BoolValue>("ReduceToPopulationSize", ".", new BoolValue(true))); 388 389 Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "", new IntValue(100000))); 390 Parameters.Add(new ValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer())); 391 Parameters.Add(new ValueParameter<MultiAnalyzer>("GroupAnalyzer", "The operator used to analyze each layergroup.", new MultiAnalyzer())); 392 Parameters.Add(new ValueParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation.", new BoolValue(false))); 393 394 #endregion 395 396 #region IslandParameter 397 398 Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5))); 399 Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "How many individuals should migrate.", new PercentValue(0.15))); 400 Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number Generations before a migration occurs.", new IntValue(20))); 401 Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); 402 Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy.")); 403 Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated.")); 404 Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants.")); 405 406 #endregion 407 408 #region GeneralParameter 409 410 Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 411 Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 412 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100))); 413 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer())); 414 Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); 415 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 416 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 417 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 418 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 419 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) {Hidden = true}); 420 Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator())); 421 422 #endregion 446 423 } 447 424 … … 546 523 547 524 //add analyzer 548 GroupAnalyzer.Operators.Add(groupQualityAnalyzer, groupQualityAnalyzer.EnabledByDefault);549 LayerAnalyzer.Operators.Add(layerQualityAnalyzer, layerQualityAnalyzer.EnabledByDefault);550 IslandAnalyzer.Operators.Add(islandQualityAnalyzer, islandQualityAnalyzer.EnabledByDefault);525 GroupAnalyzer.Operators.Add(groupQualityAnalyzer, false); 526 LayerAnalyzer.Operators.Add(layerQualityAnalyzer, false); 527 IslandAnalyzer.Operators.Add(islandQualityAnalyzer, false); 551 528 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 552 529 //depth for each analyzer gets set when added … … 554 531 foreach (var analyzer in Problem.Operators.OfType<IAnalyzer>()) { 555 532 Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault); 556 IslandAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(),false);557 LayerAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false);558 GroupAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false);533 IslandAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false); 534 LayerAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false); 535 GroupAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false); 559 536 } 560 537 } … … 583 560 foreach (var terminator in Problem.Operators.OfType<ITerminator>()) 584 561 newTerminators.Add(terminator, 585 !Terminators.Operators.Contains(terminator) || Terminators.Operators.ItemChecked(terminator));562 !Terminators.Operators.Contains(terminator) || Terminators.Operators.ItemChecked(terminator)); 586 563 } 587 564 … … 600 577 MigrationRateParameter.ValueChanged += MigrationRate_ValueChanged; 601 578 602 Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded; 579 Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded; 603 580 IslandAnalyzer.Operators.ItemsAdded += IslandAnalyzerOperators_ItemsAdded; 604 581 LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded; … … 616 593 NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged; 617 594 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 618 619 595 } 620 596 621 597 private void MigrationRate_ValueChanged(object sender, EventArgs e) { 622 var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value *PopulationSize.Value);598 var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value*PopulationSize.Value); 623 599 foreach (var selector in EmigrantsSelectorParameter.ValidValues) { 624 600 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize); … … 653 629 } 654 630 } 631 655 632 private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) { 656 633 foreach (var analyzer in e.Items) { … … 684 661 ParameterizeSelectors(); 685 662 } 663 686 664 private void Elites_ValueChanged(object sender, EventArgs e) { 687 665 ParameterizeSelectors(); 688 666 } 667 689 668 private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) { 690 669 ParameterizeSelectors(); 691 670 } 671 692 672 private void PopulationSize_ValueChanged(object sender, EventArgs e) { 693 673 ParameterizeSelectors(); 694 674 } 675 695 676 private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) { 696 677 NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged; 697 678 ParameterizeAgeLimits(); 698 679 } 680 699 681 private void NumberOfLayers_ValueChanged(object sender, EventArgs e) { 700 682 ParameterizeAgeLimits(); 701 683 } 684 702 685 private void AgeGapParameter_ValueChanged(object sender, EventArgs e) { 703 686 AgeGap.ValueChanged += AgeGap_ValueChanged; 704 687 ParameterizeAgeLimits(); 705 688 } 689 706 690 private void AgeGap_ValueChanged(object sender, EventArgs e) { 707 691 ParameterizeAgeLimits(); 708 692 } 693 709 694 private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) { 710 695 AgingScheme.ValueChanged += AgingScheme_ValueChanged; 711 696 ParameterizeAgeLimits(); 712 697 } 698 713 699 private void AgingScheme_ValueChanged(object sender, EventArgs e) { 714 700 ParameterizeAgeLimits(); … … 717 703 private void ParameterizeAgeLimits() { 718 704 var scheme = AgingScheme.Value; 719 intageGap = AgeGap.Value;720 intnumberOfLayers = NumberOfLayers.Value;705 var ageGap = AgeGap.Value; 706 var numberOfLayers = NumberOfLayers.Value; 721 707 AgeLimits = scheme.CalculateAgeLimits(ageGap, numberOfLayers); 722 708 } 723 709 724 710 private void ParameterizeMainLoop() { 725 //TODO726 711 MainLoop.AgeGapParameter.ActualName = AgeGapParameter.Name; 727 712 MainLoop.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name; … … 744 729 MainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name; 745 730 746 747 748 731 MainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name; 749 732 MainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize"; … … 766 749 767 750 private void ParametrizeMigration() { 768 var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value 769 foreach ( ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) {751 var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value*PopulationSize.Value); 752 foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) { 770 753 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize); 771 754 selector.NumberOfSelectedSubScopesParameter.Hidden = true; … … 776 759 } 777 760 778 foreach ( IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) {761 foreach (var replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) { 779 762 ParameterizeStochasticOperatorForLayer(replacer); 780 763 ImmigrationReplacerParameter.ValidValues.Add(replacer); … … 807 790 ParametrizeSingleObjectiveSelector(selector); 808 791 } 809 810 792 } 811 793 }
Note: See TracChangeset
for help on using the changeset viewer.