Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/23/11 01:09:38 (14 years ago)
Author:
mkommend
Message:

#1418: Reintegrated branch into trunk.

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3

    • Property svn:ignore
      •  

        old new  
        33obj
        44HeuristicLabAlgorithmsLocalSearchPlugin.cs
         5*.vs10x
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r5753 r5809  
    3838  [Creatable("Algorithms")]
    3939  [StorableClass]
    40   public sealed class LocalSearch : EngineAlgorithm, IStorableContent {
     40  public sealed class LocalSearch : HeuristicOptimizationEngineAlgorithm, IStorableContent {
    4141    public string Filename { get; set; }
    4242
    4343    #region Problem Properties
    4444    public override Type ProblemType {
    45       get { return typeof(ISingleObjectiveProblem); }
    46     }
    47     public new ISingleObjectiveProblem Problem {
    48       get { return (ISingleObjectiveProblem)base.Problem; }
     45      get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
     46    }
     47    public new ISingleObjectiveHeuristicOptimizationProblem Problem {
     48      get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
    4949      set { base.Problem = value; }
    5050    }
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs

    r5753 r5809  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Text;
     25using HeuristicLab.Analysis;
     26using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Data;
    2829using HeuristicLab.Operators;
    29 using HeuristicLab.Common;
    30 using HeuristicLab.Parameters;
    31 using HeuristicLab.Algorithms.LocalSearch;
    32 using HeuristicLab.Data;
    3330using HeuristicLab.Optimization;
    3431using HeuristicLab.Optimization.Operators;
    35 using HeuristicLab.Analysis;
     32using HeuristicLab.Parameters;
     33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3634
    3735namespace HeuristicLab.Algorithms.LocalSearch {
     
    4139  [Item("LocalSearchImprovementOperator", "A local search improvement operator.")]
    4240  [StorableClass]
    43   public class LocalSearchImprovementOperator: SingleSuccessorOperator, ILocalImprovementOperator {
     41  public class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator {
    4442    [Storable]
    4543    private LocalSearchMainLoop loop;
     
    4745    [Storable]
    4846    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
    49    
     47
    5048    private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
    5149      get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
     
    8886
    8987    [StorableConstructor]
    90     protected LocalSearchImprovementOperator(bool deserializing) : base(deserializing) {}
     88    protected LocalSearchImprovementOperator(bool deserializing) : base(deserializing) { }
    9189    [StorableHook(HookType.AfterDeserialization)]
    9290    private void AfterDeserialization() {
     
    9593    protected LocalSearchImprovementOperator(LocalSearchImprovementOperator original, Cloner cloner)
    9694      : base(original, cloner) {
    97         this.loop = cloner.Clone(original.loop);
    98         this.qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
    99         Initialize();
     95      this.loop = cloner.Clone(original.loop);
     96      this.qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
     97      Initialize();
    10098    }
    10199    public override IDeepCloneable Clone(Cloner cloner) {
     
    104102    public LocalSearchImprovementOperator()
    105103      : base() {
    106         loop = new LocalSearchMainLoop();
    107        
    108         ResultsCollector rc = (loop.OperatorGraph.InitialOperator as SingleSuccessorOperator).Successor as ResultsCollector;
    109         rc.CollectedValues.Remove("BestLocalQuality");
    110 
    111         qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
    112 
    113         Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
    114         Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
    115         Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
    116         Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(150)));
    117         Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(1500)));
    118         Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated moves."));
    119         Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer()));
    120 
    121         Initialize();
     104      loop = new LocalSearchMainLoop();
     105
     106      ResultsCollector rc = (loop.OperatorGraph.InitialOperator as SingleSuccessorOperator).Successor as ResultsCollector;
     107      rc.CollectedValues.Remove("BestLocalQuality");
     108
     109      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
     110
     111      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
     112      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
     113      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
     114      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(150)));
     115      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(1500)));
     116      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated moves."));
     117      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer()));
     118
     119      Initialize();
    122120    }
    123121
     
    130128      ChooseMoveOperators();
    131129
    132       ParameterizeMoveGenerators(problem as ISingleObjectiveProblem);
    133       ParameterizeMoveEvaluators(problem as ISingleObjectiveProblem);
    134       ParameterizeMoveMakers(problem as ISingleObjectiveProblem);
    135 
    136       ParameterizeAnalyzers(problem as ISingleObjectiveProblem);
    137       UpdateAnalyzers(problem as ISingleObjectiveProblem);
    138     }
    139 
    140     void ParameterizeAnalyzers(ISingleObjectiveProblem problem) {
     130      ParameterizeMoveGenerators(problem as ISingleObjectiveHeuristicOptimizationProblem);
     131      ParameterizeMoveEvaluators(problem as ISingleObjectiveHeuristicOptimizationProblem);
     132      ParameterizeMoveMakers(problem as ISingleObjectiveHeuristicOptimizationProblem);
     133
     134      ParameterizeAnalyzers(problem as ISingleObjectiveHeuristicOptimizationProblem);
     135      UpdateAnalyzers(problem as ISingleObjectiveHeuristicOptimizationProblem);
     136    }
     137
     138    void ParameterizeAnalyzers(ISingleObjectiveHeuristicOptimizationProblem problem) {
    141139      qualityAnalyzer.ResultsParameter.ActualName = "Results";
    142140      if (problem != null) {
     
    148146    }
    149147
    150     void UpdateAnalyzers(ISingleObjectiveProblem problem) {
     148    void UpdateAnalyzers(ISingleObjectiveHeuristicOptimizationProblem problem) {
    151149      Analyzer.Operators.Clear();
    152150      if (problem != null) {
     
    228226          if (mm != null) MoveMaker = mm;
    229227          else MoveMaker = validMoveMakers.FirstOrDefault();
    230         } 
     228        }
    231229
    232230        if (oldMoveEvaluator != null) {
     
    234232          if (me != null) MoveEvaluator = me;
    235233          else MoveEvaluator = validMoveEvaluators.FirstOrDefault();
    236         } 
     234        }
    237235      }
    238236    }
     
    244242    }
    245243
    246     private void ParameterizeMoveGenerators(ISingleObjectiveProblem problem) {
     244    private void ParameterizeMoveGenerators(ISingleObjectiveHeuristicOptimizationProblem problem) {
    247245      if (problem != null) {
    248246        foreach (IMultiMoveGenerator generator in problem.Operators.OfType<IMultiMoveGenerator>())
     
    250248      }
    251249    }
    252     private void ParameterizeMoveEvaluators(ISingleObjectiveProblem problem) {
     250    private void ParameterizeMoveEvaluators(ISingleObjectiveHeuristicOptimizationProblem problem) {
    253251      foreach (ISingleObjectiveMoveEvaluator op in problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {
    254252        op.QualityParameter.ActualName = problem.Evaluator.QualityParameter.ActualName;
    255253      }
    256254    }
    257     private void ParameterizeMoveMakers(ISingleObjectiveProblem problem) {
     255    private void ParameterizeMoveMakers(ISingleObjectiveHeuristicOptimizationProblem problem) {
    258256      foreach (IMoveMaker op in problem.Operators.OfType<IMoveMaker>()) {
    259257        op.QualityParameter.ActualName = problem.Evaluator.QualityParameter.ActualName;
Note: See TracChangeset for help on using the changeset viewer.