Changeset 10142 for branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs
- Timestamp:
- 11/20/13 10:52:38 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis.IslandAlgorithms/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs
r9756 r10142 41 41 [Creatable("Algorithms")] 42 42 [StorableClass] 43 public sealedclass IslandGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {43 public class IslandGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent { 44 44 public string Filename { get; set; } 45 45 … … 55 55 56 56 #region Parameter Properties 57 pr ivateValueParameter<IntValue> SeedParameter {57 protected ValueParameter<IntValue> SeedParameter { 58 58 get { return (ValueParameter<IntValue>)Parameters["Seed"]; } 59 59 } 60 pr ivateValueParameter<BoolValue> SetSeedRandomlyParameter {60 protected ValueParameter<BoolValue> SetSeedRandomlyParameter { 61 61 get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 62 62 } 63 pr ivateValueParameter<IntValue> NumberOfIslandsParameter {63 protected ValueParameter<IntValue> NumberOfIslandsParameter { 64 64 get { return (ValueParameter<IntValue>)Parameters["NumberOfIslands"]; } 65 65 } 66 pr ivateValueParameter<IntValue> MigrationIntervalParameter {66 protected ValueParameter<IntValue> MigrationIntervalParameter { 67 67 get { return (ValueParameter<IntValue>)Parameters["MigrationInterval"]; } 68 68 } 69 pr ivateValueParameter<PercentValue> MigrationRateParameter {69 protected ValueParameter<PercentValue> MigrationRateParameter { 70 70 get { return (ValueParameter<PercentValue>)Parameters["MigrationRate"]; } 71 71 } … … 79 79 get { return (IConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; } 80 80 } 81 pr ivateValueParameter<IntValue> PopulationSizeParameter {81 protected ValueParameter<IntValue> PopulationSizeParameter { 82 82 get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; } 83 83 } 84 pr ivateValueParameter<IntValue> MaximumGenerationsParameter {84 protected ValueParameter<IntValue> MaximumGenerationsParameter { 85 85 get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 86 86 } … … 91 91 get { return (IConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; } 92 92 } 93 pr ivateValueParameter<PercentValue> MutationProbabilityParameter {93 protected ValueParameter<PercentValue> MutationProbabilityParameter { 94 94 get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; } 95 95 } … … 97 97 get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; } 98 98 } 99 pr ivateValueParameter<IntValue> ElitesParameter {99 protected ValueParameter<IntValue> ElitesParameter { 100 100 get { return (ValueParameter<IntValue>)Parameters["Elites"]; } 101 101 } 102 pr ivateIFixedValueParameter<BoolValue> ReevaluateElitesParameter {102 protected IFixedValueParameter<BoolValue> ReevaluateElitesParameter { 103 103 get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; } 104 104 } 105 pr ivateValueParameter<MultiAnalyzer> AnalyzerParameter {105 protected ValueParameter<MultiAnalyzer> AnalyzerParameter { 106 106 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 107 107 } 108 pr ivateValueParameter<MultiAnalyzer> IslandAnalyzerParameter {108 protected ValueParameter<MultiAnalyzer> IslandAnalyzerParameter { 109 109 get { return (ValueParameter<MultiAnalyzer>)Parameters["IslandAnalyzer"]; } 110 110 } … … 184 184 set { IslandAnalyzerParameter.Value = value; } 185 185 } 186 pr ivateRandomCreator RandomCreator {186 protected RandomCreator RandomCreator { 187 187 get { return (RandomCreator)OperatorGraph.InitialOperator; } 188 188 } 189 pr ivateUniformSubScopesProcessor IslandProcessor {189 protected UniformSubScopesProcessor IslandProcessor { 190 190 get { return OperatorGraph.Iterate().OfType<UniformSubScopesProcessor>().First(x => x.Operator is SolutionsCreator); } 191 191 } 192 pr ivateSolutionsCreator SolutionsCreator {192 protected SolutionsCreator SolutionsCreator { 193 193 get { return (SolutionsCreator)IslandProcessor.Operator; } 194 194 } 195 pr ivateIslandGeneticAlgorithmMainLoop MainLoop {195 protected IslandGeneticAlgorithmMainLoop MainLoop { 196 196 get { return FindMainLoop(IslandProcessor.Successor); } 197 197 } 198 198 [Storable] 199 pr ivateBestAverageWorstQualityAnalyzer islandQualityAnalyzer;199 protected BestAverageWorstQualityAnalyzer islandQualityAnalyzer; 200 200 [Storable] 201 pr ivateBestAverageWorstQualityAnalyzer qualityAnalyzer;201 protected BestAverageWorstQualityAnalyzer qualityAnalyzer; 202 202 #endregion 203 203 204 204 [StorableConstructor] 205 pr ivateIslandGeneticAlgorithm(bool deserializing) : base(deserializing) { }205 protected IslandGeneticAlgorithm(bool deserializing) : base(deserializing) { } 206 206 [StorableHook(HookType.AfterDeserialization)] 207 207 private void AfterDeserialization() { … … 215 215 Initialize(); 216 216 } 217 pr ivateIslandGeneticAlgorithm(IslandGeneticAlgorithm original, Cloner cloner)217 protected IslandGeneticAlgorithm(IslandGeneticAlgorithm original, Cloner cloner) 218 218 : base(original, cloner) { 219 219 islandQualityAnalyzer = cloner.Clone(original.islandQualityAnalyzer); … … 422 422 423 423 #region Helpers 424 pr ivatevoid Initialize() {424 protected virtual void Initialize() { 425 425 PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged); 426 426 PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged); … … 433 433 } 434 434 } 435 pr ivatevoid ParameterizeSolutionsCreator() {435 protected virtual void ParameterizeSolutionsCreator() { 436 436 SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 437 437 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; 438 438 } 439 pr ivatevoid ParameterizeMainLoop() {439 protected virtual void ParameterizeMainLoop() { 440 440 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 441 441 MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; … … 443 443 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 444 444 } 445 pr ivatevoid ParameterizeStochasticOperator(IOperator op) {445 protected virtual void ParameterizeStochasticOperator(IOperator op) { 446 446 IStochasticOperator stochasticOp = op as IStochasticOperator; 447 447 if (stochasticOp != null) { … … 450 450 } 451 451 } 452 pr ivatevoid ParameterizeStochasticOperatorForIsland(IOperator op) {452 protected virtual void ParameterizeStochasticOperatorForIsland(IOperator op) { 453 453 IStochasticOperator stochasticOp = op as IStochasticOperator; 454 454 if (stochasticOp != null) { … … 457 457 } 458 458 } 459 pr ivatevoid ParameterizeSelectors() {459 protected virtual void ParameterizeSelectors() { 460 460 foreach (ISelector selector in SelectorParameter.ValidValues) { 461 461 selector.CopySelected = new BoolValue(true); … … 494 494 } 495 495 } 496 pr ivatevoid ParameterizeAnalyzers() {496 protected virtual void ParameterizeAnalyzers() { 497 497 islandQualityAnalyzer.ResultsParameter.ActualName = "Results"; 498 498 islandQualityAnalyzer.ResultsParameter.Hidden = true; … … 517 517 } 518 518 } 519 pr ivatevoid ParameterizeIterationBasedOperators() {519 protected virtual void ParameterizeIterationBasedOperators() { 520 520 if (Problem != null) { 521 521 foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) { … … 527 527 } 528 528 } 529 pr ivatevoid UpdateCrossovers() {529 protected virtual void UpdateCrossovers() { 530 530 ICrossover oldCrossover = CrossoverParameter.Value; 531 531 ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault(); … … 543 543 CrossoverParameter.Value = defaultCrossover; 544 544 } 545 pr ivatevoid UpdateMutators() {545 protected virtual void UpdateMutators() { 546 546 IManipulator oldMutator = MutatorParameter.Value; 547 547 MutatorParameter.ValidValues.Clear(); … … 555 555 } 556 556 } 557 pr ivatevoid UpdateAnalyzers() {557 protected virtual void UpdateAnalyzers() { 558 558 IslandAnalyzer.Operators.Clear(); 559 559 Analyzer.Operators.Clear(); … … 568 568 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 569 569 } 570 pr ivateIslandGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {570 protected virtual IslandGeneticAlgorithmMainLoop FindMainLoop(IOperator start) { 571 571 IOperator mainLoop = start; 572 572 while (mainLoop != null && !(mainLoop is IslandGeneticAlgorithmMainLoop))
Note: See TracChangeset
for help on using the changeset viewer.