Changeset 9569 for trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm
- Timestamp:
- 06/03/13 14:39:36 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs
r9456 r9569 100 100 get { return (ValueParameter<IntValue>)Parameters["Elites"]; } 101 101 } 102 private IFixedValueParameter<BoolValue> ReevaluateElitesParameter { 103 get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; } 104 } 102 105 private ValueParameter<MultiAnalyzer> AnalyzerParameter { 103 106 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } … … 168 171 get { return ElitesParameter.Value; } 169 172 set { ElitesParameter.Value = value; } 173 } 174 public bool ReevaluteElites { 175 get { return ReevaluateElitesParameter.Value.Value; } 176 set { ReevaluateElitesParameter.Value.Value = value; } 170 177 } 171 178 public MultiAnalyzer Analyzer { … … 199 206 [StorableHook(HookType.AfterDeserialization)] 200 207 private void AfterDeserialization() { 208 if (!Parameters.ContainsKey("ReevaluateElites")) { 209 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 210 } 201 211 Initialize(); 202 212 } … … 228 238 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 229 239 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 240 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 }); 230 241 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer())); 231 242 Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); … … 301 312 mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name; 302 313 mainLoop.ElitesParameter.ActualName = ElitesParameter.Name; 314 mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name; 303 315 mainLoop.MutatorParameter.ActualName = MutatorParameter.Name; 304 316 mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name; -
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs
r9456 r9569 91 91 public ValueLookupParameter<IntValue> ElitesParameter { 92 92 get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; } 93 } 94 public IValueLookupParameter<BoolValue> ReevaluateElitesParameter { 95 get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; } 93 96 } 94 97 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 144 147 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions.")); 145 148 Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.")); 149 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 146 150 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results.")); 147 151 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands.")); … … 194 198 Placeholder analyzer2 = new Placeholder(); 195 199 ConditionalBranch generationsTerminationCondition = new ConditionalBranch(); 200 ConditionalBranch reevaluateElitesBranch = new ConditionalBranch(); 196 201 197 202 … … 305 310 generationsTerminationCondition.Name = "Terminate?"; 306 311 generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations"; 312 313 reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites"; 314 reevaluateElitesBranch.Name = "Reevaluate elites ?"; 307 315 #endregion 308 316 … … 345 353 evaluator.Successor = null; 346 354 subScopesCounter.Successor = null; 347 subScopesCounter.Successor = null;348 355 subScopesProcessor2.Operators.Add(bestSelector); 349 356 subScopesProcessor2.Operators.Add(new EmptyOperator()); … … 351 358 mergingReducer.Successor = islandAnalyzer2; 352 359 bestSelector.Successor = rightReducer; 353 rightReducer.Successor = null; 360 rightReducer.Successor = reevaluateElitesBranch; 361 reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor3; 362 reevaluateElitesBranch.FalseBranch = null; 363 reevaluateElitesBranch.Successor = null; 354 364 islandAnalyzer2.Successor = islandGenerationsCounter; 355 365 islandGenerationsCounter.Successor = checkIslandGenerationsReachedMaximum; … … 369 379 } 370 380 381 [StorableHook(HookType.AfterDeserialization)] 382 private void AfterDeserialization() { 383 if (!Parameters.ContainsKey("ReevaluateElites")) { 384 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 385 } 386 } 387 371 388 public override IOperation Apply() { 372 389 if (CrossoverParameter.ActualValue == null)
Note: See TracChangeset
for help on using the changeset viewer.