Changeset 9553
- Timestamp:
- 05/29/13 13:14:58 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
r9456 r9553 79 79 get { return (ValueParameter<IntValue>)Parameters["Elites"]; } 80 80 } 81 private IFixedValueParameter<BoolValue> ReevaluateElitesParameter { 82 get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; } 83 } 81 84 private ValueParameter<MultiAnalyzer> AnalyzerParameter { 82 85 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } … … 119 122 get { return ElitesParameter.Value; } 120 123 set { ElitesParameter.Value = value; } 124 } 125 public bool ReevaluteElites { 126 get { return ReevaluateElitesParameter.Value.Value; } 127 set { ReevaluateElitesParameter.Value.Value = value; } 121 128 } 122 129 public MultiAnalyzer Analyzer { … … 151 158 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 152 159 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 160 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 }); 153 161 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 154 162 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); … … 207 215 [StorableHook(HookType.AfterDeserialization)] 208 216 private void AfterDeserialization() { 217 if (!Parameters.ContainsKey("ReevaluateElites")) { 218 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 }); 219 } 209 220 Initialize(); 210 221 } -
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithmMainLoop.cs
r9456 r9553 63 63 public ValueLookupParameter<IntValue> ElitesParameter { 64 64 get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; } 65 } 66 public IValueLookupParameter<BoolValue> ReevaluateElitesParameter { 67 get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; } 65 68 } 66 69 public ValueLookupParameter<IntValue> MaximumGenerationsParameter { … … 112 115 Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization.")); 113 116 Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.")); 117 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 114 118 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.")); 115 119 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); … … 143 147 Placeholder analyzer2 = new Placeholder(); 144 148 ConditionalBranch conditionalBranch = new ConditionalBranch(); 149 ConditionalBranch reevaluateElitesBranch = new ConditionalBranch(); 150 UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor(); 151 Placeholder evaluator2 = new Placeholder(); 152 SubScopesCounter subScopesCounter2 = new SubScopesCounter(); 145 153 146 154 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class GeneticAlgorithm expects this to be called Generations … … 193 201 194 202 conditionalBranch.ConditionParameter.ActualName = "Terminate"; 203 204 reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites"; 205 reevaluateElitesBranch.Name = "Reevaluate elites ?"; 206 207 uniformSubScopesProcessor3.Parallel.Value = true; 208 209 evaluator2.Name = "Evaluator"; 210 evaluator2.OperatorParameter.ActualName = "Evaluator"; 211 212 subScopesCounter2.Name = "Increment EvaluatedSolutions"; 213 subScopesCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 214 195 215 #endregion 196 216 … … 221 241 subScopesProcessor2.Successor = mergingReducer; 222 242 bestSelector.Successor = rightReducer; 223 rightReducer.Successor = null; 243 rightReducer.Successor = reevaluateElitesBranch; 244 reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor3; 245 uniformSubScopesProcessor3.Operator = evaluator; 246 uniformSubScopesProcessor3.Successor = subScopesCounter2; 247 reevaluateElitesBranch.FalseBranch = null; 248 reevaluateElitesBranch.Successor = null; 224 249 mergingReducer.Successor = intCounter; 225 250 intCounter.Successor = comparator; … … 232 257 } 233 258 259 [StorableHook(HookType.AfterDeserialization)] 260 private void AfterDeserialization() { 261 if (!Parameters.ContainsKey("ReevaluateElites")) { 262 Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)")); 263 } 264 } 265 234 266 public override IOperation Apply() { 235 267 if (CrossoverParameter.ActualValue == null)
Note: See TracChangeset
for help on using the changeset viewer.