Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4514 for branches


Ignore:
Timestamp:
09/27/10 10:40:51 (14 years ago)
Author:
abeham
Message:

#1040

  • Added SelectedParents parameter to define the size of the offspring population
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/NSGA2/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs

    r4168 r4514  
    8282      get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
    8383    }
     84    private ValueParameter<IntValue> SelectedParentsParameter {
     85      get { return (ValueParameter<IntValue>)Parameters["SelectedParents"]; }
     86    }
    8487    #endregion
    8588
     
    124127      get { return MaximumGenerationsParameter.Value; }
    125128      set { MaximumGenerationsParameter.Value = value; }
     129    }
     130    public IntValue SelectedParents {
     131      get { return SelectedParentsParameter.Value; }
     132      set { SelectedParentsParameter.Value = value; }
    126133    }
    127134    private RandomCreator RandomCreator {
     
    155162      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
    156163      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)));
    157165
    158166      RandomCreator randomCreator = new RandomCreator();
     
    268276      ParameterizeAnalyzers();
    269277    }
     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    }
    270288    #endregion
    271289
     
    275293      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
    276294      PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
     295      SelectedParentsParameter.ValueChanged += new EventHandler(SelectedParentsParameter_ValueChanged);
     296      SelectedParents.ValueChanged += new EventHandler(SelectedParents_ValueChanged);
    277297      if (Problem != null) {
    278298        Problem.Evaluator.QualitiesParameter.ActualNameChanged += new EventHandler(Evaluator_QualitiesParameter_ActualNameChanged);
     
    299319      foreach (ISelector selector in SelectorParameter.ValidValues) {
    300320        selector.CopySelected = new BoolValue(true);
    301         selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * PopulationSizeParameter.Value.Value);
     321        selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name;
    302322        ParameterizeStochasticOperator(selector);
    303323      }
Note: See TracChangeset for help on using the changeset viewer.