- Timestamp:
- 09/27/10 10:40:51 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/NSGA2/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
r4168 r4514 82 82 get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; } 83 83 } 84 private ValueParameter<IntValue> SelectedParentsParameter { 85 get { return (ValueParameter<IntValue>)Parameters["SelectedParents"]; } 86 } 84 87 #endregion 85 88 … … 124 127 get { return MaximumGenerationsParameter.Value; } 125 128 set { MaximumGenerationsParameter.Value = value; } 129 } 130 public IntValue SelectedParents { 131 get { return SelectedParentsParameter.Value; } 132 set { SelectedParentsParameter.Value = value; } 126 133 } 127 134 private RandomCreator RandomCreator { … … 155 162 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 156 163 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); 164 Parameters.Add(new ValueParameter<IntValue>("SelectedParents", "Each two parents form a new child, typically this value should be twice the population size, but because the NSGA-II is maximally elitist it can be any multiple of 2 greater than 0.", new IntValue(200))); 157 165 158 166 RandomCreator randomCreator = new RandomCreator(); … … 268 276 ParameterizeAnalyzers(); 269 277 } 278 private void SelectedParentsParameter_ValueChanged(object sender, EventArgs e) { 279 SelectedParents.ValueChanged += new EventHandler(SelectedParents_ValueChanged); 280 SelectedParents_ValueChanged(null, EventArgs.Empty); 281 } 282 private void SelectedParents_ValueChanged(object sender, EventArgs e) { 283 if (SelectedParents.Value < 2) SelectedParents.Value = 2; 284 else if (SelectedParents.Value % 2 != 0) { 285 SelectedParents.Value = SelectedParents.Value + 1; 286 } 287 } 270 288 #endregion 271 289 … … 275 293 PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged); 276 294 PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged); 295 SelectedParentsParameter.ValueChanged += new EventHandler(SelectedParentsParameter_ValueChanged); 296 SelectedParents.ValueChanged += new EventHandler(SelectedParents_ValueChanged); 277 297 if (Problem != null) { 278 298 Problem.Evaluator.QualitiesParameter.ActualNameChanged += new EventHandler(Evaluator_QualitiesParameter_ActualNameChanged); … … 299 319 foreach (ISelector selector in SelectorParameter.ValidValues) { 300 320 selector.CopySelected = new BoolValue(true); 301 selector.NumberOfSelectedSubScopesParameter. Value = new IntValue(2 * PopulationSizeParameter.Value.Value);321 selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name; 302 322 ParameterizeStochasticOperator(selector); 303 323 }
Note: See TracChangeset
for help on using the changeset viewer.