Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3818 was 3816, checked in by swagner, 15 years ago

Removed sorting of analyzer provided by problems (#893)

File size: 22.8 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.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Optimization;
29using HeuristicLab.Operators;
30using HeuristicLab.Optimization.Operators;
31using HeuristicLab.Parameters;
32using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
33using HeuristicLab.PluginInfrastructure;
34using HeuristicLab.Random;
35using HeuristicLab.Analysis;
36
37namespace HeuristicLab.Algorithms.TabuSearch {
38  [Item("Tabu Search", "A tabu search algorithm.")]
39  [Creatable("Algorithms")]
40  [StorableClass]
41  public sealed class TabuSearch : EngineAlgorithm {
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
193    public override IDeepCloneable Clone(Cloner cloner) {
194      TabuSearch clone = (TabuSearch)base.Clone(cloner);
195      clone.moveQualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(moveQualityAnalyzer);
196      clone.tabuNeighborhoodAnalyzer = (TabuNeighborhoodAnalyzer)cloner.Clone(tabuNeighborhoodAnalyzer);
197      clone.Initialize();
198      return clone;
199    }
200
201    public override void Prepare() {
202      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null &&
203          TabuChecker != null && TabuMaker != null)
204        base.Prepare();
205    }
206
207    #region Events
208    protected override void OnProblemChanged() {
209      ParameterizeStochasticOperator(Problem.SolutionCreator);
210      ParameterizeStochasticOperator(Problem.Evaluator);
211      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
212      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
213        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
214      }
215      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
216        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
217      }
218      ParameterizeSolutionsCreator();
219      ParameterizeMainLoop();
220      UpdateMoveGenerator();
221      UpdateMoveParameters();
222      UpdateAnalyzers();
223      ParameterizeMoveGenerators();
224      ParameterizeMoveEvaluator();
225      ParameterizeMoveMaker();
226      ParameterizeTabuMaker();
227      ParameterizeTabuChecker();
228      ParameterizeAnalyzers();
229      ParameterizeIterationBasedOperators();
230      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
231      base.OnProblemChanged();
232    }
233    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
234      ParameterizeStochasticOperator(Problem.SolutionCreator);
235      ParameterizeSolutionsCreator();
236      base.Problem_SolutionCreatorChanged(sender, e);
237    }
238    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
239      ParameterizeStochasticOperator(Problem.Evaluator);
240      ParameterizeSolutionsCreator();
241      ParameterizeMainLoop();
242      ParameterizeMoveEvaluator();
243      ParameterizeMoveMaker();
244      ParameterizeTabuMaker();
245      ParameterizeTabuChecker();
246      ParameterizeAnalyzers();
247      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
248      base.Problem_EvaluatorChanged(sender, e);
249    }
250    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
251      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
252      // This may seem pointless, but some operators already have the eventhandler registered, others don't
253      // FIXME: Is there another way to solve this problem?
254      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
255        op.MoveQualityParameter.ActualNameChanged -= new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
256        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
257      }
258      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
259        op.MoveTabuParameter.ActualNameChanged -= new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
260        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
261      }
262      UpdateMoveGenerator();
263      UpdateMoveParameters();
264      UpdateAnalyzers();
265      ParameterizeMainLoop();
266      ParameterizeMoveGenerators();
267      ParameterizeMoveEvaluator();
268      ParameterizeMoveMaker();
269      ParameterizeTabuMaker();
270      ParameterizeTabuChecker();
271      ParameterizeAnalyzers();
272      ParameterizeIterationBasedOperators();
273      base.Problem_OperatorsChanged(sender, e);
274    }
275    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
276      ParameterizeMainLoop();
277      ParameterizeMoveEvaluator();
278      ParameterizeMoveMaker();
279      ParameterizeTabuMaker();
280      ParameterizeTabuChecker();
281    }
282    private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) {
283      UpdateMoveParameters();
284    }
285    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
286      ParameterizeMainLoop();
287      ParameterizeMoveEvaluator();
288      ParameterizeMoveMaker();
289      ParameterizeTabuMaker();
290      ParameterizeTabuChecker();
291      ParameterizeAnalyzers();
292    }
293    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
294      ParameterizeMainLoop();
295      ParameterizeMoveEvaluator();
296      ParameterizeMoveMaker();
297      ParameterizeTabuMaker();
298      ParameterizeTabuChecker();
299      ParameterizeAnalyzers();
300    }
301    private void TabuCheckerParameter_ValueChanged(object sender, EventArgs e) {
302      ParameterizeMainLoop();
303      ParameterizeAnalyzers();
304    }
305    private void TabuChecker_MoveTabuParameter_ActualNameChanged(object sender, EventArgs e) {
306      ParameterizeMainLoop();
307      ParameterizeAnalyzers();
308    }
309    private void SampleSizeParameter_NameChanged(object sender, EventArgs e) {
310      ParameterizeMoveGenerators();
311    }
312    #endregion
313
314    #region Helpers
315    [StorableHook(HookType.AfterDeserialization)]
316    private void Initialize() {
317      if (Problem != null) {
318        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
319        foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
320          op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
321        }
322      }
323      MoveGeneratorParameter.ValueChanged += new EventHandler(MoveGeneratorParameter_ValueChanged);
324      MoveEvaluatorParameter.ValueChanged += new EventHandler(MoveEvaluatorParameter_ValueChanged);
325      TabuCheckerParameter.ValueChanged += new EventHandler(TabuCheckerParameter_ValueChanged);
326      SampleSizeParameter.NameChanged += new EventHandler(SampleSizeParameter_NameChanged);
327    }
328    private void UpdateMoveGenerator() {
329      IMoveGenerator oldMoveGenerator = MoveGenerator;
330      MoveGeneratorParameter.ValidValues.Clear();
331      if (Problem != null) {
332        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
333          MoveGeneratorParameter.ValidValues.Add(generator);
334        }
335      }
336      if (oldMoveGenerator != null && MoveGeneratorParameter.ValidValues.Any(x => x.GetType() == oldMoveGenerator.GetType()))
337        MoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType());
338      if (MoveGenerator == null) {
339        ClearMoveParameters();
340      }
341    }
342    private void UpdateMoveParameters() {
343      IMoveMaker oldMoveMaker = MoveMaker;
344      ISingleObjectiveMoveEvaluator oldMoveEvaluator = MoveEvaluator;
345      ITabuChecker oldTabuMoveEvaluator = TabuChecker;
346      ITabuMaker oldTabuMoveMaker = TabuMaker;
347      ClearMoveParameters();
348      if (MoveGenerator != null) {
349        List<Type> moveTypes = MoveGenerator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList();
350        foreach (Type type in moveTypes.ToList()) {
351          if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t)))
352            moveTypes.Remove(type);
353        }
354        foreach (Type type in moveTypes) {
355          var operators = Problem.Operators.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name);
356          foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>())
357            MoveMakerParameter.ValidValues.Add(moveMaker);
358          foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>())
359            MoveEvaluatorParameter.ValidValues.Add(moveEvaluator);
360          foreach (ITabuChecker tabuMoveEvaluator in operators.OfType<ITabuChecker>())
361            TabuCheckerParameter.ValidValues.Add(tabuMoveEvaluator);
362          foreach (ITabuMaker tabuMoveMaker in operators.OfType<ITabuMaker>())
363            TabuMakerParameter.ValidValues.Add(tabuMoveMaker);
364        }
365        if (oldMoveMaker != null) {
366          IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType());
367          if (mm != null) MoveMaker = mm;
368        }
369        if (oldMoveEvaluator != null) {
370          ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType());
371          if (me != null) MoveEvaluator = me;
372        }
373        if (oldTabuMoveMaker != null) {
374          ITabuMaker tmm = TabuMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveMaker.GetType());
375          if (tmm != null) TabuMaker = tmm;
376        }
377        if (oldTabuMoveEvaluator != null) {
378          ITabuChecker tme = TabuCheckerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveEvaluator.GetType());
379          if (tme != null) TabuChecker = tme;
380        }
381      }
382    }
383    private void UpdateAnalyzers() {
384      Analyzer.Operators.Clear();
385      if (Problem != null) {
386        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
387          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
388            param.Depth = 0;
389          Analyzer.Operators.Add(analyzer);
390        }
391      }
392      Analyzer.Operators.Add(moveQualityAnalyzer);
393      Analyzer.Operators.Add(tabuNeighborhoodAnalyzer);
394    }
395    private void ClearMoveParameters() {
396      MoveMakerParameter.ValidValues.Clear();
397      MoveEvaluatorParameter.ValidValues.Clear();
398      TabuCheckerParameter.ValidValues.Clear();
399      TabuMakerParameter.ValidValues.Clear();
400    }
401    private void ParameterizeSolutionsCreator() {
402      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
403      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
404    }
405    private void ParameterizeMainLoop() {
406      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
407      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
408      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
409      if (MoveEvaluator != null)
410        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
411      if (TabuChecker != null)
412        MainLoop.MoveTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
413    }
414    private void ParameterizeStochasticOperator(IOperator op) {
415      if (op is IStochasticOperator)
416        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
417    }
418    private void ParameterizeMoveGenerators() {
419      if (Problem != null) {
420        foreach (IMultiMoveGenerator generator in Problem.Operators.OfType<IMultiMoveGenerator>())
421          generator.SampleSizeParameter.ActualName = SampleSizeParameter.Name;
422      }
423    }
424    private void ParameterizeMoveEvaluator() {
425      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
426        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
427      }
428    }
429    private void ParameterizeMoveMaker() {
430      foreach (IMoveMaker op in Problem.Operators.OfType<IMoveMaker>()) {
431        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
432        if (MoveEvaluator != null)
433          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
434      }
435    }
436    private void ParameterizeTabuMaker() {
437      foreach (ITabuMaker op in Problem.Operators.OfType<ITabuMaker>()) {
438        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
439        if (MoveEvaluator != null)
440          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
441      }
442    }
443    private void ParameterizeTabuChecker() {
444      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
445        if (MoveEvaluator != null)
446          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
447        if (TabuChecker != null)
448          op.MoveTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
449      }
450    }
451    private void ParameterizeAnalyzers() {
452      moveQualityAnalyzer.ResultsParameter.ActualName = "Results";
453      tabuNeighborhoodAnalyzer.ResultsParameter.ActualName = "Results";
454      tabuNeighborhoodAnalyzer.PercentTabuParameter.ActualName = "PercentTabu";
455      if (Problem != null) {
456        moveQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
457        if (MoveEvaluator != null)
458          moveQualityAnalyzer.QualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
459        moveQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
460        if (TabuChecker != null)
461          tabuNeighborhoodAnalyzer.IsTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
462      }
463    }
464    private void ParameterizeIterationBasedOperators() {
465      if (Problem != null) {
466        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
467          op.IterationsParameter.ActualName = "Iterations";
468          op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
469        }
470      }
471    }
472    #endregion
473  }
474}
Note: See TracBrowser for help on using the repository browser.