Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/05/19 10:26:41 (5 years ago)
Author:
gkronber
Message:

#2950: made some small changes while reviewing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Selectors/DiversitySelector.cs

    r16839 r17076  
    6666    }
    6767
    68     public bool StrictSimilarity { get { return StrictSimilarityParameter.Value.Value; } }
    69 
    70     public double SimilarityWeight { get { return SimilarityWeightParameter.Value.Value; } }
     68    public bool StrictSimilarity {
     69      get { return StrictSimilarityParameter.Value.Value; }
     70      set { StrictSimilarityParameter.Value.Value = value; }
     71    }
     72
     73    public double SimilarityWeight {
     74      get { return SimilarityWeightParameter.Value.Value; }
     75      set { SimilarityWeightParameter.Value.Value = value; }
     76    }
    7177
    7278    public DiversitySelector() : base() {
     
    7480      Parameters.Add(new FixedValueParameter<DoubleValue>(SimilarityWeightParameterName, "Weight of the diversity term.", new DoubleValue(1)));
    7581      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees that should be analyzed."));
    76       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(DiversityParameterName));
    7782      Parameters.Add(new ValueParameter<ISingleObjectiveSelector>(SelectorParameterName, "The inner selection operator to select the parents.", new TournamentSelector()));
     83      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(DiversityParameterName, "The diversity value calcuated by the operator (output). The inner selector uses this value."));
    7884
    7985      RegisterParameterEventHandlers();
     
    8187
    8288    [StorableConstructor]
    83     private DiversitySelector(StorableConstructorFlag deserializing) : base(deserializing) { }
     89    private DiversitySelector(StorableConstructorFlag _) : base(_) { }
    8490
    8591    private DiversitySelector(DiversitySelector original, Cloner cloner) : base(original, cloner) { }
     
    9197    [StorableHook(HookType.AfterDeserialization)]
    9298    private void AfterDeserialization() {
    93       RegisterParameterEventHandlers();
    94 
    9599      if (!Parameters.ContainsKey(DiversityParameterName)) {
    96100        Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(DiversityParameterName));
    97101      }
     102
     103      RegisterParameterEventHandlers();
    98104    }
    99105
     
    103109      CopySelectedParameter.ValueChanged += CopySelectedParameter_ValueChanged;
    104110      CopySelected.ValueChanged += CopySelected_ValueChanged;
    105     }
     111
     112      MaximizationParameter.NameChanged += MaximizationParameter_NameChanged;
     113      QualityParameter.NameChanged += QualityParameter_NameChanged;
     114      RandomParameter.NameChanged += RandomParameter_NameChanged;
     115    }
     116
     117    private void RandomParameter_NameChanged(object sender, EventArgs e) { ParameterizeSelector(Selector); }
     118    private void QualityParameter_NameChanged(object sender, EventArgs e) { ParameterizeSelector(Selector); }
     119    private void MaximizationParameter_NameChanged(object sender, EventArgs e) { ParameterizeSelector(Selector); }
    106120
    107121    private void CopySelectedParameter_ValueChanged(object sender, EventArgs e) {
     
    127141      if (w.IsAlmost(0)) {
    128142        ApplyInnerSelector();
    129         return CurrentScope.SubScopes[1].SubScopes.ToArray();
     143        return CurrentScope.SubScopes[1].SubScopes.ToArray();  // return selected individuals (selectors create two sub-scopes with remaining and selected)
    130144      }
    131145
Note: See TracChangeset for help on using the changeset viewer.