Free cookie consent management tool by TermsFeed Policy Generator

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

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

Merged cloning refactoring branch back into trunk (#922)

File size: 22.9 KB
RevLine 
[3044]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;
[3074]24using System.Linq;
[4068]25using HeuristicLab.Analysis;
[3376]26using HeuristicLab.Common;
[3044]27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Optimization;
30using HeuristicLab.Optimization.Operators;
31using HeuristicLab.Parameters;
32using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[3368]33using HeuristicLab.Random;
[3044]34
[3100]35namespace HeuristicLab.Algorithms.TabuSearch {
[3280]36  [Item("Tabu Search", "A tabu search algorithm.")]
[3074]37  [Creatable("Algorithms")]
[3201]38  [StorableClass]
[4437]39  public sealed class TabuSearch : EngineAlgorithm, IStorableContent {
40    public string Filename { get; set; }
41
[3074]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
[3048]53    private ValueParameter<IntValue> SeedParameter {
54      get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
[3044]55    }
[3048]56    private ValueParameter<BoolValue> SetSeedRandomlyParameter {
57      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
[3044]58    }
59    private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
60      get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
61    }
[3074]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    }
[3340]68    private ConstrainedValueParameter<ITabuChecker> TabuCheckerParameter {
69      get { return (ConstrainedValueParameter<ITabuChecker>)Parameters["TabuChecker"]; }
[3074]70    }
[3340]71    private ConstrainedValueParameter<ITabuMaker> TabuMakerParameter {
72      get { return (ConstrainedValueParameter<ITabuMaker>)Parameters["TabuMaker"]; }
[3074]73    }
74    private ValueParameter<IntValue> TabuTenureParameter {
75      get { return (ValueParameter<IntValue>)Parameters["TabuTenure"]; }
76    }
[3048]77    private ValueParameter<IntValue> MaximumIterationsParameter {
78      get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; }
[3044]79    }
[3141]80    private ValueParameter<IntValue> SampleSizeParameter {
81      get { return (ValueParameter<IntValue>)Parameters["SampleSize"]; }
82    }
[3658]83    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
84      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
[3636]85    }
[3044]86    #endregion
87
88    #region Properties
[3048]89    public IntValue Seed {
[3044]90      get { return SeedParameter.Value; }
91      set { SeedParameter.Value = value; }
92    }
[3048]93    public BoolValue SetSeedRandomly {
[3044]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    }
[3074]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    }
[3340]109    public ITabuChecker TabuChecker {
110      get { return TabuCheckerParameter.Value; }
111      set { TabuCheckerParameter.Value = value; }
[3074]112    }
[3340]113    public ITabuMaker TabuMaker {
114      get { return TabuMakerParameter.Value; }
115      set { TabuMakerParameter.Value = value; }
[3074]116    }
117    public IntValue TabuTenure {
118      get { return TabuTenureParameter.Value; }
119      set { TabuTenureParameter.Value = value; }
120    }
[3048]121    public IntValue MaximumIterations {
[3044]122      get { return MaximumIterationsParameter.Value; }
123      set { MaximumIterationsParameter.Value = value; }
124    }
[3658]125    public MultiAnalyzer Analyzer {
[3636]126      get { return AnalyzerParameter.Value; }
127      set { AnalyzerParameter.Value = value; }
128    }
[3044]129    private RandomCreator RandomCreator {
130      get { return (RandomCreator)OperatorGraph.InitialOperator; }
131    }
132    private SolutionsCreator SolutionsCreator {
133      get { return (SolutionsCreator)RandomCreator.Successor; }
134    }
[3100]135    private TabuSearchMainLoop MainLoop {
136      get { return (TabuSearchMainLoop)SolutionsCreator.Successor; }
[3044]137    }
[3689]138    [Storable]
[3662]139    private BestAverageWorstQualityAnalyzer moveQualityAnalyzer;
[3689]140    [Storable]
[3636]141    private TabuNeighborhoodAnalyzer tabuNeighborhoodAnalyzer;
[3044]142    #endregion
143
[3100]144    public TabuSearch()
[3044]145      : base() {
[3048]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)));
[3044]148      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
[3074]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."));
[3340]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."));
[3074]153      Parameters.Add(new ValueParameter<IntValue>("TabuTenure", "The length of the tabu list.", new IntValue(10)));
[3048]154      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000)));
[3340]155      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "The neighborhood size for stochastic sampling move generators", new IntValue(100)));
[3658]156      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer()));
[4068]157
[3044]158      RandomCreator randomCreator = new RandomCreator();
159      SolutionsCreator solutionsCreator = new SolutionsCreator();
[3100]160      TabuSearchMainLoop tsMainLoop = new TabuSearchMainLoop();
[3044]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
[3048]170      solutionsCreator.NumberOfSolutions = new IntValue(1);
[3044]171      solutionsCreator.Successor = tsMainLoop;
172
173      tsMainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
[3074]174      tsMainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
175      tsMainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
[3340]176      tsMainLoop.TabuCheckerParameter.ActualName = TabuCheckerParameter.Name;
177      tsMainLoop.TabuMakerParameter.ActualName = TabuMakerParameter.Name;
[3074]178      tsMainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
[3044]179      tsMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
180      tsMainLoop.ResultsParameter.ActualName = "Results";
[3636]181      tsMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
[3044]182
[3689]183      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
184      tabuNeighborhoodAnalyzer = new TabuNeighborhoodAnalyzer();
185      ParameterizeAnalyzers();
186      UpdateAnalyzers();
187
[3074]188      Initialize();
[3044]189    }
[3280]190    [StorableConstructor]
191    private TabuSearch(bool deserializing) : base(deserializing) { }
[4722]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    }
[3044]202    public override IDeepCloneable Clone(Cloner cloner) {
[4722]203      return new TabuSearch(this, cloner);
[3044]204    }
205
[3275]206    public override void Prepare() {
[3265]207      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null &&
[3340]208          TabuChecker != null && TabuMaker != null)
[3275]209        base.Prepare();
[3189]210    }
211
[3044]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);
[3074]217      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
218        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
219      }
[3232]220      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
[3340]221        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
[3104]222      }
[3044]223      ParameterizeSolutionsCreator();
[3104]224      ParameterizeMainLoop();
[3187]225      UpdateMoveGenerator();
226      UpdateMoveParameters();
[3636]227      UpdateAnalyzers();
[3141]228      ParameterizeMoveGenerators();
[3074]229      ParameterizeMoveEvaluator();
230      ParameterizeMoveMaker();
[3340]231      ParameterizeTabuMaker();
232      ParameterizeTabuChecker();
[3636]233      ParameterizeAnalyzers();
[3750]234      ParameterizeIterationBasedOperators();
[3044]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();
[3104]246      ParameterizeMainLoop();
[3074]247      ParameterizeMoveEvaluator();
248      ParameterizeMoveMaker();
[3340]249      ParameterizeTabuMaker();
250      ParameterizeTabuChecker();
[3636]251      ParameterizeAnalyzers();
[3044]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);
[3074]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      }
[3232]263      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
[3340]264        op.MoveTabuParameter.ActualNameChanged -= new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
265        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
[3104]266      }
[3074]267      UpdateMoveGenerator();
[3187]268      UpdateMoveParameters();
[3636]269      UpdateAnalyzers();
[3104]270      ParameterizeMainLoop();
[3141]271      ParameterizeMoveGenerators();
[3074]272      ParameterizeMoveEvaluator();
273      ParameterizeMoveMaker();
[3340]274      ParameterizeTabuMaker();
275      ParameterizeTabuChecker();
[3636]276      ParameterizeAnalyzers();
[3750]277      ParameterizeIterationBasedOperators();
[3044]278      base.Problem_OperatorsChanged(sender, e);
279    }
[3074]280    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
[3104]281      ParameterizeMainLoop();
[3074]282      ParameterizeMoveEvaluator();
283      ParameterizeMoveMaker();
[3340]284      ParameterizeTabuMaker();
285      ParameterizeTabuChecker();
[3044]286    }
[3074]287    private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) {
288      UpdateMoveParameters();
[3044]289    }
[3074]290    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
[3104]291      ParameterizeMainLoop();
[3074]292      ParameterizeMoveEvaluator();
293      ParameterizeMoveMaker();
[3340]294      ParameterizeTabuMaker();
295      ParameterizeTabuChecker();
[3636]296      ParameterizeAnalyzers();
[3044]297    }
[3074]298    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
[3104]299      ParameterizeMainLoop();
[3074]300      ParameterizeMoveEvaluator();
301      ParameterizeMoveMaker();
[3340]302      ParameterizeTabuMaker();
303      ParameterizeTabuChecker();
[3636]304      ParameterizeAnalyzers();
[3044]305    }
[3340]306    private void TabuCheckerParameter_ValueChanged(object sender, EventArgs e) {
[3104]307      ParameterizeMainLoop();
[3636]308      ParameterizeAnalyzers();
[3104]309    }
[3340]310    private void TabuChecker_MoveTabuParameter_ActualNameChanged(object sender, EventArgs e) {
[3104]311      ParameterizeMainLoop();
[3636]312      ParameterizeAnalyzers();
[3104]313    }
[3141]314    private void SampleSizeParameter_NameChanged(object sender, EventArgs e) {
315      ParameterizeMoveGenerators();
316    }
[3044]317    #endregion
318
319    #region Helpers
[3074]320    private void Initialize() {
321      if (Problem != null) {
[3044]322        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
[3074]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);
[3340]329      TabuCheckerParameter.ValueChanged += new EventHandler(TabuCheckerParameter_ValueChanged);
[3141]330      SampleSizeParameter.NameChanged += new EventHandler(SampleSizeParameter_NameChanged);
[3044]331    }
[3074]332    private void UpdateMoveGenerator() {
333      IMoveGenerator oldMoveGenerator = MoveGenerator;
334      MoveGeneratorParameter.ValidValues.Clear();
335      if (Problem != null) {
[3141]336        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
[3074]337          MoveGeneratorParameter.ValidValues.Add(generator);
[3141]338        }
[3074]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;
[3340]349      ITabuChecker oldTabuMoveEvaluator = TabuChecker;
350      ITabuMaker oldTabuMoveMaker = TabuMaker;
[3074]351      ClearMoveParameters();
[3131]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);
[3232]364          foreach (ITabuChecker tabuMoveEvaluator in operators.OfType<ITabuChecker>())
[3340]365            TabuCheckerParameter.ValidValues.Add(tabuMoveEvaluator);
[3232]366          foreach (ITabuMaker tabuMoveMaker in operators.OfType<ITabuMaker>())
[3340]367            TabuMakerParameter.ValidValues.Add(tabuMoveMaker);
[3131]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) {
[3340]378          ITabuMaker tmm = TabuMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveMaker.GetType());
379          if (tmm != null) TabuMaker = tmm;
[3131]380        }
381        if (oldTabuMoveEvaluator != null) {
[3340]382          ITabuChecker tme = TabuCheckerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveEvaluator.GetType());
383          if (tme != null) TabuChecker = tme;
[3131]384        }
[3074]385      }
386    }
[3636]387    private void UpdateAnalyzers() {
388      Analyzer.Operators.Clear();
389      if (Problem != null) {
[3816]390        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
[3671]391          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
392            param.Depth = 0;
[3636]393          Analyzer.Operators.Add(analyzer);
[3671]394        }
[3636]395      }
[3809]396      Analyzer.Operators.Add(moveQualityAnalyzer);
397      Analyzer.Operators.Add(tabuNeighborhoodAnalyzer);
[3636]398    }
[3074]399    private void ClearMoveParameters() {
400      MoveMakerParameter.ValidValues.Clear();
401      MoveEvaluatorParameter.ValidValues.Clear();
[3340]402      TabuCheckerParameter.ValidValues.Clear();
403      TabuMakerParameter.ValidValues.Clear();
[3074]404    }
[3044]405    private void ParameterizeSolutionsCreator() {
406      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
407      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
408    }
[3104]409    private void ParameterizeMainLoop() {
[3141]410      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
[3100]411      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
412      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
[3074]413      if (MoveEvaluator != null)
[3100]414        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
[3340]415      if (TabuChecker != null)
416        MainLoop.MoveTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
[3044]417    }
418    private void ParameterizeStochasticOperator(IOperator op) {
419      if (op is IStochasticOperator)
420        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
421    }
[3141]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    }
[3074]428    private void ParameterizeMoveEvaluator() {
429      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
430        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
[3044]431      }
432    }
[3074]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;
[3044]438      }
439    }
[3340]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    }
[3636]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    }
[3750]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    }
[3044]476    #endregion
477  }
478}
Note: See TracBrowser for help on using the repository browser.