Changeset 15238


Ignore:
Timestamp:
07/13/17 17:46:58 (2 months ago)
Author:
mkommend
Message:

#2792: Merged r15006:r15008, r15047, r15049, r15070, r15107 into stable.

Location:
stable
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.ALPS

  • stable/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs

    r14997 r15238  
    251251    [StorableHook(HookType.AfterDeserialization)]
    252252    private void AfterDeserialization() {
     253      // BackwardsCompatibility3.3
     254      #region Backwards compatible code, remove with 3.4
     255      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     256      if (optionalMutatorParameter != null) {
     257        Parameters.Remove(optionalMutatorParameter);
     258        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     259        foreach (var m in optionalMutatorParameter.ValidValues)
     260          MutatorParameter.ValidValues.Add(m);
     261        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     262        else Mutator = optionalMutatorParameter.Value;
     263        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     264      }
     265      #endregion
    253266      Initialize();
    254267    }
     
    284297      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
    285298      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    286       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     299      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    287300      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    288301      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
     
    690703    }
    691704    private void UpdateMutators() {
    692       var oldMutator = MutatorParameter.Value;
     705      IManipulator oldMutator = MutatorParameter.Value;
    693706      MutatorParameter.ValidValues.Clear();
    694       foreach (var mutator in Problem.Operators.OfType<IManipulator>().OrderBy(m => m.Name)) {
     707      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     708
     709      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) {
    695710        ParameterizeStochasticOperatorForLayer(mutator);
    696711        MutatorParameter.ValidValues.Add(mutator);
    697712      }
     713
    698714      if (oldMutator != null) {
    699         var mutator = MutatorParameter.ValidValues.FirstOrDefault(m => m.GetType() == oldMutator.GetType());
    700         if (mutator != null)
    701           MutatorParameter.Value = mutator;
    702       }
     715        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
     716        if (mutator != null) MutatorParameter.Value = mutator;
     717        else oldMutator = null;
     718      }
     719
     720      if (oldMutator == null && defaultMutator != null)
     721        MutatorParameter.Value = defaultMutator;
    703722    }
    704723    private void UpdateTerminators() {
  • stable/HeuristicLab.Algorithms.ALPS/3.3/AlpsOffspringSelectionGeneticAlgorithm.cs

    r14186 r15238  
    298298    [StorableHook(HookType.AfterDeserialization)]
    299299    private void AfterDeserialization() {
     300      // BackwardsCompatibility3.3
     301      #region Backwards compatible code, remove with 3.4
     302      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     303      if (optionalMutatorParameter != null) {
     304        Parameters.Remove(optionalMutatorParameter);
     305        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     306        foreach (var m in optionalMutatorParameter.ValidValues)
     307          MutatorParameter.ValidValues.Add(m);
     308        if (optionalMutatorParameter.Value == null) MutationProbability = 0; // to guarantee that the old configuration results in the same behavior
     309        else Mutator = optionalMutatorParameter.Value;
     310        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     311      }
     312      #endregion
    300313      Initialize();
    301314    }
     
    334347      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
    335348      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    336       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     349      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    337350      Parameters.Add(new FixedValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    338351      Parameters.Add(new FixedValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
     
    755768    }
    756769    private void UpdateMutators() {
    757       var oldMutator = MutatorParameter.Value;
     770      IManipulator oldMutator = MutatorParameter.Value;
    758771      MutatorParameter.ValidValues.Clear();
    759       foreach (var mutator in Problem.Operators.OfType<IManipulator>().OrderBy(m => m.Name)) {
     772      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     773
     774      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) {
    760775        ParameterizeStochasticOperatorForLayer(mutator);
    761776        MutatorParameter.ValidValues.Add(mutator);
    762777      }
     778
    763779      if (oldMutator != null) {
    764         var mutator = MutatorParameter.ValidValues.FirstOrDefault(m => m.GetType() == oldMutator.GetType());
    765         if (mutator != null)
    766           MutatorParameter.Value = mutator;
    767       }
     780        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
     781        if (mutator != null) MutatorParameter.Value = mutator;
     782        else oldMutator = null;
     783      }
     784
     785      if (oldMutator == null && defaultMutator != null)
     786        MutatorParameter.Value = defaultMutator;
    768787    }
    769788    private void UpdateTerminators() {
  • stable/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r14186 r15238  
    156156      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    157157      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    158       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     158      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    159159      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    160160      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
     
    221221        Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true });
    222222      }
     223      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     224      if (optionalMutatorParameter != null) {
     225        Parameters.Remove(optionalMutatorParameter);
     226        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     227        foreach (var m in optionalMutatorParameter.ValidValues)
     228          MutatorParameter.ValidValues.Add(m);
     229        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     230        else Mutator = optionalMutatorParameter.Value;
     231        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     232      }
    223233      #endregion
    224234
     
    387397      IManipulator oldMutator = MutatorParameter.Value;
    388398      MutatorParameter.ValidValues.Clear();
     399      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     400
    389401      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
    390402        MutatorParameter.ValidValues.Add(mutator);
     403
    391404      if (oldMutator != null) {
    392405        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
    393406        if (mutator != null) MutatorParameter.Value = mutator;
    394       }
     407        else oldMutator = null;
     408      }
     409
     410      if (oldMutator == null && defaultMutator != null)
     411        MutatorParameter.Value = defaultMutator;
    395412    }
    396413    private void UpdateAnalyzers() {
  • stable/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r14186 r15238  
    211211        Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true });
    212212      }
     213      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     214      if (optionalMutatorParameter != null) {
     215        Parameters.Remove(optionalMutatorParameter);
     216        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     217        foreach (var m in optionalMutatorParameter.ValidValues)
     218          MutatorParameter.ValidValues.Add(m);
     219        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     220        else Mutator = optionalMutatorParameter.Value;
     221        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     222      }
    213223      #endregion
    214224
     
    240250      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    241251      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    242       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     252      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    243253      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    244254      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
     
    551561      IManipulator oldMutator = MutatorParameter.Value;
    552562      MutatorParameter.ValidValues.Clear();
     563      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     564
    553565      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) {
    554566        ParameterizeStochasticOperatorForIsland(mutator);
     
    558570        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
    559571        if (mutator != null) MutatorParameter.Value = mutator;
    560       }
     572        else oldMutator = null;
     573      }
     574
     575      if (oldMutator == null && defaultMutator != null)
     576        MutatorParameter.Value = defaultMutator;
    561577    }
    562578    private void UpdateAnalyzers() {
  • stable/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs

    r14186 r15238  
    176176      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    177177      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    178       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     178      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    179179      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
    180180      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
     
    326326      if (!Parameters.ContainsKey("DominateOnEqualQualities"))
    327327        Parameters.Add(new FixedValueParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false)));
     328      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     329      if (optionalMutatorParameter != null) {
     330        Parameters.Remove(optionalMutatorParameter);
     331        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     332        foreach (var m in optionalMutatorParameter.ValidValues)
     333          MutatorParameter.ValidValues.Add(m);
     334        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     335        else Mutator = optionalMutatorParameter.Value;
     336        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     337      }
    328338      #endregion
    329339
     
    397407      IManipulator oldMutator = MutatorParameter.Value;
    398408      MutatorParameter.ValidValues.Clear();
     409      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
    399410      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
    400411        MutatorParameter.ValidValues.Add(mutator);
     
    402413        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
    403414        if (mutator != null) MutatorParameter.Value = mutator;
    404       }
     415        else oldMutator = null;
     416      }
     417      if (oldMutator == null && defaultMutator != null)
     418        MutatorParameter.Value = defaultMutator;
    405419    }
    406420    private void UpdateAnalyzers() {
  • stable/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs

    r14186 r15238  
    280280      if (!Parameters.ContainsKey("FillPopulationWithParents"))
    281281        Parameters.Add(new FixedValueParameter<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.", new BoolValue(false)) { Hidden = true });
     282
     283      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     284      if (optionalMutatorParameter != null) {
     285        Parameters.Remove(optionalMutatorParameter);
     286        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     287        foreach (var m in optionalMutatorParameter.ValidValues)
     288          MutatorParameter.ValidValues.Add(m);
     289        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     290        else Mutator = optionalMutatorParameter.Value;
     291        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     292      }
    282293      #endregion
    283294
     
    311322      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    312323      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    313       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     324      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    314325      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    315326      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
     
    642653      IManipulator oldMutator = MutatorParameter.Value;
    643654      MutatorParameter.ValidValues.Clear();
     655      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     656
    644657      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
    645658        MutatorParameter.ValidValues.Add(mutator);
     659
    646660      if (oldMutator != null) {
    647661        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
    648662        if (mutator != null) MutatorParameter.Value = mutator;
    649       }
     663        else oldMutator = null;
     664      }
     665
     666      if (oldMutator == null && defaultMutator != null)
     667        MutatorParameter.Value = defaultMutator;
    650668    }
    651669    private void UpdateAnalyzers() {
  • stable/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs

    r14186 r15238  
    228228      if (!Parameters.ContainsKey("FillPopulationWithParents"))
    229229        Parameters.Add(new FixedValueParameter<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.", new BoolValue(false)) { Hidden = true });
     230
     231      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     232      if (optionalMutatorParameter != null) {
     233        Parameters.Remove(optionalMutatorParameter);
     234        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     235        foreach (var m in optionalMutatorParameter.ValidValues)
     236          MutatorParameter.ValidValues.Add(m);
     237        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     238        else Mutator = optionalMutatorParameter.Value;
     239        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     240      }
    230241      #endregion
    231242
     
    250261      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    251262      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    252       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     263      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    253264      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    254265      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
     
    487498      IManipulator oldMutator = MutatorParameter.Value;
    488499      MutatorParameter.ValidValues.Clear();
     500      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     501
    489502      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
    490503        MutatorParameter.ValidValues.Add(mutator);
     504
    491505      if (oldMutator != null) {
    492506        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
    493507        if (mutator != null) MutatorParameter.Value = mutator;
    494       }
     508        else oldMutator = null;
     509      }
     510
     511      if (oldMutator == null && defaultMutator != null)
     512        MutatorParameter.Value = defaultMutator;
    495513    }
    496514    private void UpdateAnalyzers() {
  • stable/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs

    r14186 r15238  
    256256      if (!Parameters.ContainsKey("FillPopulationWithParents"))
    257257        Parameters.Add(new FixedValueParameter<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.", new BoolValue(false)) { Hidden = true });
     258
     259      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
     260      if (optionalMutatorParameter != null) {
     261        Parameters.Remove(optionalMutatorParameter);
     262        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     263        foreach (var m in optionalMutatorParameter.ValidValues)
     264          MutatorParameter.ValidValues.Add(m);
     265        if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior
     266        else Mutator = optionalMutatorParameter.Value;
     267        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
     268      }
    258269      #endregion
    259270
     
    282293      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
    283294      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
    284       Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
     295      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
    285296      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    286297      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
     
    561572      ICrossover oldCrossover = CrossoverParameter.Value;
    562573      CrossoverParameter.ValidValues.Clear();
     574      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
     575
    563576      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
    564577        CrossoverParameter.ValidValues.Add(crossover);
     578
    565579      if (oldCrossover != null) {
    566580        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
    567581        if (crossover != null) CrossoverParameter.Value = crossover;
    568       }
     582        else oldCrossover = null;
     583      }
     584      if (oldCrossover == null && defaultCrossover != null)
     585        CrossoverParameter.Value = defaultCrossover;
    569586    }
    570587    private void UpdateMutators() {
    571588      IManipulator oldMutator = MutatorParameter.Value;
    572589      MutatorParameter.ValidValues.Clear();
     590      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
     591
    573592      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
    574593        MutatorParameter.ValidValues.Add(mutator);
     594
    575595      if (oldMutator != null) {
    576596        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
    577597        if (mutator != null) MutatorParameter.Value = mutator;
    578       }
     598        else oldMutator = null;
     599      }
     600
     601      if (oldMutator == null && defaultMutator != null)
     602        MutatorParameter.Value = defaultMutator;
    579603    }
    580604    private void UpdateAnalyzers() {
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r15131 r15238  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     
    241242
    242243    private void InitializeOperators() {
    243       Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
    244       Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionCrossover<T>>());
    245       Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
    246       Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer());
    247       Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
    248       Operators.Add(new SymbolicExpressionTreeLengthAnalyzer());
    249       Operators.Add(new SymbolicExpressionTreeBottomUpSimilarityCalculator());
    250       Operators.Add(new SymbolicDataAnalysisBottomUpDiversityAnalyzer(Operators.OfType<SymbolicExpressionTreeBottomUpSimilarityCalculator>().First()));
     244      var operators = new HashSet<IItem>(new TypeEqualityComparer<IItem>());
     245      operators.Add(new SubtreeCrossover());
     246      operators.Add(new MultiSymbolicExpressionTreeManipulator());
     247
     248      foreach (var op in ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>())
     249        operators.Add(op);
     250      foreach (var op in ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionCrossover<T>>())
     251        operators.Add(op);
     252
     253      operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
     254      operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer());
     255      operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
     256      operators.Add(new SymbolicExpressionTreeLengthAnalyzer());
     257      operators.Add(new SymbolicExpressionTreeBottomUpSimilarityCalculator());
     258      operators.Add(new SymbolicDataAnalysisBottomUpDiversityAnalyzer(operators.OfType<SymbolicExpressionTreeBottomUpSimilarityCalculator>().First()));
     259
     260      Operators.AddRange(operators);
    251261      ParameterizeOperators();
    252262    }
Note: See TracChangeset for help on using the changeset viewer.