Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/22/11 16:45:46 (14 years ago)
Author:
mkommend
Message:

#1418: Merged trunk changes into branch.

Location:
branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.LocalSearch/3.3
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.LocalSearch/3.3/HeuristicLab.Algorithms.LocalSearch-3.3.csproj

    r5163 r5796  
    1212    <AssemblyName>HeuristicLab.Algorithms.LocalSearch-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    107108  <ItemGroup>
    108109    <Compile Include="HeuristicLabAlgorithmsLocalSearchPlugin.cs" />
     110    <Compile Include="LocalSearchImprovementOperator.cs" />
    109111    <Compile Include="LocalSearchMainLoop.cs" />
    110112    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r5644 r5796  
    168168      variableCreator.Name = "Initialize EvaluatedMoves";
    169169      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue()));
     170      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
     171      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestQuality", new DoubleValue(0)));
    170172      variableCreator.Successor = resultsCollector;
    171173
     
    182184      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
    183185      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
     186      mainLoop.IterationsParameter.ActualName = "Iterations";
     187      mainLoop.BestQualityParameter.ActualName = "BestQuality";
    184188
    185189      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
  • branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs

    r5792 r5796  
    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;
  • branches/DataAnalysis Refactoring/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchMainLoop.cs

    r5445 r5796  
    4646      get { return (LookupParameter<DoubleValue>)Parameters["Quality"]; }
    4747    }
     48    public LookupParameter<DoubleValue> BestQualityParameter {
     49      get { return (LookupParameter<DoubleValue>)Parameters["BestLocalQuality"]; }
     50    }
    4851    public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
    4952      get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     
    5154    public LookupParameter<DoubleValue> MoveQualityParameter {
    5255      get { return (LookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
     56    }
     57    public LookupParameter<IntValue> IterationsParameter {
     58      get { return (LookupParameter<IntValue>)Parameters["LocalIterations"]; }
    5359    }
    5460    public ValueLookupParameter<IntValue> MaximumIterationsParameter {
     
    7985    public LocalSearchMainLoop()
    8086      : base() {
    81       Initialize();
     87        Initialize();
    8288    }
    8389    private LocalSearchMainLoop(LocalSearchMainLoop original, Cloner cloner)
     
    9399      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
    94100      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
     101      Parameters.Add(new LookupParameter<DoubleValue>("BestLocalQuality", "The value which represents the best quality found so far."));
    95102      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
    96103      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move."));
     104      Parameters.Add(new LookupParameter<IntValue>("LocalIterations", "The number of generations."));
    97105      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed."));
    98106      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
     
    107115
    108116      #region Create operators
    109       VariableCreator variableCreator = new VariableCreator();
    110117      SubScopesProcessor subScopesProcessor0 = new SubScopesProcessor();
    111118      Assigner bestQualityInitializer = new Assigner();
     
    124131      Placeholder moveMaker = new Placeholder();
    125132      Assigner bestQualityUpdater = new Assigner();
     133      ResultsCollector resultsCollector2 = new ResultsCollector();
    126134      MergingReducer mergingReducer = new MergingReducer();
    127135      Placeholder analyzer2 = new Placeholder();
     
    131139      ConditionalBranch iterationsTermination = new ConditionalBranch();
    132140
    133       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); // Class LocalSearch expects this to be called Iterations
    134       variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestQuality", new DoubleValue(0)));
    135 
    136141      bestQualityInitializer.Name = "Initialize BestQuality";
    137       bestQualityInitializer.LeftSideParameter.ActualName = "BestQuality";
     142      bestQualityInitializer.LeftSideParameter.ActualName = BestQualityParameter.Name;
    138143      bestQualityInitializer.RightSideParameter.ActualName = QualityParameter.Name;
    139144
     
    142147
    143148      resultsCollector1.CopyValue = new BoolValue(false);
    144       resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
    145       resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
     149      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>(IterationsParameter.Name));
     150      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>(BestQualityParameter.Name, null, BestQualityParameter.Name));
    146151      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
    147152
     
    172177
    173178      bestQualityUpdater.Name = "Update BestQuality";
    174       bestQualityUpdater.LeftSideParameter.ActualName = "BestQuality";
     179      bestQualityUpdater.LeftSideParameter.ActualName = BestQualityParameter.Name;
    175180      bestQualityUpdater.RightSideParameter.ActualName = QualityParameter.Name;
     181
     182      resultsCollector2.CopyValue = new BoolValue(false);
     183      resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>(BestQualityParameter.Name, null, BestQualityParameter.Name));
     184      resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
    176185
    177186      analyzer2.Name = "Analyzer (placeholder)";
     
    182191      iterationsCounter.Name = "Iterations Counter";
    183192      iterationsCounter.Increment = new IntValue(1);
    184       iterationsCounter.ValueParameter.ActualName = "Iterations";
     193      iterationsCounter.ValueParameter.ActualName = IterationsParameter.Name;
    185194
    186195      iterationsComparator.Name = "Iterations >= MaximumIterations";
    187196      iterationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
    188       iterationsComparator.LeftSideParameter.ActualName = "Iterations";
     197      iterationsComparator.LeftSideParameter.ActualName = IterationsParameter.Name;
    189198      iterationsComparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
    190199      iterationsComparator.ResultParameter.ActualName = "Terminate";
     
    195204
    196205      #region Create operator graph
    197       OperatorGraph.InitialOperator = variableCreator;
    198       variableCreator.Successor = subScopesProcessor0;
     206      OperatorGraph.InitialOperator = subScopesProcessor0;
    199207      subScopesProcessor0.Operators.Add(bestQualityInitializer);
    200208      subScopesProcessor0.Successor = resultsCollector1;
Note: See TracChangeset for help on using the changeset viewer.