Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs @ 14350

Last change on this file since 14350 was 14185, checked in by swagner, 8 years ago

#2526: Updated year of copyrights in license headers

File size: 21.0 KB
RevLine 
[3078]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3078]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;
[4068]25using HeuristicLab.Analysis;
[3376]26using HeuristicLab.Common;
[3078]27using HeuristicLab.Core;
28using HeuristicLab.Data;
[5356]29using HeuristicLab.Operators;
[3078]30using HeuristicLab.Optimization;
31using HeuristicLab.Optimization.Operators;
32using HeuristicLab.Parameters;
33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[3368]34using HeuristicLab.Random;
[3078]35
[3103]36namespace HeuristicLab.Algorithms.LocalSearch {
[13173]37  [Item("Local Search (LS)", "A local search algorithm.")]
[12504]38  [Creatable(CreatableAttribute.Categories.SingleSolutionAlgorithms, Priority = 100)]
[3201]39  [StorableClass]
[5809]40  public sealed class LocalSearch : HeuristicOptimizationEngineAlgorithm, IStorableContent {
[4437]41    public string Filename { get; set; }
42
[3078]43    #region Problem Properties
44    public override Type ProblemType {
[5809]45      get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
[3078]46    }
[5809]47    public new ISingleObjectiveHeuristicOptimizationProblem Problem {
48      get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
[3078]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    }
[8121]60    public IConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
61      get { return (IConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
[3078]62    }
[8121]63    public IConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
64      get { return (IConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; }
[3078]65    }
[8121]66    public IConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
67      get { return (IConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
[3078]68    }
69    private ValueParameter<IntValue> MaximumIterationsParameter {
70      get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; }
71    }
[3187]72    private ValueParameter<IntValue> SampleSizeParameter {
73      get { return (ValueParameter<IntValue>)Parameters["SampleSize"]; }
74    }
[3658]75    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
76      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
[3621]77    }
[3078]78    #endregion
79
80    #region Properties
81    public IntValue Seed {
82      get { return SeedParameter.Value; }
83      set { SeedParameter.Value = value; }
84    }
85    public BoolValue SetSeedRandomly {
86      get { return SetSeedRandomlyParameter.Value; }
87      set { SetSeedRandomlyParameter.Value = value; }
88    }
89    public IMoveGenerator MoveGenerator {
90      get { return MoveGeneratorParameter.Value; }
91      set { MoveGeneratorParameter.Value = value; }
92    }
93    public IMoveMaker MoveMaker {
94      get { return MoveMakerParameter.Value; }
95      set { MoveMakerParameter.Value = value; }
96    }
97    public ISingleObjectiveMoveEvaluator MoveEvaluator {
98      get { return MoveEvaluatorParameter.Value; }
99      set { MoveEvaluatorParameter.Value = value; }
100    }
101    public IntValue MaximumIterations {
102      get { return MaximumIterationsParameter.Value; }
103      set { MaximumIterationsParameter.Value = value; }
104    }
[3187]105    public IntValue SampleSize {
106      get { return SampleSizeParameter.Value; }
107      set { SampleSizeParameter.Value = value; }
108    }
[3658]109    public MultiAnalyzer Analyzer {
[3621]110      get { return AnalyzerParameter.Value; }
111      set { AnalyzerParameter.Value = value; }
112    }
[3078]113    private RandomCreator RandomCreator {
114      get { return (RandomCreator)OperatorGraph.InitialOperator; }
115    }
116    private SolutionsCreator SolutionsCreator {
117      get { return (SolutionsCreator)RandomCreator.Successor; }
118    }
[3103]119    private LocalSearchMainLoop MainLoop {
[5366]120      get { return FindMainLoop(SolutionsCreator.Successor); }
[3078]121    }
[3689]122    [Storable]
[3662]123    private BestAverageWorstQualityAnalyzer moveQualityAnalyzer;
[3078]124    #endregion
125
[3621]126    [StorableConstructor]
127    private LocalSearch(bool deserializing) : base(deserializing) { }
[4722]128    [StorableHook(HookType.AfterDeserialization)]
129    private void AfterDeserialization() {
130      Initialize();
131    }
132    private LocalSearch(LocalSearch original, Cloner cloner)
133      : base(original, cloner) {
134      moveQualityAnalyzer = cloner.Clone(original.moveQualityAnalyzer);
135      Initialize();
136    }
137    public override IDeepCloneable Clone(Cloner cloner) {
138      return new LocalSearch(this, cloner);
139    }
[3103]140    public LocalSearch()
[3078]141      : base() {
142      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
143      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
144      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
145      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
146      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
147      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000)));
[3187]148      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(100)));
[3809]149      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.", new MultiAnalyzer()));
[4068]150
[3078]151      RandomCreator randomCreator = new RandomCreator();
152      SolutionsCreator solutionsCreator = new SolutionsCreator();
[5356]153      VariableCreator variableCreator = new VariableCreator();
154      ResultsCollector resultsCollector = new ResultsCollector();
155      LocalSearchMainLoop mainLoop = new LocalSearchMainLoop();
[3078]156      OperatorGraph.InitialOperator = randomCreator;
157
158      randomCreator.RandomParameter.ActualName = "Random";
159      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
160      randomCreator.SeedParameter.Value = null;
161      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
162      randomCreator.SetSeedRandomlyParameter.Value = null;
163      randomCreator.Successor = solutionsCreator;
164
165      solutionsCreator.NumberOfSolutions = new IntValue(1);
[5356]166      solutionsCreator.Successor = variableCreator;
[3078]167
[5356]168      variableCreator.Name = "Initialize EvaluatedMoves";
169      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue()));
[5753]170      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
171      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestQuality", new DoubleValue(0)));
[5356]172      variableCreator.Successor = resultsCollector;
[3078]173
[5356]174      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
175      resultsCollector.ResultsParameter.ActualName = "Results";
176      resultsCollector.Successor = mainLoop;
177
178      mainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
179      mainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
180      mainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
181      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
182      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
183      mainLoop.ResultsParameter.ActualName = "Results";
184      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
185      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
[5753]186      mainLoop.IterationsParameter.ActualName = "Iterations";
[6042]187      mainLoop.BestLocalQualityParameter.ActualName = "BestQuality";
[5356]188
[3689]189      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
190      ParameterizeAnalyzers();
191      UpdateAnalyzers();
192
[3078]193      Initialize();
194    }
195
[3275]196    public override void Prepare() {
[3265]197      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null)
[3275]198        base.Prepare();
[3189]199    }
200
[3078]201    #region Events
202    protected override void OnProblemChanged() {
203      ParameterizeStochasticOperator(Problem.SolutionCreator);
204      ParameterizeStochasticOperator(Problem.Evaluator);
[7999]205      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
[3078]206      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
207        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
208      }
209      ParameterizeSolutionsCreator();
[3134]210      ParameterizeMainLoop();
[3750]211      UpdateMoveGenerator();
212      UpdateMoveParameters();
213      UpdateAnalyzers();
[4048]214      ParameterizeMoveGenerators();
[3145]215      ParameterizeMoveEvaluators();
216      ParameterizeMoveMakers();
[3621]217      ParameterizeAnalyzers();
[3750]218      ParameterizeIterationBasedOperators();
[3078]219      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
220      base.OnProblemChanged();
221    }
222    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
223      ParameterizeStochasticOperator(Problem.SolutionCreator);
224      ParameterizeSolutionsCreator();
225      base.Problem_SolutionCreatorChanged(sender, e);
226    }
227    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
228      ParameterizeStochasticOperator(Problem.Evaluator);
229      ParameterizeSolutionsCreator();
[3134]230      ParameterizeMainLoop();
[3145]231      ParameterizeMoveEvaluators();
232      ParameterizeMoveMakers();
[3621]233      ParameterizeAnalyzers();
[3078]234      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
235      base.Problem_EvaluatorChanged(sender, e);
236    }
237    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
[8351]238      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
[3078]239      // This may seem pointless, but some operators already have the eventhandler registered, others don't
240      // FIXME: Is there another way to solve this problem?
241      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
242        op.MoveQualityParameter.ActualNameChanged -= new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
243        op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
244      }
245      UpdateMoveGenerator();
[3187]246      UpdateMoveParameters();
[3621]247      UpdateAnalyzers();
[3134]248      ParameterizeMainLoop();
[4048]249      ParameterizeMoveGenerators();
[3145]250      ParameterizeMoveEvaluators();
251      ParameterizeMoveMakers();
[3636]252      ParameterizeAnalyzers();
[3750]253      ParameterizeIterationBasedOperators();
[3078]254      base.Problem_OperatorsChanged(sender, e);
255    }
256    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
[3134]257      ParameterizeMainLoop();
[3145]258      ParameterizeMoveEvaluators();
259      ParameterizeMoveMakers();
[3078]260    }
261    private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) {
262      UpdateMoveParameters();
263    }
264    private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) {
[3134]265      ParameterizeMainLoop();
[3145]266      ParameterizeMoveEvaluators();
267      ParameterizeMoveMakers();
[3621]268      ParameterizeAnalyzers();
[3078]269    }
270    private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) {
[3134]271      ParameterizeMainLoop();
[3145]272      ParameterizeMoveEvaluators();
273      ParameterizeMoveMakers();
[3621]274      ParameterizeAnalyzers();
[3078]275    }
276    #endregion
277
278    #region Helpers
279    private void Initialize() {
280      if (Problem != null) {
281        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
282        foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
283          op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged);
284        }
285      }
286      MoveGeneratorParameter.ValueChanged += new EventHandler(MoveGeneratorParameter_ValueChanged);
287      MoveEvaluatorParameter.ValueChanged += new EventHandler(MoveEvaluatorParameter_ValueChanged);
288    }
289    private void UpdateMoveGenerator() {
290      IMoveGenerator oldMoveGenerator = MoveGenerator;
[7510]291      IMoveGenerator defaultMoveGenerator = Problem.Operators.OfType<IMoveGenerator>().FirstOrDefault();
[3078]292      MoveGeneratorParameter.ValidValues.Clear();
293      if (Problem != null) {
294        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name))
295          MoveGeneratorParameter.ValidValues.Add(generator);
296      }
[3145]297      if (oldMoveGenerator != null) {
298        IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType());
299        if (newMoveGenerator != null) MoveGenerator = newMoveGenerator;
[7510]300        else oldMoveGenerator = null;
[3145]301      }
[7510]302      if (oldMoveGenerator == null && defaultMoveGenerator != null)
303        MoveGenerator = defaultMoveGenerator;
[3078]304      if (MoveGenerator == null) {
305        ClearMoveParameters();
306      }
307    }
308    private void UpdateMoveParameters() {
309      IMoveMaker oldMoveMaker = MoveMaker;
310      ISingleObjectiveMoveEvaluator oldMoveEvaluator = MoveEvaluator;
311      ClearMoveParameters();
[3131]312      if (MoveGenerator != null) {
313        List<Type> moveTypes = MoveGenerator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList();
314        foreach (Type type in moveTypes.ToList()) {
315          if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t)))
316            moveTypes.Remove(type);
317        }
[7510]318
319        var operators = Problem.Operators.Where(op => moveTypes.Any(m => m.IsInstanceOfType(op))).ToList();
320        IMoveMaker defaultMoveMaker = operators.OfType<IMoveMaker>().FirstOrDefault();
321        ISingleObjectiveMoveEvaluator defaultMoveEvaluator = operators.OfType<ISingleObjectiveMoveEvaluator>().FirstOrDefault();
322        foreach (IMoveMaker moveMaker in operators.OfType<IMoveMaker>().OrderBy(op => op.Name))
323          MoveMakerParameter.ValidValues.Add(moveMaker);
324        foreach (ISingleObjectiveMoveEvaluator moveEvaluator in operators.OfType<ISingleObjectiveMoveEvaluator>().OrderBy(op => op.Name))
325          MoveEvaluatorParameter.ValidValues.Add(moveEvaluator);
326
[3131]327        if (oldMoveMaker != null) {
328          IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType());
329          if (mm != null) MoveMaker = mm;
[7510]330          else oldMoveMaker = null;
[3131]331        }
[7510]332        if (oldMoveMaker == null && defaultMoveMaker != null)
333          MoveMaker = defaultMoveMaker;
334
[3131]335        if (oldMoveEvaluator != null) {
336          ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType());
337          if (me != null) MoveEvaluator = me;
[7510]338          else oldMoveEvaluator = null;
[3131]339        }
[7510]340        if (oldMoveEvaluator == null && defaultMoveEvaluator != null)
341          MoveEvaluator = defaultMoveEvaluator;
[3078]342      }
343    }
[3621]344    private void UpdateAnalyzers() {
345      Analyzer.Operators.Clear();
[3626]346      if (Problem != null) {
[3816]347        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
[3669]348          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
349            param.Depth = 0;
[7172]350          Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
[3669]351        }
[3626]352      }
[7172]353      Analyzer.Operators.Add(moveQualityAnalyzer, moveQualityAnalyzer.EnabledByDefault);
[3621]354    }
[3078]355    private void ClearMoveParameters() {
356      MoveMakerParameter.ValidValues.Clear();
357      MoveEvaluatorParameter.ValidValues.Clear();
358    }
359    private void ParameterizeSolutionsCreator() {
360      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
361      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
362    }
[3134]363    private void ParameterizeMainLoop() {
[6053]364      if (Problem != null) {
365        MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
366        MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
367        MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
368      }
[3078]369      if (MoveEvaluator != null)
[3103]370        MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
[3078]371    }
372    private void ParameterizeStochasticOperator(IOperator op) {
[6053]373      if (op is IStochasticOperator) {
374        IStochasticOperator stOp = (IStochasticOperator)op;
375        stOp.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
376        stOp.RandomParameter.Hidden = true;
377      }
[3078]378    }
[4048]379    private void ParameterizeMoveGenerators() {
380      if (Problem != null) {
[6053]381        foreach (IMultiMoveGenerator generator in Problem.Operators.OfType<IMultiMoveGenerator>()) {
[4048]382          generator.SampleSizeParameter.ActualName = SampleSizeParameter.Name;
[6053]383          generator.SampleSizeParameter.Hidden = true;
384        }
[4048]385      }
386    }
[3145]387    private void ParameterizeMoveEvaluators() {
[3078]388      foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
389        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
[6053]390        op.QualityParameter.Hidden = true;
[3078]391      }
392    }
[3145]393    private void ParameterizeMoveMakers() {
[3078]394      foreach (IMoveMaker op in Problem.Operators.OfType<IMoveMaker>()) {
395        op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
[6053]396        op.QualityParameter.Hidden = true;
397        if (MoveEvaluator != null) {
[3078]398          op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
[6053]399          op.MoveQualityParameter.Hidden = true;
400        } else {
401          op.MoveQualityParameter.Hidden = false;
402        }
[3078]403      }
404    }
[3621]405    private void ParameterizeAnalyzers() {
406      moveQualityAnalyzer.ResultsParameter.ActualName = "Results";
[6053]407      moveQualityAnalyzer.ResultsParameter.Hidden = true;
[3621]408      if (Problem != null) {
409        moveQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
[6053]410        moveQualityAnalyzer.MaximizationParameter.Hidden = true;
411        if (MoveEvaluator != null) {
[3621]412          moveQualityAnalyzer.QualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
[6053]413          moveQualityAnalyzer.QualityParameter.Hidden = true;
414        } else moveQualityAnalyzer.QualityParameter.Hidden = false;
[3621]415        moveQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
[6053]416        moveQualityAnalyzer.BestKnownQualityParameter.Hidden = true;
417      } else {
418        moveQualityAnalyzer.MaximizationParameter.Hidden = false;
419        moveQualityAnalyzer.BestKnownQualityParameter.Hidden = false;
[3621]420      }
421    }
[3750]422    private void ParameterizeIterationBasedOperators() {
423      if (Problem != null) {
424        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
425          op.IterationsParameter.ActualName = "Iterations";
[6053]426          op.IterationsParameter.Hidden = true;
[3750]427          op.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
[6053]428          op.MaximumIterationsParameter.Hidden = true;
[3750]429        }
430      }
431    }
[5366]432    private LocalSearchMainLoop FindMainLoop(IOperator start) {
433      IOperator mainLoop = start;
434      while (mainLoop != null && !(mainLoop is LocalSearchMainLoop))
435        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
436      if (mainLoop == null) return null;
437      else return (LocalSearchMainLoop)mainLoop;
438    }
[3078]439    #endregion
440  }
441}
Note: See TracBrowser for help on using the repository browser.