Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 5357 was 5356, checked in by abeham, 14 years ago

#1344

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