Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3044_variableScaling/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs @ 17456

Last change on this file since 17456 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 23.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23using System.Linq;
24using HeuristicLab.Analysis;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Operators;
29using HeuristicLab.Optimization;
30using HeuristicLab.Optimization.Operators;
31using HeuristicLab.Parameters;
32using HEAL.Attic;
33using HeuristicLab.Random;
34using HeuristicLab.Selection;
35
36namespace HeuristicLab.Algorithms.ScatterSearch {
37  /// <summary>
38  /// A scatter search algorithm.
39  /// </summary>
40  [Item("Scatter Search (SS)", "A scatter search algorithm.")]
41  [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 500)]
42  [StorableType("B0A218C1-8D92-4BDF-AAB7-C6396612C26B")]
43  public sealed class ScatterSearch : HeuristicOptimizationEngineAlgorithm, IStorableContent {
44    public string Filename { get; set; }
45
46    #region Problem Properties
47    public override Type ProblemType {
48      get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
49    }
50    public new ISingleObjectiveHeuristicOptimizationProblem Problem {
51      get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
52      set { base.Problem = value; }
53    }
54    #endregion
55
56    #region Parameter Properties
57    public IValueParameter<MultiAnalyzer> AnalyzerParameter {
58      get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
59    }
60    public IConstrainedValueParameter<ICrossover> CrossoverParameter {
61      get { return (IConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
62    }
63    public IValueParameter<BoolValue> ExecutePathRelinkingParameter {
64      get { return (IValueParameter<BoolValue>)Parameters["ExecutePathRelinking"]; }
65    }
66    public IConstrainedValueParameter<IImprovementOperator> ImproverParameter {
67      get { return (IConstrainedValueParameter<IImprovementOperator>)Parameters["Improver"]; }
68    }
69    public IValueParameter<IntValue> MaximumIterationsParameter {
70      get { return (IValueParameter<IntValue>)Parameters["MaximumIterations"]; }
71    }
72    public IValueParameter<IntValue> NumberOfHighQualitySolutionsParameter {
73      get { return (IValueParameter<IntValue>)Parameters["NumberOfHighQualitySolutions"]; }
74    }
75    public IConstrainedValueParameter<IPathRelinker> PathRelinkerParameter {
76      get { return (IConstrainedValueParameter<IPathRelinker>)Parameters["PathRelinker"]; }
77    }
78    public IValueParameter<IntValue> PopulationSizeParameter {
79      get { return (IValueParameter<IntValue>)Parameters["PopulationSize"]; }
80    }
81    public IValueParameter<IntValue> ReferenceSetSizeParameter {
82      get { return (IValueParameter<IntValue>)Parameters["ReferenceSetSize"]; }
83    }
84    public IValueParameter<IntValue> SeedParameter {
85      get { return (IValueParameter<IntValue>)Parameters["Seed"]; }
86    }
87    public IValueParameter<BoolValue> SetSeedRandomlyParameter {
88      get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
89    }
90    public IConstrainedValueParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter {
91      get { return (IConstrainedValueParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
92    }
93    #endregion
94
95    #region Properties
96    public MultiAnalyzer Analyzer {
97      get { return AnalyzerParameter.Value; }
98      set { AnalyzerParameter.Value = value; }
99    }
100    public ICrossover Crossover {
101      get { return CrossoverParameter.Value; }
102      set { CrossoverParameter.Value = value; }
103    }
104    public BoolValue ExecutePathRelinking {
105      get { return ExecutePathRelinkingParameter.Value; }
106      set { ExecutePathRelinkingParameter.Value = value; }
107    }
108    public IImprovementOperator Improver {
109      get { return ImproverParameter.Value; }
110      set { ImproverParameter.Value = value; }
111    }
112    public IntValue MaximumIterations {
113      get { return MaximumIterationsParameter.Value; }
114      set { MaximumIterationsParameter.Value = value; }
115    }
116    public IntValue NumberOfHighQualitySolutions {
117      get { return NumberOfHighQualitySolutionsParameter.Value; }
118      set { NumberOfHighQualitySolutionsParameter.Value = value; }
119    }
120    public IPathRelinker PathRelinker {
121      get { return PathRelinkerParameter.Value; }
122      set { PathRelinkerParameter.Value = value; }
123    }
124    public IntValue PopulationSize {
125      get { return PopulationSizeParameter.Value; }
126      set { PopulationSizeParameter.Value = value; }
127    }
128    public IntValue ReferenceSetSize {
129      get { return ReferenceSetSizeParameter.Value; }
130      set { ReferenceSetSizeParameter.Value = value; }
131    }
132    public IntValue Seed {
133      get { return SeedParameter.Value; }
134      set { SeedParameter.Value = value; }
135    }
136    public BoolValue SetSeedRandomly {
137      get { return SetSeedRandomlyParameter.Value; }
138      set { SetSeedRandomlyParameter.Value = value; }
139    }
140    public ISolutionSimilarityCalculator SimilarityCalculator {
141      get { return SimilarityCalculatorParameter.Value; }
142      set { SimilarityCalculatorParameter.Value = value; }
143    }
144    private RandomCreator RandomCreator {
145      get { return (RandomCreator)OperatorGraph.InitialOperator; }
146    }
147    private SolutionsCreator SolutionsCreator {
148      get { return (SolutionsCreator)RandomCreator.Successor; }
149    }
150    private ScatterSearchMainLoop MainLoop {
151      get { return FindMainLoop(SolutionsCreator.Successor); }
152    }
153
154    [Storable]
155    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
156    #endregion
157
158    [StorableConstructor]
159    private ScatterSearch(StorableConstructorFlag _) : base(_) { }
160    [StorableHook(HookType.AfterDeserialization)]
161    private void AfterDeserialization() {
162      // BackwardsCompatibility3.3
163      #region Backwards compatible code, remove with 3.4
164#pragma warning disable 0618
165      if (Parameters.ContainsKey("SimilarityCalculator") && Parameters["SimilarityCalculator"] is IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>) {
166        var oldParameter = (IConstrainedValueParameter<ISingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"];
167#pragma warning restore 0618
168        Parameters.Remove(oldParameter);
169        var newParameter = new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions.", new ItemSet<ISolutionSimilarityCalculator>(oldParameter.ValidValues));
170        var selectedSimilarityCalculator = newParameter.ValidValues.SingleOrDefault(x => x.GetType() == oldParameter.Value.GetType());
171        newParameter.Value = selectedSimilarityCalculator;
172        Parameters.Add(newParameter);
173      }
174      #endregion
175      Initialize();
176    }
177    private ScatterSearch(ScatterSearch original, Cloner cloner)
178      : base(original, cloner) {
179      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
180      Initialize();
181    }
182    public override IDeepCloneable Clone(Cloner cloner) {
183      return new ScatterSearch(this, cloner);
184    }
185    public ScatterSearch()
186      : base() {
187      #region Create parameters
188      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration.", new MultiAnalyzer()));
189      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
190      Parameters.Add(new ValueParameter<BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false.", new BoolValue(false)));
191      Parameters.Add(new ConstrainedValueParameter<IImprovementOperator>("Improver", "The operator used to improve solutions."));
192      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.", new IntValue(100)));
193      Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set.", new IntValue(5)));
194      Parameters.Add(new ConstrainedValueParameter<IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
195      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(50)));
196      Parameters.Add(new ValueParameter<IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(20)));
197      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
198      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
199      Parameters.Add(new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
200      #endregion
201
202      #region Create operators
203      RandomCreator randomCreator = new RandomCreator();
204      SolutionsCreator solutionsCreator = new SolutionsCreator();
205      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
206      Placeholder solutionEvaluator = new Placeholder();
207      Placeholder solutionImprover = new Placeholder();
208      VariableCreator variableCreator = new VariableCreator();
209      DataReducer dataReducer = new DataReducer();
210      ResultsCollector resultsCollector = new ResultsCollector();
211      BestSelector bestSelector = new BestSelector();
212      ScatterSearchMainLoop mainLoop = new ScatterSearchMainLoop();
213      #endregion
214
215      #region Create operator graph
216      OperatorGraph.InitialOperator = randomCreator;
217      randomCreator.RandomParameter.ActualName = "Random";
218      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
219      randomCreator.SeedParameter.Value = null;
220      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
221      randomCreator.SetSeedRandomlyParameter.Value = null;
222      randomCreator.Successor = solutionsCreator;
223
224      solutionsCreator.Name = "DiversificationGenerationMethod";
225      solutionsCreator.NumberOfSolutionsParameter.ActualName = "PopulationSize";
226      solutionsCreator.Successor = uniformSubScopesProcessor;
227
228      uniformSubScopesProcessor.Operator = solutionImprover;
229      uniformSubScopesProcessor.ParallelParameter.Value = new BoolValue(true);
230      uniformSubScopesProcessor.Successor = variableCreator;
231
232      solutionImprover.Name = "SolutionImprover";
233      solutionImprover.OperatorParameter.ActualName = "Improver";
234      solutionImprover.Successor = solutionEvaluator;
235
236      solutionEvaluator.Name = "SolutionEvaluator";
237      solutionEvaluator.OperatorParameter.ActualName = "Evaluator";
238      solutionEvaluator.Successor = null;
239
240      variableCreator.Name = "Initialize EvaluatedSolutions";
241      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue()));
242      variableCreator.Successor = dataReducer;
243
244      dataReducer.Name = "Increment EvaluatedSolutions";
245      dataReducer.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
246      dataReducer.TargetParameter.ActualName = "EvaluatedSolutions";
247      dataReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
248      dataReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
249      dataReducer.Successor = resultsCollector;
250
251      resultsCollector.Name = "ResultsCollector";
252      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", null, "EvaluatedSolutions"));
253      resultsCollector.Successor = bestSelector;
254
255      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
256      bestSelector.CopySelected = new BoolValue(false);
257      bestSelector.Successor = mainLoop;
258
259      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
260      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
261      mainLoop.ResultsParameter.ActualName = "Results";
262      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
263      mainLoop.IterationsParameter.ActualName = "Iterations";
264      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
265      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
266      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
267      mainLoop.NumberOfHighQualitySolutionsParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
268      mainLoop.Successor = null;
269      #endregion
270
271      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
272      ParameterizeAnalyzers();
273      UpdateAnalyzers();
274
275      Initialize();
276    }
277
278    public override void Prepare() {
279      if (Problem != null && Improver != null && (PathRelinker != null || ExecutePathRelinking.Value == false) && SimilarityCalculator != null)
280        base.Prepare();
281    }
282
283    #region Events
284    protected override void OnProblemChanged() {
285      ParameterizeStochasticOperator(Problem.SolutionCreator);
286      ParameterizeStochasticOperator(Problem.Evaluator);
287      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
288      ParameterizeAnalyzers();
289      ParameterizeSolutionsCreator();
290      ParameterizeBestSelector();
291      UpdateAnalyzers();
292      UpdateCrossovers();
293      UpdateImprovers();
294      UpdatePathRelinkers();
295      UpdateSimilarityCalculators();
296      ParameterizeMainLoop();
297      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
298      base.OnProblemChanged();
299    }
300    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
301      ParameterizeStochasticOperator(Problem.SolutionCreator);
302      ParameterizeSolutionsCreator();
303      base.Problem_SolutionCreatorChanged(sender, e);
304    }
305    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
306      ParameterizeStochasticOperator(Problem.Evaluator);
307      ParameterizeSolutionsCreator();
308      ParameterizeMainLoop();
309      ParameterizeAnalyzers();
310      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
311      base.Problem_EvaluatorChanged(sender, e);
312    }
313    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
314      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
315      UpdateAnalyzers();
316      UpdateCrossovers();
317      UpdatePathRelinkers();
318      UpdateSimilarityCalculators();
319      UpdateImprovers();
320      ParameterizeMainLoop();
321      ParameterizeAnalyzers();
322      base.Problem_OperatorsChanged(sender, e);
323    }
324    private void PathRelinkerParameter_ValueChanged(object sender, EventArgs e) {
325      ExecutePathRelinking.Value = PathRelinkerParameter.Value != null;
326    }
327    private void SimilarityCalculatorParameter_ValueChanged(object sender, EventArgs e) {
328      ParameterizeMainLoop();
329    }
330    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
331      ParameterizeMainLoop();
332      ParameterizeAnalyzers();
333      ParameterizeBestSelector();
334      ParameterizeSimilarityCalculators();
335    }
336    #endregion
337
338    #region Helpers
339    private void Initialize() {
340      PathRelinkerParameter.ValueChanged += new EventHandler(PathRelinkerParameter_ValueChanged);
341      SimilarityCalculatorParameter.ValueChanged += new EventHandler(SimilarityCalculatorParameter_ValueChanged);
342      if (Problem != null)
343        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
344    }
345    private void UpdateAnalyzers() {
346      Analyzer.Operators.Clear();
347      if (Problem != null) {
348        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
349          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
350            param.Depth = 1;
351          Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
352        }
353      }
354      Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
355    }
356    private void UpdateCrossovers() {
357      ICrossover oldCrossover = CrossoverParameter.Value;
358      CrossoverParameter.ValidValues.Clear();
359      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
360
361      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
362        CrossoverParameter.ValidValues.Add(crossover);
363
364      if (oldCrossover != null) {
365        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
366        if (crossover != null) CrossoverParameter.Value = crossover;
367        else oldCrossover = null;
368      }
369      if (oldCrossover == null && defaultCrossover != null)
370        CrossoverParameter.Value = defaultCrossover;
371    }
372    private void UpdateImprovers() {
373      IImprovementOperator oldImprover = ImproverParameter.Value;
374      ImproverParameter.ValidValues.Clear();
375      IImprovementOperator defaultImprover = Problem.Operators.OfType<IImprovementOperator>().FirstOrDefault();
376
377      foreach (IImprovementOperator improver in Problem.Operators.OfType<IImprovementOperator>().OrderBy(x => x.Name))
378        ImproverParameter.ValidValues.Add(improver);
379
380      if (oldImprover != null) {
381        IImprovementOperator improver = ImproverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldImprover.GetType());
382        if (improver != null) ImproverParameter.Value = improver;
383        else oldImprover = null;
384      }
385      if (oldImprover == null && defaultImprover != null)
386        ImproverParameter.Value = defaultImprover;
387    }
388    private void UpdatePathRelinkers() {
389      IPathRelinker oldPathRelinker = PathRelinkerParameter.Value;
390      PathRelinkerParameter.ValidValues.Clear();
391      IPathRelinker defaultPathRelinker = Problem.Operators.OfType<IPathRelinker>().FirstOrDefault();
392
393      foreach (IPathRelinker pathRelinker in Problem.Operators.OfType<IPathRelinker>().OrderBy(x => x.Name))
394        PathRelinkerParameter.ValidValues.Add(pathRelinker);
395
396      if (oldPathRelinker != null) {
397        IPathRelinker pathRelinker = PathRelinkerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldPathRelinker.GetType());
398        if (pathRelinker != null) PathRelinkerParameter.Value = pathRelinker;
399        else oldPathRelinker = null;
400      }
401      if (oldPathRelinker == null && defaultPathRelinker != null)
402        PathRelinkerParameter.Value = defaultPathRelinker;
403    }
404    private void UpdateSimilarityCalculators() {
405      ISolutionSimilarityCalculator oldSimilarityCalculator = SimilarityCalculatorParameter.Value;
406      SimilarityCalculatorParameter.ValidValues.Clear();
407      ISolutionSimilarityCalculator defaultSimilarityCalculator = Problem.Operators.OfType<ISolutionSimilarityCalculator>().FirstOrDefault();
408
409      foreach (ISolutionSimilarityCalculator similarityCalculator in Problem.Operators.OfType<ISolutionSimilarityCalculator>())
410        SimilarityCalculatorParameter.ValidValues.Add(similarityCalculator);
411
412      if (!SimilarityCalculatorParameter.ValidValues.OfType<QualitySimilarityCalculator>().Any())
413        SimilarityCalculatorParameter.ValidValues.Add(new QualitySimilarityCalculator {
414          QualityVariableName = Problem.Evaluator.QualityParameter.ActualName
415        });
416      if (!SimilarityCalculatorParameter.ValidValues.OfType<NoSimilarityCalculator>().Any())
417        SimilarityCalculatorParameter.ValidValues.Add(new NoSimilarityCalculator());
418
419      if (oldSimilarityCalculator != null) {
420        ISolutionSimilarityCalculator similarityCalculator = SimilarityCalculatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSimilarityCalculator.GetType());
421        if (similarityCalculator != null) SimilarityCalculatorParameter.Value = similarityCalculator;
422        else oldSimilarityCalculator = null;
423      }
424      if (oldSimilarityCalculator == null && defaultSimilarityCalculator != null)
425        SimilarityCalculatorParameter.Value = defaultSimilarityCalculator;
426    }
427    private void ParameterizeBestSelector() {
428      OperatorGraph.Operators.OfType<ISingleObjectiveSelector>()
429                             .First().QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
430    }
431    private void ParameterizeSolutionsCreator() {
432      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
433      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
434    }
435    private void ParameterizeMainLoop() {
436      if (Problem != null && Improver != null) {
437        MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
438        MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
439        MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
440        MainLoop.OperatorGraph.Operators.OfType<PopulationRebuildMethod>().Single().QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
441        MainLoop.OperatorGraph.Operators.OfType<SolutionPoolUpdateMethod>().Single().QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
442      }
443    }
444    private void ParameterizeStochasticOperator(IOperator op) {
445      if (op is IStochasticOperator) {
446        IStochasticOperator stOp = (IStochasticOperator)op;
447        stOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
448        stOp.RandomParameter.Hidden = true;
449      }
450    }
451    private void ParameterizeAnalyzers() {
452      qualityAnalyzer.ResultsParameter.ActualName = "Results";
453      qualityAnalyzer.ResultsParameter.Hidden = true;
454      if (Problem != null) {
455        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
456        qualityAnalyzer.MaximizationParameter.Hidden = true;
457        qualityAnalyzer.QualityParameter.Hidden = false;
458        qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
459        qualityAnalyzer.BestKnownQualityParameter.Hidden = true;
460      } else {
461        qualityAnalyzer.MaximizationParameter.Hidden = false;
462        qualityAnalyzer.BestKnownQualityParameter.Hidden = false;
463      }
464    }
465    private void ParameterizeSimilarityCalculators() {
466      foreach (ISolutionSimilarityCalculator calc in SimilarityCalculatorParameter.ValidValues) {
467        calc.QualityVariableName = Problem.Evaluator.QualityParameter.ActualName;
468      }
469    }
470    private ScatterSearchMainLoop FindMainLoop(IOperator start) {
471      IOperator mainLoop = start;
472      while (mainLoop != null && !(mainLoop is ScatterSearchMainLoop))
473        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
474      return mainLoop as ScatterSearchMainLoop;
475    }
476    #endregion
477  }
478}
Note: See TracBrowser for help on using the repository browser.