Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/13/12 18:42:59 (13 years ago)
Author:
jkarder
Message:

#1331:

  • added custom improvement operator (ScatterSearchImprovementOperator)
  • added parameters and adjusted types
  • replaced improvement operators with placeholders
  • changed access levels
Location:
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/HeuristicLab.Algorithms.ScatterSearch-3.3.csproj

    r7722 r7727  
    9292    <Compile Include="PopulationRebuildMethod.cs" />
    9393    <Compile Include="ScatterSearch.cs" />
     94    <Compile Include="ScatterSearchImprovementOperator.cs" />
    9495    <Compile Include="ScatterSearchMainLoop.cs" />
    9596    <Compile Include="SolutionCombinationMethod.cs" />
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs

    r7724 r7727  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Algorithms.LocalSearch;
    2625using HeuristicLab.Analysis;
    2726using HeuristicLab.Common;
     
    6059      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
    6160    }
     61    private ValueParameter<ILocalImprovementOperator> ImproverParameter {
     62      get { return (ValueParameter<ILocalImprovementOperator>)Parameters["Improver"]; }
     63    }
    6264    private ValueParameter<IntValue> MaximumIterationsParameter {
    6365      get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; }
    6466    }
    65     public ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
     67    private ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
    6668      get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
    6769    }
    68     public ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
     70    private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
    6971      get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
    7072    }
    71     public ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
     73    private ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
    7274      get { return (ConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; }
    7375    }
     
    106108      set { AnalyzerParameter.Value = value; }
    107109    }
     110    public ILocalImprovementOperator Improver {
     111      get { return ImproverParameter.Value; }
     112      set { ImproverParameter.Value = value; }
     113    }
    108114    public IntValue MaximumIterations {
    109115      get { return MaximumIterationsParameter.Value; }
     
    148154
    149155    [Storable]
    150     private BestAverageWorstQualityAnalyzer moveQualityAnalyzer;
     156    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
    151157    #endregion
    152158
     
    159165    private ScatterSearch(ScatterSearch original, Cloner cloner)
    160166      : base(original, cloner) {
    161       moveQualityAnalyzer = cloner.Clone(original.moveQualityAnalyzer);
     167      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
    162168      Initialize();
    163169    }
     
    169175      #region Create parameters
    170176      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.", new MultiAnalyzer()));
    171       Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(5)));
     177      Parameters.Add(new ValueParameter<ILocalImprovementOperator>("Improver", "The operator used to improve solutions.", new ScatterSearchImprovementOperator()));
     178      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000)));
    172179      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
    173180      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
    174181      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
    175       Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions that should be added to the reference set.", new IntValue(6)));
     182      Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions that should be added to the reference set.", new IntValue(5)));
    176183      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population.", new IntValue(30)));
    177184      Parameters.Add(new ValueParameter<IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(10)));
     
    185192      SolutionsCreator solutionsCreator = new SolutionsCreator();
    186193      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
    187       LocalSearchImprovementOperator localImprovementOperator = new LocalSearchImprovementOperator();
     194      Placeholder solutionEvaluator = new Placeholder();
     195      Placeholder solutionImprover = new Placeholder();
    188196      BestSelector bestSelector = new BestSelector();
    189197      VariableCreator variableCreator = new VariableCreator();
     
    203211      solutionsCreator.Successor = uniformSubScopesProcessor;
    204212
    205       uniformSubScopesProcessor.Operator = localImprovementOperator;
     213      uniformSubScopesProcessor.Operator = solutionImprover;
    206214      uniformSubScopesProcessor.Successor = bestSelector;
    207215
    208       localImprovementOperator.Name = "ImprovementMethod";
    209       localImprovementOperator.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
    210       localImprovementOperator.SampleSizeParameter.ActualName = SampleSizeParameter.Name;
    211       localImprovementOperator.Successor = null;
     216      solutionImprover.Name = "SolutionImprover";
     217      solutionImprover.OperatorParameter.ActualName = "Improver";
     218      solutionImprover.Successor = solutionEvaluator;
     219
     220      solutionEvaluator.Name = "SolutionEvaluator";
     221      solutionEvaluator.OperatorParameter.ActualName = "Evaluator";
     222      solutionEvaluator.Successor = null;
    212223
    213224      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
     
    233244      #endregion
    234245
    235       moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
     246      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
    236247      ParameterizeAnalyzers();
    237248      UpdateAnalyzers();
     
    318329      ParameterizeMoveEvaluators();
    319330      ParameterizeMoveMakers();
    320       ParameterizeAnalyzers();
    321331    }
    322332    #endregion
     
    397407        }
    398408      }
    399       Analyzer.Operators.Add(moveQualityAnalyzer, moveQualityAnalyzer.EnabledByDefault);
     409      Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
    400410    }
    401411    private void ClearMoveParameters() {
     
    450460    }
    451461    private void ParameterizeAnalyzers() {
    452       moveQualityAnalyzer.ResultsParameter.ActualName = "Results";
    453       moveQualityAnalyzer.ResultsParameter.Hidden = true;
    454       if (Problem != null) {
    455         moveQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
    456         moveQualityAnalyzer.MaximizationParameter.Hidden = true;
     462      qualityAnalyzer.ResultsParameter.ActualName = "Results";
     463      qualityAnalyzer.ResultsParameter.Hidden = true;
     464      if (Problem != null) {
     465        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     466        qualityAnalyzer.MaximizationParameter.Hidden = true;
    457467        if (MoveEvaluator != null) {
    458           moveQualityAnalyzer.QualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;
    459           moveQualityAnalyzer.QualityParameter.Hidden = true;
    460         } else moveQualityAnalyzer.QualityParameter.Hidden = false;
    461         moveQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    462         moveQualityAnalyzer.BestKnownQualityParameter.Hidden = true;
     468          qualityAnalyzer.QualityParameter.Hidden = true;
     469        } else qualityAnalyzer.QualityParameter.Hidden = false;
     470        qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
     471        qualityAnalyzer.BestKnownQualityParameter.Hidden = true;
    463472      } else {
    464         moveQualityAnalyzer.MaximizationParameter.Hidden = false;
    465         moveQualityAnalyzer.BestKnownQualityParameter.Hidden = false;
     473        qualityAnalyzer.MaximizationParameter.Hidden = false;
     474        qualityAnalyzer.BestKnownQualityParameter.Hidden = false;
    466475      }
    467476    }
  • branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearchMainLoop.cs

    r7724 r7727  
    2020#endregion
    2121
    22 using HeuristicLab.Algorithms.LocalSearch;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    7473      get { return (LookupParameter<VariableCollection>)Parameters["Results"]; }
    7574    }
    76     internal LookupParameter<IOperator> MoveEvaluatorParameter {
    77       get { return (LookupParameter<IOperator>)Parameters["MoveEvaluator"]; }
    78     }
    79     internal LookupParameter<IOperator> MoveGeneratorParameter {
    80       get { return (LookupParameter<IOperator>)Parameters["MoveGenerator"]; }
    81     }
    82     internal LookupParameter<IOperator> MoveMakerParameter {
    83       get { return (LookupParameter<IOperator>)Parameters["MoveMaker"]; }
     75    internal LookupParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
     76      get { return (LookupParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
     77    }
     78    internal LookupParameter<IMoveGenerator> MoveGeneratorParameter {
     79      get { return (LookupParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
     80    }
     81    internal LookupParameter<IMoveMaker> MoveMakerParameter {
     82      get { return (LookupParameter<IMoveMaker>)Parameters["MoveMaker"]; }
     83    }
     84    internal LookupParameter<IOperator> ImproverParameter {
     85      get { return (LookupParameter<IOperator>)Parameters["Improver"]; }
     86    }
     87    internal LookupParameter<IOperator> EvaluatorParameter {
     88      get { return (LookupParameter<IOperator>)Parameters["Evaluator"]; }
    8489    }
    8590    internal LookupParameter<IMultiAnalyzer> AnalyzerParameter {
     
    137142      set { ResultsParameter.ActualValue = value; }
    138143    }
    139     public IOperator MoveEvaluator {
     144    public ISingleObjectiveMoveEvaluator MoveEvaluator {
    140145      get { return MoveEvaluatorParameter.ActualValue; }
    141146      set { MoveEvaluatorParameter.ActualValue = value; }
    142147    }
    143     public IOperator MoveGenerator {
     148    public IMoveGenerator MoveGenerator {
    144149      get { return MoveGeneratorParameter.ActualValue; }
    145150      set { MoveGeneratorParameter.ActualValue = value; }
    146151    }
    147     public IOperator MoveMaker {
     152    public IMoveMaker MoveMaker {
    148153      get { return MoveMakerParameter.ActualValue; }
    149154      set { MoveMakerParameter.ActualValue = value; }
     155    }
     156    public IOperator Improver {
     157      get { return ImproverParameter.ActualValue; }
     158      set { ImproverParameter.ActualValue = value; }
     159    }
     160    public IOperator Evaluator {
     161      get { return EvaluatorParameter.ActualValue; }
     162      set { EvaluatorParameter.ActualValue = value; }
    150163    }
    151164    public IMultiAnalyzer Analyzer {
     
    178191      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move."));
    179192      Parameters.Add(new LookupParameter<IOperator>("SolutionCreator", "The operator which is used to create new solutions."));
    180       Parameters.Add(new LookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
    181       Parameters.Add(new LookupParameter<IOperator>("Improver", "The operator which is used to improve new solutions. This operator is executed in parallelm, if an engine is used which supports parallelization."));
     193      Parameters.Add(new LookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions."));
    182194      Parameters.Add(new LookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
    183       Parameters.Add(new LookupParameter<IOperator>("MoveGenerator", "The operator that generates the moves."));
    184       Parameters.Add(new LookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality."));
    185       Parameters.Add(new LookupParameter<IOperator>("MoveEvaluator", "The operator that evaluates a move."));
     195      Parameters.Add(new LookupParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
     196      Parameters.Add(new LookupParameter<IMoveGenerator>("MoveGenerator", "The operator that generates the moves."));
     197      Parameters.Add(new LookupParameter<IMoveMaker>("MoveMaker", "The operator that performs a move and updates the quality."));
     198      Parameters.Add(new LookupParameter<IOperator>("Improver", "The operator used to improve solutions."));
    186199      Parameters.Add(new LookupParameter<IMultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves."));
    187200      #endregion
     
    195208      ConditionalBranch terminateBranch = new ConditionalBranch();
    196209      IntCounter interationsCounter = new IntCounter();
    197       LocalSearchImprovementOperator localImprovementOperator = new LocalSearchImprovementOperator();
    198210      Placeholder analyzer = new Placeholder();
    199       Placeholder solutionImprover = new Placeholder();
    200       Placeholder solutionEvaluator = new Placeholder();
     211      Placeholder solutionEvaluator1 = new Placeholder();
     212      Placeholder solutionEvaluator2 = new Placeholder();
     213      Placeholder solutionImprover1 = new Placeholder();
     214      Placeholder solutionImprover2 = new Placeholder();
    201215      PopulationRebuildMethod populationRebuildMethod = new PopulationRebuildMethod();
    202216      ResultsCollector resultsCollector = new ResultsCollector();
     
    236250      iterationsChecker.Successor = terminateBranch;
    237251
    238       localImprovementOperator.Name = "ImprovementMethod";
    239       localImprovementOperator.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
    240       localImprovementOperator.SampleSizeParameter.ActualName = SampleSizeParameter.Name;
    241       localImprovementOperator.Successor = null;
     252      solutionImprover2.Name = "SolutionImprover";
     253      solutionImprover2.OperatorParameter.ActualName = "Improver";
     254      solutionImprover2.Successor = solutionEvaluator2;
     255
     256      solutionEvaluator2.Name = "SolutionEvaluator";
     257      solutionEvaluator2.OperatorParameter.ActualName = "Evaluator";
     258      solutionEvaluator2.Successor = null;
    242259
    243260      newSolutionsBranch.Name = "NewSolutionChecker";
     
    261278      analyzer.OperatorParameter.ActualName = "Analyzer";
    262279
    263       solutionImprover.Name = "SolutionImprover";
    264       solutionImprover.OperatorParameter.ActualName = "LocalImprovementOperator";
    265       solutionImprover.Successor = solutionEvaluator;
    266 
    267       solutionEvaluator.Name = "SolutionEvaluator";
    268       solutionEvaluator.OperatorParameter.ActualName = "Evaluator";
    269       solutionEvaluator.Successor = null;
     280      solutionImprover1.Name = "SolutionImprover";
     281      solutionImprover1.OperatorParameter.ActualName = "Improver";
     282      solutionImprover1.Successor = solutionEvaluator1;
     283
     284      solutionEvaluator1.Name = "SolutionEvaluator";
     285      solutionEvaluator1.OperatorParameter.ActualName = "Evaluator";
     286      solutionEvaluator1.Successor = null;
    270287
    271288      populationRebuildMethod.Successor = subScopesProcessor3;
     
    308325
    309326      uniformSubScopesProcessor2.DepthParameter.Value = new IntValue(1);
    310       uniformSubScopesProcessor2.Operator = solutionImprover;
     327      uniformSubScopesProcessor2.Operator = solutionImprover1;
    311328      uniformSubScopesProcessor2.Successor = null;
    312329
    313330      uniformSubScopesProcessor3.DepthParameter.Value = new IntValue(1);
    314       uniformSubScopesProcessor3.Operator = localImprovementOperator;
     331      uniformSubScopesProcessor3.Operator = solutionImprover2;
    315332      uniformSubScopesProcessor3.Successor = null;
    316333      #endregion
Note: See TracChangeset for help on using the changeset viewer.