Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/07/19 13:32:09 (5 years ago)
Author:
mkommend
Message:

#2974: Merged trunk changes into branch.

Location:
branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Selectors/DiversitySelector.cs

    r16623 r17193  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    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
    100106    #region Events
    101107    private void RegisterParameterEventHandlers() {
    102       SelectorParameter.ValueChanged += new EventHandler(SelectorParameter_ValueChanged);
    103       CopySelected.ValueChanged += new EventHandler(CopySelected_ValueChanged);
     108      SelectorParameter.ValueChanged += SelectorParameter_ValueChanged;
     109      CopySelectedParameter.ValueChanged += CopySelectedParameter_ValueChanged;
     110      CopySelected.ValueChanged += CopySelected_ValueChanged;
     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); }
     120
     121    private void CopySelectedParameter_ValueChanged(object sender, EventArgs e) {
     122      if (CopySelected.Value != true) {
     123        CopySelected.Value = true;
     124      }
     125      CopySelected.ValueChanged += CopySelected_ValueChanged;
    104126    }
    105127
     
    119141      if (w.IsAlmost(0)) {
    120142        ApplyInnerSelector();
    121         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)
    122144      }
    123145
Note: See TracChangeset for help on using the changeset viewer.