[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;
|
---|
[2986] | 23 | using System.Collections.Generic;
|
---|
[2865] | 24 | using System.Linq;
|
---|
[2] | 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Data;
|
---|
[2851] | 27 | using HeuristicLab.Operators;
|
---|
| 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;
|
---|
[2] | 33 |
|
---|
[3196] | 34 | namespace HeuristicLab.Algorithms.GeneticAlgorithm {
|
---|
[1153] | 35 | /// <summary>
|
---|
[3198] | 36 | /// A genetic algorithm.
|
---|
[1153] | 37 | /// </summary>
|
---|
[3198] | 38 | [Item("Genetic Algorithm", "A genetic algorithm.")]
|
---|
[2851] | 39 | [Creatable("Algorithms")]
|
---|
[3017] | 40 | [StorableClass]
|
---|
[3198] | 41 | public sealed class GeneticAlgorithm : EngineAlgorithm {
|
---|
[2986] | 42 | #region Problem Properties
|
---|
| 43 | public override Type ProblemType {
|
---|
| 44 | get { return typeof(ISingleObjectiveProblem); }
|
---|
| 45 | }
|
---|
| 46 | public new ISingleObjectiveProblem Problem {
|
---|
| 47 | get { return (ISingleObjectiveProblem)base.Problem; }
|
---|
| 48 | set { base.Problem = value; }
|
---|
| 49 | }
|
---|
| 50 | #endregion
|
---|
[2852] | 51 |
|
---|
[2986] | 52 | #region Parameter Properties
|
---|
[3048] | 53 | private ValueParameter<IntValue> SeedParameter {
|
---|
| 54 | get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
|
---|
[2986] | 55 | }
|
---|
[3048] | 56 | private ValueParameter<BoolValue> SetSeedRandomlyParameter {
|
---|
| 57 | get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
|
---|
[2986] | 58 | }
|
---|
[3048] | 59 | private ValueParameter<IntValue> PopulationSizeParameter {
|
---|
| 60 | get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
[2986] | 61 | }
|
---|
| 62 | private ConstrainedValueParameter<ISelector> SelectorParameter {
|
---|
| 63 | get { return (ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
|
---|
| 64 | }
|
---|
| 65 | private ConstrainedValueParameter<ICrossover> CrossoverParameter {
|
---|
| 66 | get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
|
---|
| 67 | }
|
---|
[3095] | 68 | private ValueParameter<PercentValue> MutationProbabilityParameter {
|
---|
| 69 | get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
[2986] | 70 | }
|
---|
| 71 | private OptionalConstrainedValueParameter<IManipulator> MutatorParameter {
|
---|
| 72 | get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
|
---|
| 73 | }
|
---|
[3048] | 74 | private ValueParameter<IntValue> ElitesParameter {
|
---|
| 75 | get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
|
---|
[2986] | 76 | }
|
---|
[3048] | 77 | private ValueParameter<IntValue> MaximumGenerationsParameter {
|
---|
| 78 | get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
[2986] | 79 | }
|
---|
| 80 | #endregion
|
---|
[2865] | 81 |
|
---|
[2986] | 82 | #region Properties
|
---|
[3048] | 83 | public IntValue Seed {
|
---|
[2986] | 84 | get { return SeedParameter.Value; }
|
---|
| 85 | set { SeedParameter.Value = value; }
|
---|
| 86 | }
|
---|
[3048] | 87 | public BoolValue SetSeedRandomly {
|
---|
[2986] | 88 | get { return SetSeedRandomlyParameter.Value; }
|
---|
| 89 | set { SetSeedRandomlyParameter.Value = value; }
|
---|
| 90 | }
|
---|
[3048] | 91 | public IntValue PopulationSize {
|
---|
[2986] | 92 | get { return PopulationSizeParameter.Value; }
|
---|
| 93 | set { PopulationSizeParameter.Value = value; }
|
---|
| 94 | }
|
---|
| 95 | public ISelector Selector {
|
---|
| 96 | get { return SelectorParameter.Value; }
|
---|
| 97 | set { SelectorParameter.Value = value; }
|
---|
| 98 | }
|
---|
| 99 | public ICrossover Crossover {
|
---|
| 100 | get { return CrossoverParameter.Value; }
|
---|
| 101 | set { CrossoverParameter.Value = value; }
|
---|
| 102 | }
|
---|
[3095] | 103 | public PercentValue MutationProbability {
|
---|
[2986] | 104 | get { return MutationProbabilityParameter.Value; }
|
---|
| 105 | set { MutationProbabilityParameter.Value = value; }
|
---|
| 106 | }
|
---|
| 107 | public IManipulator Mutator {
|
---|
| 108 | get { return MutatorParameter.Value; }
|
---|
| 109 | set { MutatorParameter.Value = value; }
|
---|
| 110 | }
|
---|
[3048] | 111 | public IntValue Elites {
|
---|
[2986] | 112 | get { return ElitesParameter.Value; }
|
---|
| 113 | set { ElitesParameter.Value = value; }
|
---|
| 114 | }
|
---|
[3048] | 115 | public IntValue MaximumGenerations {
|
---|
[2986] | 116 | get { return MaximumGenerationsParameter.Value; }
|
---|
| 117 | set { MaximumGenerationsParameter.Value = value; }
|
---|
| 118 | }
|
---|
| 119 | private RandomCreator RandomCreator {
|
---|
| 120 | get { return (RandomCreator)OperatorGraph.InitialOperator; }
|
---|
| 121 | }
|
---|
[3023] | 122 | private SolutionsCreator SolutionsCreator {
|
---|
| 123 | get { return (SolutionsCreator)RandomCreator.Successor; }
|
---|
[2986] | 124 | }
|
---|
[3198] | 125 | private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop {
|
---|
| 126 | get { return (GeneticAlgorithmMainLoop)SolutionsCreator.Successor; }
|
---|
[2986] | 127 | }
|
---|
| 128 | private List<ISelector> selectors;
|
---|
| 129 | private IEnumerable<ISelector> Selectors {
|
---|
| 130 | get { return selectors; }
|
---|
| 131 | }
|
---|
| 132 | #endregion
|
---|
[2852] | 133 |
|
---|
[3198] | 134 | public GeneticAlgorithm()
|
---|
[2986] | 135 | : base() {
|
---|
[3048] | 136 | Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
|
---|
| 137 | Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
|
---|
| 138 | Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
|
---|
[2986] | 139 | Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
|
---|
| 140 | Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
|
---|
[3095] | 141 | Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
|
---|
[2986] | 142 | Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
|
---|
[3048] | 143 | Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
|
---|
| 144 | Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
|
---|
[2] | 145 |
|
---|
[2986] | 146 | RandomCreator randomCreator = new RandomCreator();
|
---|
[3023] | 147 | SolutionsCreator solutionsCreator = new SolutionsCreator();
|
---|
[3198] | 148 | GeneticAlgorithmMainLoop geneticAlgorithmMainLoop = new GeneticAlgorithmMainLoop();
|
---|
[2986] | 149 | OperatorGraph.InitialOperator = randomCreator;
|
---|
[2882] | 150 |
|
---|
[2986] | 151 | randomCreator.RandomParameter.ActualName = "Random";
|
---|
| 152 | randomCreator.SeedParameter.ActualName = SeedParameter.Name;
|
---|
| 153 | randomCreator.SeedParameter.Value = null;
|
---|
| 154 | randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
|
---|
| 155 | randomCreator.SetSeedRandomlyParameter.Value = null;
|
---|
[3023] | 156 | randomCreator.Successor = solutionsCreator;
|
---|
[2] | 157 |
|
---|
[3023] | 158 | solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
|
---|
[3198] | 159 | solutionsCreator.Successor = geneticAlgorithmMainLoop;
|
---|
[2] | 160 |
|
---|
[3198] | 161 | geneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
|
---|
| 162 | geneticAlgorithmMainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
|
---|
| 163 | geneticAlgorithmMainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
| 164 | geneticAlgorithmMainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
| 165 | geneticAlgorithmMainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
|
---|
| 166 | geneticAlgorithmMainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
|
---|
| 167 | geneticAlgorithmMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
| 168 | geneticAlgorithmMainLoop.ResultsParameter.ActualName = "Results";
|
---|
[2] | 169 |
|
---|
[3280] | 170 | Initialize();
|
---|
[2986] | 171 | }
|
---|
| 172 | [StorableConstructor]
|
---|
[3280] | 173 | private GeneticAlgorithm(bool deserializing) : base(deserializing) { }
|
---|
[2] | 174 |
|
---|
[2986] | 175 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[3198] | 176 | GeneticAlgorithm clone = (GeneticAlgorithm)base.Clone(cloner);
|
---|
[3280] | 177 | clone.Initialize();
|
---|
[2986] | 178 | return clone;
|
---|
| 179 | }
|
---|
[2882] | 180 |
|
---|
[3275] | 181 | public override void Prepare() {
|
---|
| 182 | if (Problem != null) base.Prepare();
|
---|
[3188] | 183 | }
|
---|
| 184 |
|
---|
[2986] | 185 | #region Events
|
---|
| 186 | protected override void OnProblemChanged() {
|
---|
| 187 | ParameterizeStochasticOperator(Problem.SolutionCreator);
|
---|
| 188 | ParameterizeStochasticOperator(Problem.Evaluator);
|
---|
[3107] | 189 | ParameterizeStochasticOperator(Problem.Visualizer);
|
---|
[2986] | 190 | foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
|
---|
[3023] | 191 | ParameterizeSolutionsCreator();
|
---|
[3198] | 192 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[2986] | 193 | ParameterizeSelectors();
|
---|
| 194 | UpdateCrossovers();
|
---|
| 195 | UpdateMutators();
|
---|
| 196 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3139] | 197 | if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged);
|
---|
[2986] | 198 | base.OnProblemChanged();
|
---|
| 199 | }
|
---|
[3139] | 200 |
|
---|
[2986] | 201 | protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
|
---|
| 202 | ParameterizeStochasticOperator(Problem.SolutionCreator);
|
---|
[3023] | 203 | ParameterizeSolutionsCreator();
|
---|
[2986] | 204 | base.Problem_SolutionCreatorChanged(sender, e);
|
---|
| 205 | }
|
---|
| 206 | protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
|
---|
| 207 | ParameterizeStochasticOperator(Problem.Evaluator);
|
---|
[3023] | 208 | ParameterizeSolutionsCreator();
|
---|
[3198] | 209 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[2986] | 210 | ParameterizeSelectors();
|
---|
| 211 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 212 | base.Problem_EvaluatorChanged(sender, e);
|
---|
| 213 | }
|
---|
[3107] | 214 | protected override void Problem_VisualizerChanged(object sender, EventArgs e) {
|
---|
| 215 | ParameterizeStochasticOperator(Problem.Visualizer);
|
---|
[3198] | 216 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[3139] | 217 | if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged);
|
---|
[3107] | 218 | base.Problem_VisualizerChanged(sender, e);
|
---|
| 219 | }
|
---|
[2986] | 220 | protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
|
---|
| 221 | foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
|
---|
| 222 | UpdateCrossovers();
|
---|
| 223 | UpdateMutators();
|
---|
| 224 | base.Problem_OperatorsChanged(sender, e);
|
---|
| 225 | }
|
---|
| 226 | private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 227 | Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
|
---|
| 228 | ParameterizeSelectors();
|
---|
| 229 | }
|
---|
| 230 | private void Elites_ValueChanged(object sender, EventArgs e) {
|
---|
| 231 | ParameterizeSelectors();
|
---|
| 232 | }
|
---|
| 233 | private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 234 | PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
|
---|
| 235 | ParameterizeSelectors();
|
---|
| 236 | }
|
---|
| 237 | private void PopulationSize_ValueChanged(object sender, EventArgs e) {
|
---|
| 238 | ParameterizeSelectors();
|
---|
| 239 | }
|
---|
| 240 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
[3198] | 241 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[2986] | 242 | ParameterizeSelectors();
|
---|
| 243 | }
|
---|
[3139] | 244 | private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
[3198] | 245 | ParameterizeGeneticAlgorithmMainLoop();
|
---|
[3139] | 246 | }
|
---|
[2986] | 247 | #endregion
|
---|
[2852] | 248 |
|
---|
[2986] | 249 | #region Helpers
|
---|
| 250 | [StorableHook(HookType.AfterDeserialization)]
|
---|
[3280] | 251 | private void Initialize() {
|
---|
[2986] | 252 | InitializeSelectors();
|
---|
| 253 | UpdateSelectors();
|
---|
| 254 | PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
|
---|
| 255 | PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
|
---|
| 256 | ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
|
---|
| 257 | Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
|
---|
[3139] | 258 | if (Problem != null) {
|
---|
| 259 | UpdateCrossovers();
|
---|
| 260 | UpdateMutators();
|
---|
[2986] | 261 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
[3139] | 262 | if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged);
|
---|
| 263 | }
|
---|
[2986] | 264 | }
|
---|
[2852] | 265 |
|
---|
[3023] | 266 | private void ParameterizeSolutionsCreator() {
|
---|
| 267 | SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
| 268 | SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
|
---|
[2986] | 269 | }
|
---|
[3198] | 270 | private void ParameterizeGeneticAlgorithmMainLoop() {
|
---|
| 271 | GeneticAlgorithmMainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
|
---|
| 272 | GeneticAlgorithmMainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
| 273 | GeneticAlgorithmMainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 274 | GeneticAlgorithmMainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 275 | GeneticAlgorithmMainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name;
|
---|
[3139] | 276 | if (Problem.Visualizer != null)
|
---|
[3198] | 277 | GeneticAlgorithmMainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName;
|
---|
[2986] | 278 | }
|
---|
| 279 | private void ParameterizeStochasticOperator(IOperator op) {
|
---|
| 280 | if (op is IStochasticOperator)
|
---|
| 281 | ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
| 282 | }
|
---|
| 283 | private void InitializeSelectors() {
|
---|
| 284 | selectors = new List<ISelector>();
|
---|
[3199] | 285 | if (ApplicationManager.Manager != null) selectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name));
|
---|
| 286 | ParameterizeSelectors();
|
---|
[2986] | 287 | }
|
---|
| 288 | private void ParameterizeSelectors() {
|
---|
| 289 | foreach (ISelector selector in Selectors) {
|
---|
[3048] | 290 | selector.CopySelected = new BoolValue(true);
|
---|
| 291 | selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSizeParameter.Value.Value - ElitesParameter.Value.Value));
|
---|
[2986] | 292 | ParameterizeStochasticOperator(selector);
|
---|
| 293 | }
|
---|
| 294 | if (Problem != null) {
|
---|
| 295 | foreach (ISingleObjectiveSelector selector in Selectors.OfType<ISingleObjectiveSelector>()) {
|
---|
| 296 | selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 297 | selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 298 | }
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 | private void UpdateSelectors() {
|
---|
| 302 | if (ApplicationManager.Manager != null) {
|
---|
| 303 | ISelector oldSelector = SelectorParameter.Value;
|
---|
| 304 | SelectorParameter.ValidValues.Clear();
|
---|
| 305 | foreach (ISelector selector in Selectors.OrderBy(x => x.Name))
|
---|
| 306 | SelectorParameter.ValidValues.Add(selector);
|
---|
[3076] | 307 | if (oldSelector != null) {
|
---|
| 308 | ISelector selector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType());
|
---|
| 309 | if (selector != null) SelectorParameter.Value = selector;
|
---|
| 310 | }
|
---|
[2986] | 311 | }
|
---|
| 312 | }
|
---|
| 313 | private void UpdateCrossovers() {
|
---|
[3199] | 314 | if (ApplicationManager.Manager != null) {
|
---|
| 315 | ICrossover oldCrossover = CrossoverParameter.Value;
|
---|
| 316 | CrossoverParameter.ValidValues.Clear();
|
---|
| 317 | foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
|
---|
| 318 | CrossoverParameter.ValidValues.Add(crossover);
|
---|
| 319 | if (oldCrossover != null) {
|
---|
| 320 | ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
|
---|
| 321 | if (crossover != null) CrossoverParameter.Value = crossover;
|
---|
| 322 | }
|
---|
[3076] | 323 | }
|
---|
[2986] | 324 | }
|
---|
| 325 | private void UpdateMutators() {
|
---|
[3199] | 326 | if (ApplicationManager.Manager != null) {
|
---|
| 327 | IManipulator oldMutator = MutatorParameter.Value;
|
---|
| 328 | MutatorParameter.ValidValues.Clear();
|
---|
| 329 | foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
|
---|
| 330 | MutatorParameter.ValidValues.Add(mutator);
|
---|
| 331 | if (oldMutator != null) {
|
---|
| 332 | IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
|
---|
| 333 | if (mutator != null) MutatorParameter.Value = mutator;
|
---|
| 334 | }
|
---|
[3076] | 335 | }
|
---|
[2986] | 336 | }
|
---|
| 337 | #endregion
|
---|
[2] | 338 | }
|
---|
| 339 | }
|
---|