Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/12/14 13:26:18 (10 years ago)
Author:
pfleck
Message:
  • Merged trunk into preprocessing branch.
Location:
branches/DataPreprocessing
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing

  • branches/DataPreprocessing/HeuristicLab.Selection/3.3/OffspringSelector.cs

    r9456 r11009  
    5757    }
    5858
     59    public IValueLookupParameter<BoolValue> FillPopulationWithParentsParameter {
     60      get { return (IValueLookupParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
     61    }
     62
    5963    public IOperator OffspringCreator {
    6064      get { return OffspringCreatorParameter.Value; }
     
    6468    [StorableConstructor]
    6569    protected OffspringSelector(bool deserializing) : base(deserializing) { }
     70    [StorableHook(HookType.AfterDeserialization)]
     71    private void AfterDeserialization() {
     72      // BackwardsCompatibility3.3
     73      #region Backwards compatible code, remove with 3.4
     74      if (Parameters.ContainsKey("FillPopulationWithParents") && Parameters["FillPopulationWithParents"] is FixedValueParameter<BoolValue>)
     75        Parameters.Remove("FillPopulationWithParents");
     76      if (!Parameters.ContainsKey("FillPopulationWithParents"))
     77        Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individuals instead of lucky losers."));
     78      #endregion
     79    }
     80
    6681    protected OffspringSelector(OffspringSelector original, Cloner cloner) : base(original, cloner) { }
    6782    public override IDeepCloneable Clone(Cloner cloner) {
     
    7893      Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("SuccessfulOffspring", "True if the offspring was more successful than its parents.", 2));
    7994      Parameters.Add(new OperatorParameter("OffspringCreator", "The operator used to create new offspring."));
     95      Parameters.Add(new ValueLookupParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded."));
    8096    }
    8197
     
    8399      double maxSelPress = MaximumSelectionPressureParameter.ActualValue.Value;
    84100      double successRatio = SuccessRatioParameter.ActualValue.Value;
     101      bool fillPopulationWithParents = false;
     102      if (FillPopulationWithParentsParameter.ActualValue != null)
     103        fillPopulationWithParents = FillPopulationWithParentsParameter.ActualValue.Value;
    85104      IScope scope = ExecutionContext.Scope;
    86105      IScope parents = scope.SubScopes[0];
     
    133152          successfulOffspringAdded++;
    134153        } else if (worseOffspringNeeded > 0 || tmpSelPress >= maxSelPress) {
    135           IScope currentOffspring = offspring.SubScopes[i];
    136           offspring.SubScopes.Remove(currentOffspring);
    137           i--;
     154          IScope currentOffspring;
     155          if (!fillPopulationWithParents || worseOffspringNeeded > 0) {
     156            currentOffspring = offspring.SubScopes[i];
     157            offspring.SubScopes.Remove(currentOffspring);
     158            i--;
     159            worseOffspringNeeded--;
     160          } else {
     161            currentOffspring = parents.SubScopes[i];
     162          }
    138163          population.Add(currentOffspring);
    139           worseOffspringNeeded--;
    140164        }
    141165        tmpSelPress += tmpSelPressInc;
Note: See TracChangeset for help on using the changeset viewer.