Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4711 was 4437, checked in by swagner, 14 years ago

Implemented !IStorableContent separately for each algorithm (#1193)

File size: 22.8 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) { }
[3074]192
[3044]193    public override IDeepCloneable Clone(Cloner cloner) {
[3100]194      TabuSearch clone = (TabuSearch)base.Clone(cloner);
[3689]195      clone.moveQualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(moveQualityAnalyzer);
196      clone.tabuNeighborhoodAnalyzer = (TabuNeighborhoodAnalyzer)cloner.Clone(tabuNeighborhoodAnalyzer);
[3074]197      clone.Initialize();
[3044]198      return clone;
199    }
200
[3275]201    public override void Prepare() {
[3265]202      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null &&
[3340]203          TabuChecker != null && TabuMaker != null)
[3275]204        base.Prepare();
[3189]205    }
206
[3044]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);
[3074]212      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
213        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
214      }
[3232]215      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
[3340]216        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
[3104]217      }
[3044]218      ParameterizeSolutionsCreator();
[3104]219      ParameterizeMainLoop();
[3187]220      UpdateMoveGenerator();
221      UpdateMoveParameters();
[3636]222      UpdateAnalyzers();
[3141]223      ParameterizeMoveGenerators();
[3074]224      ParameterizeMoveEvaluator();
225      ParameterizeMoveMaker();
[3340]226      ParameterizeTabuMaker();
227      ParameterizeTabuChecker();
[3636]228      ParameterizeAnalyzers();
[3750]229      ParameterizeIterationBasedOperators();
[3044]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();
[3104]241      ParameterizeMainLoop();
[3074]242      ParameterizeMoveEvaluator();
243      ParameterizeMoveMaker();
[3340]244      ParameterizeTabuMaker();
245      ParameterizeTabuChecker();
[3636]246      ParameterizeAnalyzers();
[3044]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);
[3074]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      }
[3232]258      foreach (ITabuChecker op in Problem.Operators.OfType<ITabuChecker>()) {
[3340]259        op.MoveTabuParameter.ActualNameChanged -= new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
260        op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuChecker_MoveTabuParameter_ActualNameChanged);
[3104]261      }
[3074]262      UpdateMoveGenerator();
[3187]263      UpdateMoveParameters();
[3636]264      UpdateAnalyzers();
[3104]265      ParameterizeMainLoop();
[3141]266      ParameterizeMoveGenerators();
[3074]267      ParameterizeMoveEvaluator();
268      ParameterizeMoveMaker();
[3340]269      ParameterizeTabuMaker();
270      ParameterizeTabuChecker();
[3636]271      ParameterizeAnalyzers();
[3750]272      ParameterizeIterationBasedOperators();
[3044]273      base.Problem_OperatorsChanged(sender, e);
274    }
[3074]275    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
[3104]276      ParameterizeMainLoop();
[3074]277      ParameterizeMoveEvaluator();
278      ParameterizeMoveMaker();
[3340]279      ParameterizeTabuMaker();
280      ParameterizeTabuChecker();
[3044]281    }
[3074]282    private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) {
283      UpdateMoveParameters();
[3044]284    }
[3074]285    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
[3104]286      ParameterizeMainLoop();
[3074]287      ParameterizeMoveEvaluator();
288      ParameterizeMoveMaker();
[3340]289      ParameterizeTabuMaker();
290      ParameterizeTabuChecker();
[3636]291      ParameterizeAnalyzers();
[3044]292    }
[3074]293    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
[3104]294      ParameterizeMainLoop();
[3074]295      ParameterizeMoveEvaluator();
296      ParameterizeMoveMaker();
[3340]297      ParameterizeTabuMaker();
298      ParameterizeTabuChecker();
[3636]299      ParameterizeAnalyzers();
[3044]300    }
[3340]301    private void TabuCheckerParameter_ValueChanged(object sender, EventArgs e) {
[3104]302      ParameterizeMainLoop();
[3636]303      ParameterizeAnalyzers();
[3104]304    }
[3340]305    private void TabuChecker_MoveTabuParameter_ActualNameChanged(object sender, EventArgs e) {
[3104]306      ParameterizeMainLoop();
[3636]307      ParameterizeAnalyzers();
[3104]308    }
[3141]309    private void SampleSizeParameter_NameChanged(object sender, EventArgs e) {
310      ParameterizeMoveGenerators();
311    }
[3044]312    #endregion
313
314    #region Helpers
315    [StorableHook(HookType.AfterDeserialization)]
[3074]316    private void Initialize() {
317      if (Problem != null) {
[3044]318        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
[3074]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);
[3340]325      TabuCheckerParameter.ValueChanged += new EventHandler(TabuCheckerParameter_ValueChanged);
[3141]326      SampleSizeParameter.NameChanged += new EventHandler(SampleSizeParameter_NameChanged);
[3044]327    }
[3074]328    private void UpdateMoveGenerator() {
329      IMoveGenerator oldMoveGenerator = MoveGenerator;
330      MoveGeneratorParameter.ValidValues.Clear();
331      if (Problem != null) {
[3141]332        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
[3074]333          MoveGeneratorParameter.ValidValues.Add(generator);
[3141]334        }
[3074]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;
[3340]345      ITabuChecker oldTabuMoveEvaluator = TabuChecker;
346      ITabuMaker oldTabuMoveMaker = TabuMaker;
[3074]347      ClearMoveParameters();
[3131]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);
[3232]360          foreach (ITabuChecker tabuMoveEvaluator in operators.OfType<ITabuChecker>())
[3340]361            TabuCheckerParameter.ValidValues.Add(tabuMoveEvaluator);
[3232]362          foreach (ITabuMaker tabuMoveMaker in operators.OfType<ITabuMaker>())
[3340]363            TabuMakerParameter.ValidValues.Add(tabuMoveMaker);
[3131]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) {
[3340]374          ITabuMaker tmm = TabuMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveMaker.GetType());
375          if (tmm != null) TabuMaker = tmm;
[3131]376        }
377        if (oldTabuMoveEvaluator != null) {
[3340]378          ITabuChecker tme = TabuCheckerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldTabuMoveEvaluator.GetType());
379          if (tme != null) TabuChecker = tme;
[3131]380        }
[3074]381      }
382    }
[3636]383    private void UpdateAnalyzers() {
384      Analyzer.Operators.Clear();
385      if (Problem != null) {
[3816]386        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
[3671]387          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
388            param.Depth = 0;
[3636]389          Analyzer.Operators.Add(analyzer);
[3671]390        }
[3636]391      }
[3809]392      Analyzer.Operators.Add(moveQualityAnalyzer);
393      Analyzer.Operators.Add(tabuNeighborhoodAnalyzer);
[3636]394    }
[3074]395    private void ClearMoveParameters() {
396      MoveMakerParameter.ValidValues.Clear();
397      MoveEvaluatorParameter.ValidValues.Clear();
[3340]398      TabuCheckerParameter.ValidValues.Clear();
399      TabuMakerParameter.ValidValues.Clear();
[3074]400    }
[3044]401    private void ParameterizeSolutionsCreator() {
402      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
403      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
404    }
[3104]405    private void ParameterizeMainLoop() {
[3141]406      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
[3100]407      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
408      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
[3074]409      if (MoveEvaluator != null)
[3100]410        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
[3340]411      if (TabuChecker != null)
412        MainLoop.MoveTabuParameter.ActualName = TabuChecker.MoveTabuParameter.ActualName;
[3044]413    }
414    private void ParameterizeStochasticOperator(IOperator op) {
415      if (op is IStochasticOperator)
416        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
417    }
[3141]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    }
[3074]424    private void ParameterizeMoveEvaluator() {
425      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
426        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
[3044]427      }
428    }
[3074]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;
[3044]434      }
435    }
[3340]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    }
[3636]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    }
[3750]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    }
[3044]472    #endregion
473  }
474}
Note: See TracBrowser for help on using the repository browser.