[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[2851] | 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[2865] | 22 | using System;
|
---|
| 23 | using System.Linq;
|
---|
[4068] | 24 | using HeuristicLab.Analysis;
|
---|
[3376] | 25 | using HeuristicLab.Common;
|
---|
[2] | 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
[2851] | 28 | using HeuristicLab.Optimization;
|
---|
[3021] | 29 | using HeuristicLab.Optimization.Operators;
|
---|
[2852] | 30 | using HeuristicLab.Parameters;
|
---|
| 31 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[2882] | 32 | using HeuristicLab.PluginInfrastructure;
|
---|
[3368] | 33 | using HeuristicLab.Random;
|
---|
[2] | 34 |
|
---|
[3196] | 35 | namespace HeuristicLab.Algorithms.GeneticAlgorithm {
|
---|
[1153] | 36 | /// <summary>
|
---|
[3198] | 37 | /// A genetic algorithm.
|
---|
[1153] | 38 | /// </summary>
|
---|
[3198] | 39 | [Item("Genetic Algorithm", "A genetic algorithm.")]
|
---|
[2851] | 40 | [Creatable("Algorithms")]
|
---|
[3017] | 41 | [StorableClass]
|
---|
[3198] | 42 | public sealed class GeneticAlgorithm : EngineAlgorithm {
|
---|
[2986] | 43 | #region Problem Properties
|
---|
| 44 | public override Type ProblemType {
|
---|
| 45 | get { return typeof(ISingleObjectiveProblem); }
|
---|
| 46 | }
|
---|
| 47 | public new ISingleObjectiveProblem Problem {
|
---|
| 48 | get { return (ISingleObjectiveProblem)base.Problem; }
|
---|
| 49 | set { base.Problem = value; }
|
---|
| 50 | }
|
---|
| 51 | #endregion
|
---|
[2852] | 52 |
|
---|
[2986] | 53 | #region Parameter Properties
|
---|
[3048] | 54 | private ValueParameter<IntValue> SeedParameter {
|
---|
| 55 | get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
|
---|
[2986] | 56 | }
|
---|
[3048] | 57 | private ValueParameter<BoolValue> SetSeedRandomlyParameter {
|
---|
| 58 | get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
|
---|
[2986] | 59 | }
|
---|
[3048] | 60 | private ValueParameter<IntValue> PopulationSizeParameter {
|
---|
| 61 | get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
[2986] | 62 | }
|
---|
| 63 | private ConstrainedValueParameter<ISelector> SelectorParameter {
|
---|
| 64 | get { return (ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
|
---|
| 65 | }
|
---|
| 66 | private ConstrainedValueParameter<ICrossover> CrossoverParameter {
|
---|
| 67 | get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
|
---|
| 68 | }
|
---|
[3095] | 69 | private ValueParameter<PercentValue> MutationProbabilityParameter {
|
---|
| 70 | get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
[2986] | 71 | }
|
---|
| 72 | private OptionalConstrainedValueParameter<IManipulator> MutatorParameter {
|
---|
| 73 | get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
|
---|
| 74 | }
|
---|
[3048] | 75 | private ValueParameter<IntValue> ElitesParameter {
|
---|
| 76 | get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
|
---|
[2986] | 77 | }
|
---|
[3658] | 78 | private ValueParameter<MultiAnalyzer> AnalyzerParameter {
|
---|
| 79 | get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
|
---|
[3616] | 80 | }
|
---|
[3048] | 81 | private ValueParameter<IntValue> MaximumGenerationsParameter {
|
---|
| 82 | get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
[2986] | 83 | }
|
---|
| 84 | #endregion
|
---|
[2865] | 85 |
|
---|
[2986] | 86 | #region Properties
|
---|
[3048] | 87 | public IntValue Seed {
|
---|
[2986] | 88 | get { return SeedParameter.Value; }
|
---|
| 89 | set { SeedParameter.Value = value; }
|
---|
| 90 | }
|
---|
[3048] | 91 | public BoolValue SetSeedRandomly {
|
---|
[2986] | 92 | get { return SetSeedRandomlyParameter.Value; }
|
---|
| 93 | set { SetSeedRandomlyParameter.Value = value; }
|
---|
| 94 | }
|
---|
[3048] | 95 | public IntValue PopulationSize {
|
---|
[2986] | 96 | get { return PopulationSizeParameter.Value; }
|
---|
| 97 | set { PopulationSizeParameter.Value = value; }
|
---|
| 98 | }
|
---|
| 99 | public ISelector Selector {
|
---|
| 100 | get { return SelectorParameter.Value; }
|
---|
| 101 | set { SelectorParameter.Value = value; }
|
---|
| 102 | }
|
---|
| 103 | public ICrossover Crossover {
|
---|
| 104 | get { return CrossoverParameter.Value; }
|
---|
| 105 | set { CrossoverParameter.Value = value; }
|
---|
| 106 | }
|
---|
[3095] | 107 | public PercentValue MutationProbability {
|
---|
[2986] | 108 | get { return MutationProbabilityParameter.Value; }
|
---|
| 109 | set { MutationProbabilityParameter.Value = value; }
|
---|
| 110 | }
|
---|
| 111 | public IManipulator Mutator {
|
---|
| 112 | get { return MutatorParameter.Value; }
|
---|
| 113 | set { MutatorParameter.Value = value; }
|
---|
| 114 | }
|
---|
[3048] | 115 | public IntValue Elites {
|
---|
[2986] | 116 | get { return ElitesParameter.Value; }
|
---|
| 117 | set { ElitesParameter.Value = value; }
|
---|
| 118 | }
|
---|
[3658] | 119 | public MultiAnalyzer Analyzer {
|
---|
[3616] | 120 | get { return AnalyzerParameter.Value; }
|
---|
| 121 | set { AnalyzerParameter.Value = value; }
|
---|
| 122 | }
|
---|
[3048] | 123 | public IntValue MaximumGenerations {
|
---|
[2986] | 124 | get { return MaximumGenerationsParameter.Value; }
|
---|
| 125 | set { MaximumGenerationsParameter.Value = value; }
|
---|
| 126 | }
|
---|
| 127 | private RandomCreator RandomCreator {
|
---|
| 128 | get { return (RandomCreator)OperatorGraph.InitialOperator; }
|
---|
| 129 | }
|
---|
[3023] | 130 | private SolutionsCreator SolutionsCreator {
|
---|
| 131 | get { return (SolutionsCreator)RandomCreator.Successor; }
|
---|
[2986] | 132 | }
|
---|
[3198] | 133 | private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop {
|
---|
| 134 | get { return (GeneticAlgorithmMainLoop)SolutionsCreator.Successor; }
|
---|
[2986] | 135 | }
|
---|
[3680] | 136 | [Storable]
|
---|
[3662] | 137 | private BestAverageWorstQualityAnalyzer qualityAnalyzer;
|
---|
[2986] | 138 | #endregion
|
---|
[2852] | 139 |
|
---|
[3198] | 140 | public GeneticAlgorithm()
|
---|
[2986] | 141 | : base() {
|
---|
[3048] | 142 | Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
|
---|
| 143 | Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
|
---|
| 144 | Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
|
---|
[2986] | 145 | Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
|
---|
| 146 | Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
|
---|
[3095] | 147 | Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
|
---|
[2986] | 148 | Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
|
---|
[3048] | 149 | Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
|
---|
[3658] | 150 | Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
|
---|
[3048] | 151 | Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
|
---|
[2] | 152 |
|
---|
[2986] | 153 | RandomCreator randomCreator = new RandomCreator();
|
---|
[3023] | 154 | SolutionsCreator solutionsCreator = new SolutionsCreator();
|
---|
[3198] | 155 | GeneticAlgorithmMainLoop geneticAlgorithmMainLoop = new GeneticAlgorithmMainLoop();
|
---|
[2986] | 156 | OperatorGraph.InitialOperator = randomCreator;
|
---|
[2882] | 157 |
|
---|
[2986] | 158 | randomCreator.RandomParameter.ActualName = "Random";
|
---|
| 159 | randomCreator.SeedParameter.ActualName = SeedParameter.Name;
|
---|
| 160 | randomCreator.SeedParameter.Value = null;
|
---|
| 161 | randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
|
---|
| 162 | randomCreator.SetSeedRandomlyParameter.Value = null;
|
---|
[3023] | 163 | randomCreator.Successor = solutionsCreator;
|
---|
[2] | 164 |
|
---|
[3023] | 165 | solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
|
---|
[3198] | 166 | solutionsCreator.Successor = geneticAlgorithmMainLoop;
|
---|
[2] | 167 |
|
---|
[3198] | 168 | geneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
|
---|
| 169 | geneticAlgorithmMainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
|
---|
| 170 | geneticAlgorithmMainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
| 171 | geneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
| 172 | geneticAlgorithmMainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
|
---|
| 173 | geneticAlgorithmMainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
|
---|
| 174 | geneticAlgorithmMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
[3616] | 175 | geneticAlgorithmMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
|
---|
[3198] | 176 | geneticAlgorithmMainLoop.ResultsParameter.ActualName = "Results";
|
---|
[2] | 177 |
|
---|
[3680] | 178 | foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
|
---|
| 179 | SelectorParameter.ValidValues.Add(selector);
|
---|
| 180 | ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
|
---|
| 181 | if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
|
---|
| 182 | ParameterizeSelectors();
|
---|
| 183 |
|
---|
| 184 | qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
|
---|
| 185 | ParameterizeAnalyzers();
|
---|
| 186 | UpdateAnalyzers();
|
---|
| 187 |
|
---|
[3280] | 188 | Initialize();
|
---|
[2986] | 189 | }
|
---|
| 190 | [StorableConstructor]
|
---|
[3280] | 191 | private GeneticAlgorithm(bool deserializing) : base(deserializing) { }
|
---|
[2] | 192 |
|
---|
[2986] | 193 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[3198] | 194 | GeneticAlgorithm clone = (GeneticAlgorithm)base.Clone(cloner);
|
---|
[3680] | 195 | clone.qualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(qualityAnalyzer);
|
---|
[3280] | 196 | clone.Initialize();
|
---|
[2986] | 197 | return clone;
|
---|
| 198 | }
|
---|
[2882] | 199 |
|
---|
[3275] | 200 | public override void Prepare() {
|
---|
| 201 | if (Problem != null) base.Prepare();
|
---|
[3188] | 202 | }
|
---|
| 203 |
|
---|
[2986] | 204 | #region Events
|
---|
| 205 | protected override void OnProblemChanged() {
|
---|
| 206 | ParameterizeStochasticOperator(Problem.SolutionCreator);
|
---|
| 207 | ParameterizeStochasticOperator(Problem.Evaluator);
|
---|
| 208 | foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
|
---|
[3023] | 209 | ParameterizeSolutionsCreator();
|
---|
[3198] | 210 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[2986] | 211 | ParameterizeSelectors();
|
---|
[3616] | 212 | ParameterizeAnalyzers();
|
---|
[3750] | 213 | ParameterizeIterationBasedOperators();
|
---|
[2986] | 214 | UpdateCrossovers();
|
---|
| 215 | UpdateMutators();
|
---|
[3616] | 216 | UpdateAnalyzers();
|
---|
[2986] | 217 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 218 | base.OnProblemChanged();
|
---|
| 219 | }
|
---|
[3139] | 220 |
|
---|
[2986] | 221 | protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
|
---|
| 222 | ParameterizeStochasticOperator(Problem.SolutionCreator);
|
---|
[3023] | 223 | ParameterizeSolutionsCreator();
|
---|
[2986] | 224 | base.Problem_SolutionCreatorChanged(sender, e);
|
---|
| 225 | }
|
---|
| 226 | protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
|
---|
| 227 | ParameterizeStochasticOperator(Problem.Evaluator);
|
---|
[3023] | 228 | ParameterizeSolutionsCreator();
|
---|
[3198] | 229 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[2986] | 230 | ParameterizeSelectors();
|
---|
[3616] | 231 | ParameterizeAnalyzers();
|
---|
[2986] | 232 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 233 | base.Problem_EvaluatorChanged(sender, e);
|
---|
| 234 | }
|
---|
| 235 | protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
|
---|
| 236 | foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
|
---|
[3750] | 237 | ParameterizeIterationBasedOperators();
|
---|
[2986] | 238 | UpdateCrossovers();
|
---|
| 239 | UpdateMutators();
|
---|
[3616] | 240 | UpdateAnalyzers();
|
---|
[2986] | 241 | base.Problem_OperatorsChanged(sender, e);
|
---|
| 242 | }
|
---|
| 243 | private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 244 | Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
|
---|
| 245 | ParameterizeSelectors();
|
---|
| 246 | }
|
---|
| 247 | private void Elites_ValueChanged(object sender, EventArgs e) {
|
---|
| 248 | ParameterizeSelectors();
|
---|
| 249 | }
|
---|
| 250 | private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 251 | PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
|
---|
| 252 | ParameterizeSelectors();
|
---|
| 253 | }
|
---|
| 254 | private void PopulationSize_ValueChanged(object sender, EventArgs e) {
|
---|
| 255 | ParameterizeSelectors();
|
---|
| 256 | }
|
---|
| 257 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
[3198] | 258 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[2986] | 259 | ParameterizeSelectors();
|
---|
[3616] | 260 | ParameterizeAnalyzers();
|
---|
[2986] | 261 | }
|
---|
| 262 | #endregion
|
---|
[2852] | 263 |
|
---|
[2986] | 264 | #region Helpers
|
---|
| 265 | [StorableHook(HookType.AfterDeserialization)]
|
---|
[3280] | 266 | private void Initialize() {
|
---|
[2986] | 267 | PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
|
---|
| 268 | PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
|
---|
| 269 | ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
|
---|
| 270 | Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
|
---|
[3139] | 271 | if (Problem != null) {
|
---|
[2986] | 272 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3139] | 273 | }
|
---|
[2986] | 274 | }
|
---|
[2852] | 275 |
|
---|
[3023] | 276 | private void ParameterizeSolutionsCreator() {
|
---|
| 277 | SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
| 278 | SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
|
---|
[2986] | 279 | }
|
---|
[3198] | 280 | private void ParameterizeGeneticAlgorithmMainLoop() {
|
---|
| 281 | GeneticAlgorithmMainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
| 282 | GeneticAlgorithmMainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 283 | GeneticAlgorithmMainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
[2986] | 284 | }
|
---|
| 285 | private void ParameterizeStochasticOperator(IOperator op) {
|
---|
| 286 | if (op is IStochasticOperator)
|
---|
| 287 | ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
| 288 | }
|
---|
| 289 | private void ParameterizeSelectors() {
|
---|
[3680] | 290 | foreach (ISelector selector in SelectorParameter.ValidValues) {
|
---|
[3048] | 291 | selector.CopySelected = new BoolValue(true);
|
---|
| 292 | selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSizeParameter.Value.Value - ElitesParameter.Value.Value));
|
---|
[2986] | 293 | ParameterizeStochasticOperator(selector);
|
---|
| 294 | }
|
---|
| 295 | if (Problem != null) {
|
---|
[3680] | 296 | foreach (ISingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
|
---|
[2986] | 297 | selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 298 | selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
[3616] | 302 | private void ParameterizeAnalyzers() {
|
---|
| 303 | qualityAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
| 304 | if (Problem != null) {
|
---|
| 305 | qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 306 | qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
[3662] | 307 | qualityAnalyzer.QualityParameter.Depth = 1;
|
---|
[3616] | 308 | qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
|
---|
| 309 | }
|
---|
| 310 | }
|
---|
[3750] | 311 | private void ParameterizeIterationBasedOperators() {
|
---|
| 312 | if (Problem != null) {
|
---|
| 313 | foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
|
---|
| 314 | op.IterationsParameter.ActualName = "Generations";
|
---|
| 315 | op.MaximumIterationsParameter.ActualName = "MaximumGenerations";
|
---|
| 316 | }
|
---|
| 317 | }
|
---|
| 318 | }
|
---|
[2986] | 319 | private void UpdateCrossovers() {
|
---|
[3303] | 320 | ICrossover oldCrossover = CrossoverParameter.Value;
|
---|
| 321 | CrossoverParameter.ValidValues.Clear();
|
---|
| 322 | foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
|
---|
| 323 | CrossoverParameter.ValidValues.Add(crossover);
|
---|
| 324 | if (oldCrossover != null) {
|
---|
| 325 | ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
|
---|
| 326 | if (crossover != null) CrossoverParameter.Value = crossover;
|
---|
[3076] | 327 | }
|
---|
[2986] | 328 | }
|
---|
| 329 | private void UpdateMutators() {
|
---|
[3303] | 330 | IManipulator oldMutator = MutatorParameter.Value;
|
---|
| 331 | MutatorParameter.ValidValues.Clear();
|
---|
| 332 | foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
|
---|
| 333 | MutatorParameter.ValidValues.Add(mutator);
|
---|
| 334 | if (oldMutator != null) {
|
---|
| 335 | IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
|
---|
| 336 | if (mutator != null) MutatorParameter.Value = mutator;
|
---|
[3076] | 337 | }
|
---|
[2986] | 338 | }
|
---|
[3616] | 339 | private void UpdateAnalyzers() {
|
---|
| 340 | Analyzer.Operators.Clear();
|
---|
| 341 | if (Problem != null) {
|
---|
[3816] | 342 | foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
|
---|
[3663] | 343 | foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
|
---|
| 344 | param.Depth = 1;
|
---|
[3616] | 345 | Analyzer.Operators.Add(analyzer);
|
---|
[3662] | 346 | }
|
---|
[3616] | 347 | }
|
---|
[3799] | 348 | Analyzer.Operators.Add(qualityAnalyzer);
|
---|
[3616] | 349 | }
|
---|
[2986] | 350 | #endregion
|
---|
[2] | 351 | }
|
---|
| 352 | }
|
---|