Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs @ 4745

Last change on this file since 4745 was 4722, checked in by swagner, 14 years ago

Merged cloning refactoring branch back into trunk (#922)

File size: 22.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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.Collections.Generic;
24using System.Linq;
25using HeuristicLab.Analysis;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Optimization;
30using HeuristicLab.Optimization.Operators;
31using HeuristicLab.Parameters;
32using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
33using HeuristicLab.Random;
34
35namespace HeuristicLab.Algorithms.TabuSearch {
36  [Item("Tabu Search", "A tabu search algorithm.")]
37  [Creatable("Algorithms")]
38  [StorableClass]
39  public sealed class TabuSearch : EngineAlgorithm, IStorableContent {
40    public string Filename { get; set; }
41
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
51
52    #region Parameter Properties
53    private ValueParameter<IntValue> SeedParameter {
54      get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
55    }
56    private ValueParameter<BoolValue> SetSeedRandomlyParameter {
57      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
58    }
59    private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
60      get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
61    }
62    private ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
63      get { return (ConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; }
64    }
65    private ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
66      get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
67    }
68    private ConstrainedValueParameter<ITabuChecker> TabuCheckerParameter {
69      get { return (ConstrainedValueParameter<ITabuChecker>)Parameters["TabuChecker"]; }
70    }
71    private ConstrainedValueParameter<ITabuMaker> TabuMakerParameter {
72      get { return (ConstrainedValueParameter<ITabuMaker>)Parameters["TabuMaker"]; }
73    }
74    private ValueParameter<IntValue> TabuTenureParameter {
75      get { return (ValueParameter<IntValue>)Parameters["TabuTenure"]; }
76    }
77    private ValueParameter<IntValue> MaximumIterationsParameter {
78      get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; }
79    }
80    private ValueParameter<IntValue> SampleSizeParameter {
81      get { return (ValueParameter<IntValue>)Parameters["SampleSize"]; }
82    }
83    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
84      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
85    }
86    #endregion
87
88    #region Properties
89    public IntValue Seed {
90      get { return SeedParameter.Value; }
91      set { SeedParameter.Value = value; }
92    }
93    public BoolValue SetSeedRandomly {
94      get { return SetSeedRandomlyParameter.Value; }
95      set { SetSeedRandomlyParameter.Value = value; }
96    }
97    public IMoveGenerator MoveGenerator {
98      get { return MoveGeneratorParameter.Value; }
99      set { MoveGeneratorParameter.Value = value; }
100    }
101    public IMoveMaker MoveMaker {
102      get { return MoveMakerParameter.Value; }
103      set { MoveMakerParameter.Value = value; }
104    }
105    public ISingleObjectiveMoveEvaluator MoveEvaluator {
106      get { return MoveEvaluatorParameter.Value; }
107      set { MoveEvaluatorParameter.Value = value; }
108    }
109    public ITabuChecker TabuChecker {
110      get { return TabuCheckerParameter.Value; }
111      set { TabuCheckerParameter.Value = value; }
112    }
113    public ITabuMaker TabuMaker {
114      get { return TabuMakerParameter.Value; }
115      set { TabuMakerParameter.Value = value; }
116    }
117    public IntValue TabuTenure {
118      get { return TabuTenureParameter.Value; }
119      set { TabuTenureParameter.Value = value; }
120    }
121    public IntValue MaximumIterations {
122      get { return MaximumIterationsParameter.Value; }
123      set { MaximumIterationsParameter.Value = value; }
124    }
125    public MultiAnalyzer Analyzer {
126      get { return AnalyzerParameter.Value; }
127      set { AnalyzerParameter.Value = value; }
128    }
129    private RandomCreator RandomCreator {
130      get { return (RandomCreator)OperatorGraph.InitialOperator; }
131    }
132    private SolutionsCreator SolutionsCreator {
133      get { return (SolutionsCreator)RandomCreator.Successor; }
134    }
135    private TabuSearchMainLoop MainLoop {
136      get { return (TabuSearchMainLoop)SolutionsCreator.Successor; }
137    }
138    [Storable]
139    private BestAverageWorstQualityAnalyzer moveQualityAnalyzer;
140    [Storable]
141    private TabuNeighborhoodAnalyzer tabuNeighborhoodAnalyzer;
142    #endregion
143
144    public TabuSearch()
145      : base() {
146      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
147      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
148      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
149      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
150      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
151      Parameters.Add(new ConstrainedValueParameter<ITabuChecker>("TabuChecker", "The operator to check whether a move is tabu or not."));
152      Parameters.Add(new ConstrainedValueParameter<ITabuMaker>("TabuMaker", "The operator used to insert attributes of a move into the tabu list."));
153      Parameters.Add(new ValueParameter<IntValue>("TabuTenure", "The length of the tabu list.", new IntValue(10)));
154      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000)));
155      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "The neighborhood size for stochastic sampling move generators", new IntValue(100)));
156      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer()));
157
158      RandomCreator randomCreator = new RandomCreator();
159      SolutionsCreator solutionsCreator = new SolutionsCreator();
160      TabuSearchMainLoop tsMainLoop = new TabuSearchMainLoop();
161      OperatorGraph.InitialOperator = randomCreator;
162
163      randomCreator.RandomParameter.ActualName = "Random";
164      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
165      randomCreator.SeedParameter.Value = null;
166      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
167      randomCreator.SetSeedRandomlyParameter.Value = null;
168      randomCreator.Successor = solutionsCreator;
169
170      solutionsCreator.NumberOfSolutions = new IntValue(1);
171      solutionsCreator.Successor = tsMainLoop;
172
173      tsMainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
174      tsMainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
175      tsMainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
176      tsMainLoop.TabuCheckerParameter.ActualName = TabuCheckerParameter.Name;
177      tsMainLoop.TabuMakerParameter.ActualName = TabuMakerParameter.Name;
178      tsMainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
179      tsMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
180      tsMainLoop.ResultsParameter.ActualName = "Results";
181      tsMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
182
183      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
184      tabuNeighborhoodAnalyzer = new TabuNeighborhoodAnalyzer();
185      ParameterizeAnalyzers();
186      UpdateAnalyzers();
187
188      Initialize();
189    }
190    [StorableConstructor]
191    private TabuSearch(bool deserializing) : base(deserializing) { }
192    [StorableHook(HookType.AfterDeserialization)]
193    private void AfterDeserialization() {
194      Initialize();
195    }
196    private TabuSearch(TabuSearch original, Cloner cloner)
197      : base(original, cloner) {
198      moveQualityAnalyzer = cloner.Clone(original.moveQualityAnalyzer);
199      tabuNeighborhoodAnalyzer = cloner.Clone(original.tabuNeighborhoodAnalyzer);
200      Initialize();
201    }
202    public override IDeepCloneable Clone(Cloner cloner) {
203      return new TabuSearch(this, cloner);
204    }
205
206    public override void Prepare() {
207      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null &&
208          TabuChecker != null && TabuMaker != null)
209        base.Prepare();
210    }
211
212    #region Events
213    protected override void OnProblemChanged() {
214      ParameterizeStochasticOperator(Problem.SolutionCreator);
215      ParameterizeStochasticOperator(Problem.Evaluator);
216      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
217      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
218        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
219      }
220      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
221        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
222      }
223      ParameterizeSolutionsCreator();
224      ParameterizeMainLoop();
225      UpdateMoveGenerator();
226      UpdateMoveParameters();
227      UpdateAnalyzers();
228      ParameterizeMoveGenerators();
229      ParameterizeMoveEvaluator();
230      ParameterizeMoveMaker();
231      ParameterizeTabuMaker();
232      ParameterizeTabuChecker();
233      ParameterizeAnalyzers();
234      ParameterizeIterationBasedOperators();
235      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
236      base.OnProblemChanged();
237    }
238    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
239      ParameterizeStochasticOperator(Problem.SolutionCreator);
240      ParameterizeSolutionsCreator();
241      base.Problem_SolutionCreatorChanged(sender, e);
242    }
243    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
244      ParameterizeStochasticOperator(Problem.Evaluator);
245      ParameterizeSolutionsCreator();
246      ParameterizeMainLoop();
247      ParameterizeMoveEvaluator();
248      ParameterizeMoveMaker();
249      ParameterizeTabuMaker();
250      ParameterizeTabuChecker();
251      ParameterizeAnalyzers();
252      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
253      base.Problem_EvaluatorChanged(sender, e);
254    }
255    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
256      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
257      // This may seem pointless, but some operators already have the eventhandler registered, others don't
258      // FIXME: Is there another way to solve this problem?
259      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
260        op.MoveQualityParameter.ActualNameChanged -= new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
261        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
262      }
263      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
264        op.MoveTabuParameter.ActualNameChanged -= new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
265        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
266      }
267      UpdateMoveGenerator();
268      UpdateMoveParameters();
269      UpdateAnalyzers();
270      ParameterizeMainLoop();
271      ParameterizeMoveGenerators();
272      ParameterizeMoveEvaluator();
273      ParameterizeMoveMaker();
274      ParameterizeTabuMaker();
275      ParameterizeTabuChecker();
276      ParameterizeAnalyzers();
277      ParameterizeIterationBasedOperators();
278      base.Problem_OperatorsChanged(sender, e);
279    }
280    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
281      ParameterizeMainLoop();
282      ParameterizeMoveEvaluator();
283      ParameterizeMoveMaker();
284      ParameterizeTabuMaker();
285      ParameterizeTabuChecker();
286    }
287    private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) {
288      UpdateMoveParameters();
289    }
290    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
291      ParameterizeMainLoop();
292      ParameterizeMoveEvaluator();
293      ParameterizeMoveMaker();
294      ParameterizeTabuMaker();
295      ParameterizeTabuChecker();
296      ParameterizeAnalyzers();
297    }
298    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
299      ParameterizeMainLoop();
300      ParameterizeMoveEvaluator();
301      ParameterizeMoveMaker();
302      ParameterizeTabuMaker();
303      ParameterizeTabuChecker();
304      ParameterizeAnalyzers();
305    }
306    private void TabuCheckerParameter_ValueChanged(object sender, EventArgs e) {
307      ParameterizeMainLoop();
308      ParameterizeAnalyzers();
309    }
310    private void TabuChecker_MoveTabuParameter_ActualNameChanged(object sender, EventArgs e) {
311      ParameterizeMainLoop();
312      ParameterizeAnalyzers();
313    }
314    private void SampleSizeParameter_NameChanged(object sender, EventArgs e) {
315      ParameterizeMoveGenerators();
316    }
317    #endregion
318
319    #region Helpers
320    private void Initialize() {
321      if (Problem != null) {
322        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
323        foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
324          op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
325        }
326      }
327      MoveGeneratorParameter.ValueChanged += new EventHandler(MoveGeneratorParameter_ValueChanged);
328      MoveEvaluatorParameter.ValueChanged += new EventHandler(MoveEvaluatorParameter_ValueChanged);
329      TabuCheckerParameter.ValueChanged += new EventHandler(TabuCheckerParameter_ValueChanged);
330      SampleSizeParameter.NameChanged += new EventHandler(SampleSizeParameter_NameChanged);
331    }
332    private void UpdateMoveGenerator() {
333      IMoveGenerator oldMoveGenerator = MoveGenerator;
334      MoveGeneratorParameter.ValidValues.Clear();
335      if (Problem != null) {
336        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
337          MoveGeneratorParameter.ValidValues.Add(generator);
338        }
339      }
340      if (oldMoveGenerator != null && MoveGeneratorParameter.ValidValues.Any(x => x.GetType() == oldMoveGenerator.GetType()))
341        MoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType());
342      if (MoveGenerator == null) {
343        ClearMoveParameters();
344      }
345    }
346    private void UpdateMoveParameters() {
347      IMoveMaker oldMoveMaker = MoveMaker;
348      ISingleObjectiveMoveEvaluator oldMoveEvaluator = MoveEvaluator;
349      ITabuChecker oldTabuMoveEvaluator = TabuChecker;
350      ITabuMaker oldTabuMoveMaker = TabuMaker;
351      ClearMoveParameters();
352      if (MoveGenerator != null) {
353        List<Type> moveTypes = MoveGenerator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList();
354        foreach (Type type in moveTypes.ToList()) {
355          if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t)))
356            moveTypes.Remove(type);
357        }
358        foreach (Type type in moveTypes) {
359          var operators = Problem.Operators.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name);
360          foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>())
361            MoveMakerParameter.ValidValues.Add(moveMaker);
362          foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>())
363            MoveEvaluatorParameter.ValidValues.Add(moveEvaluator);
364          foreach (ITabuChecker tabuMoveEvaluator in operators.OfType<ITabuChecker>())
365            TabuCheckerParameter.ValidValues.Add(tabuMoveEvaluator);
366          foreach (ITabuMaker tabuMoveMaker in operators.OfType<ITabuMaker>())
367            TabuMakerParameter.ValidValues.Add(tabuMoveMaker);
368        }
369        if (oldMoveMaker != null) {
370          IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType());
371          if (mm != null) MoveMaker = mm;
372        }
373        if (oldMoveEvaluator != null) {
374          ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType());
375          if (me != null) MoveEvaluator = me;
376        }
377        if (oldTabuMoveMaker != null) {
378          ITabuMaker tmm = TabuMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveMaker.GetType());
379          if (tmm != null) TabuMaker = tmm;
380        }
381        if (oldTabuMoveEvaluator != null) {
382          ITabuChecker tme = TabuCheckerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveEvaluator.GetType());
383          if (tme != null) TabuChecker = tme;
384        }
385      }
386    }
387    private void UpdateAnalyzers() {
388      Analyzer.Operators.Clear();
389      if (Problem != null) {
390        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
391          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
392            param.Depth = 0;
393          Analyzer.Operators.Add(analyzer);
394        }
395      }
396      Analyzer.Operators.Add(moveQualityAnalyzer);
397      Analyzer.Operators.Add(tabuNeighborhoodAnalyzer);
398    }
399    private void ClearMoveParameters() {
400      MoveMakerParameter.ValidValues.Clear();
401      MoveEvaluatorParameter.ValidValues.Clear();
402      TabuCheckerParameter.ValidValues.Clear();
403      TabuMakerParameter.ValidValues.Clear();
404    }
405    private void ParameterizeSolutionsCreator() {
406      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
407      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
408    }
409    private void ParameterizeMainLoop() {
410      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
411      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
412      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
413      if (MoveEvaluator != null)
414        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
415      if (TabuChecker != null)
416        MainLoop.MoveTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
417    }
418    private void ParameterizeStochasticOperator(IOperator op) {
419      if (op is IStochasticOperator)
420        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
421    }
422    private void ParameterizeMoveGenerators() {
423      if (Problem != null) {
424        foreach (IMultiMoveGenerator generator in Problem.Operators.OfType<IMultiMoveGenerator>())
425          generator.SampleSizeParameter.ActualName = SampleSizeParameter.Name;
426      }
427    }
428    private void ParameterizeMoveEvaluator() {
429      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
430        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
431      }
432    }
433    private void ParameterizeMoveMaker() {
434      foreach (IMoveMaker op in Problem.Operators.OfType<IMoveMaker>()) {
435        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
436        if (MoveEvaluator != null)
437          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
438      }
439    }
440    private void ParameterizeTabuMaker() {
441      foreach (ITabuMaker op in Problem.Operators.OfType<ITabuMaker>()) {
442        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
443        if (MoveEvaluator != null)
444          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
445      }
446    }
447    private void ParameterizeTabuChecker() {
448      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
449        if (MoveEvaluator != null)
450          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
451        if (TabuChecker != null)
452          op.MoveTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
453      }
454    }
455    private void ParameterizeAnalyzers() {
456      moveQualityAnalyzer.ResultsParameter.ActualName = "Results";
457      tabuNeighborhoodAnalyzer.ResultsParameter.ActualName = "Results";
458      tabuNeighborhoodAnalyzer.PercentTabuParameter.ActualName = "PercentTabu";
459      if (Problem != null) {
460        moveQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
461        if (MoveEvaluator != null)
462          moveQualityAnalyzer.QualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
463        moveQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
464        if (TabuChecker != null)
465          tabuNeighborhoodAnalyzer.IsTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
466      }
467    }
468    private void ParameterizeIterationBasedOperators() {
469      if (Problem != null) {
470        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
471          op.IterationsParameter.ActualName = "Iterations";
472          op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
473        }
474      }
475    }
476    #endregion
477  }
478}
Note: See TracBrowser for help on using the repository browser.