Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/12 16:00:07 (13 years ago)
Author:
abeham
Message:

#1614: simplified GRASP+PR operator graph, replaced IMerger with an IPopulationReducer

Location:
branches/GeneralizedQAP
Files:
2 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/GRASPWithPathRelinking.cs

    r7438 r7478  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Optimization;
     29using HeuristicLab.Optimization.Operators;
    2930using HeuristicLab.Parameters;
    3031using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    7980      get { return (ConstrainedValueParameter<ICrossover>)Parameters["PathRelinking"]; }
    8081    }
    81     public ConstrainedValueParameter<IMerger> EliteSetMergerParameter {
    82       get { return (ConstrainedValueParameter<IMerger>)Parameters["EliteSetMerger"]; }
     82    public ConstrainedValueParameter<IPopulationReducer> EliteSetReducerParameter {
     83      get { return (ConstrainedValueParameter<IPopulationReducer>)Parameters["EliteSetReducer"]; }
    8384    }
    8485    #endregion
     
    109110      get { return (RandomCreator)OperatorGraph.InitialOperator; }
    110111    }
     112    private SolutionsCreator SolutionsCreator {
     113      get { return (SolutionsCreator)RandomCreator.Successor; }
     114    }
    111115    private GRASPWithPathRelinkingMainLoop MainLoop {
    112       get { return RandomCreator.Successor as GRASPWithPathRelinkingMainLoop; }
     116      get { return SolutionsCreator.Successor as GRASPWithPathRelinkingMainLoop; }
    113117    }
    114118    #endregion
     
    135139      Parameters.Add(new FixedValueParameter<IntValue>("MinimumEliteSetSize", "(ρ) The minimum amount of elites for performing path relinking.", new IntValue(2)));
    136140      Parameters.Add(new ConstrainedValueParameter<ICrossover>("PathRelinking", "The operator that performs the path relinking."));
    137       Parameters.Add(new ConstrainedValueParameter<IMerger>("EliteSetMerger", "The operator that merges new solutions into the elite set."));
     141      Parameters.Add(new ConstrainedValueParameter<IPopulationReducer>("EliteSetReducer", "The operator that reduces the old elite set and the new solution(s) to a new elite set."));
    138142
    139143      analyzer = new BestAverageWorstQualityAnalyzer();
    140144      Analyzer.Operators.Add(analyzer);
    141145
    142       RandomCreator randomCreator = new RandomCreator();
     146      var randomCreator = new RandomCreator();
    143147      OperatorGraph.InitialOperator = randomCreator;
    144148
     
    149153      randomCreator.SetSeedRandomlyParameter.Value = null;
    150154
     155      var solutionsCreator = new SolutionsCreator();
     156      solutionsCreator.NumberOfSolutionsParameter.ActualName = MinimumEliteSetSizeParameter.Name;
     157      solutionsCreator.ParallelParameter.Value = new BoolValue(true);
     158      randomCreator.Successor = solutionsCreator;
     159
    151160      var mainLoop = new GRASPWithPathRelinkingMainLoop();
    152161      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
    153       mainLoop.EliteSetMergerParameter.ActualName = EliteSetMergerParameter.Name;
     162      mainLoop.EliteSetReducerParameter.ActualName = EliteSetReducerParameter.Name;
    154163      mainLoop.EliteSetSizeParameter.ActualName = EliteSetSizeParameter.Name;
    155164      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
     
    158167      mainLoop.PathRelinkingParameter.ActualName = PathRelinkingParameter.Name;
    159168      mainLoop.ResultsParameter.ActualName = "Results";
    160       randomCreator.Successor = mainLoop;
     169      solutionsCreator.Successor = mainLoop;
    161170
    162171      InitializeOperators();
     
    219228        InitializeFromInstallation(LocalImprovementParameter, x => x.ProblemType.IsAssignableFrom(Problem.GetType()));
    220229        InitializeFromProblem(PathRelinkingParameter);
    221         InitializeFromProblem(EliteSetMergerParameter);
     230        InitializeFromProblem(EliteSetReducerParameter);
    222231      } else {
    223232        LocalImprovementParameter.ValidValues.Clear();
    224233        PathRelinkingParameter.ValidValues.Clear();
    225         EliteSetMergerParameter.ValidValues.Clear();
     234        EliteSetReducerParameter.ValidValues.Clear();
    226235      }
    227236      Analyzer.Operators.Add(analyzer);
     
    232241    private void Parameterize() {
    233242      if (Problem != null) {
     243        SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     244        SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     245
    234246        MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    235247        MainLoop.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     
    245257        localImprovement.ResultsParameter.ActualName = "Results";
    246258      }
    247       foreach (var merger in EliteSetMergerParameter.ValidValues) {
    248         merger.PopulationSizeParameter.ActualName = EliteSetSizeParameter.Name;
     259      foreach (var reducer in EliteSetReducerParameter.ValidValues) {
     260        reducer.MinimumPopulationSizeParameter.ActualName = MinimumEliteSetSizeParameter.Name;
     261        reducer.MaximumPopulationSizeParameter.ActualName = EliteSetSizeParameter.Name;
    249262      }
    250263    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/GRASPWithPathRelinkingMainLoop.cs

    r7412 r7478  
    6161      get { return (IValueLookupParameter<IOperator>)Parameters["PathRelinking"]; }
    6262    }
    63     public IValueLookupParameter<IOperator> EliteSetMergerParameter {
    64       get { return (IValueLookupParameter<IOperator>)Parameters["EliteSetMerger"]; }
     63    public IValueLookupParameter<IOperator> EliteSetReducerParameter {
     64      get { return (IValueLookupParameter<IOperator>)Parameters["EliteSetReducer"]; }
    6565    }
    6666    public IValueLookupParameter<IOperator> AnalyzerParameter {
     
    8282      Parameters.Add(new ValueLookupParameter<IOperator>("LocalImprovement", "The operator which performs the local improvement."));
    8383      Parameters.Add(new ValueLookupParameter<IOperator>("PathRelinking", "The operator which performs the path relinking."));
    84       Parameters.Add(new ValueLookupParameter<IOperator>("EliteSetMerger", "The operator that merges elements in the elite set."));
     84      Parameters.Add(new ValueLookupParameter<IOperator>("EliteSetReducer", "The operator that reduces the existing elite set and the new solution to a new elite set."));
    8585      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The analyzer that is to be applied."));
    8686
     
    9393      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
    9494
    95       var variableCreator2 = new VariableCreator();
    96       variableCreator2.Name = "ActualEliteSetSize = 0";
    97       variableCreator2.CollectedValues.Add(new ValueParameter<IntValue>("ActualEliteSetSize", new IntValue(0)));
    98 
    99       var subScopesCounter1 = new SubScopesCounter();
    100       subScopesCounter1.Name = "ActualEliteSetSize += |SubScopes|";
    101       subScopesCounter1.ValueParameter.ActualName = "ActualEliteSetSize";
    102 
    103       var comparator1 = new Comparator();
    104       comparator1.Name = "ActualEliteSetSize >= MinimumEliteSetSize";
    105       comparator1.Comparison.Value = ComparisonType.GreaterOrEqual;
    106       comparator1.LeftSideParameter.ActualName = "ActualEliteSetSize";
    107       comparator1.RightSideParameter.ActualName = EliteSetSizeParameter.ActualName;
    108       comparator1.ResultParameter.ActualName = "SizeOkay";
    109 
    110       var conditionalBranch1 = new ConditionalBranch();
    111       conditionalBranch1.Name = "Elite set has at least ρ elements";
    112       conditionalBranch1.ConditionParameter.ActualName = "SizeOkay";
    113 
    11495      var selector1 = new RandomSelector();
    11596      selector1.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
    11697      selector1.CopySelected.Value = true;
    117 
    118       var selector2 = new RandomSelector();
    119       selector2.NumberOfSelectedSubScopesParameter.Value = new IntValue(0);
    12098
    12199      var ssp1 = new SubScopesProcessor();
     
    129107      solutionsCreator.NumberOfSolutions = new IntValue(1);
    130108
    131       var subScopesCounter2 = new SubScopesCounter();
    132       subScopesCounter2.Name = "Count subscopes";
    133       subScopesCounter2.ValueParameter.ActualName = "SolutionScopes";
    134 
    135       var comparator2 = new Comparator();
    136       comparator2.Name = "SolutionScopes == 2";
    137       comparator2.Comparison.Value = ComparisonType.Equal;
    138       comparator2.LeftSideParameter.ActualName = "SolutionScopes";
    139       comparator2.RightSideParameter.Value = new IntValue(2);
    140       comparator2.ResultParameter.ActualName = "PerformPR";
    141 
    142       var conditionalBranch2 = new ConditionalBranch();
    143       conditionalBranch2.Name = "Path relinking?";
    144       conditionalBranch2.ConditionParameter.ActualName = "PerformPR";
    145 
    146109      var ssp2 = new SubScopesProcessor();
    147110
     
    175138
    176139      var placeholder5 = new Placeholder();
    177       placeholder5.Name = "(EliteSetMerger)";
    178       placeholder5.OperatorParameter.ActualName = EliteSetMergerParameter.Name;
     140      placeholder5.Name = "(EliteSetReplacer)";
     141      placeholder5.OperatorParameter.ActualName = EliteSetReducerParameter.Name;
    179142
    180143      var counter = new IntCounter();
     
    200163      OperatorGraph.InitialOperator = variableCreator1;
    201164      variableCreator1.Successor = resultsCollector;
    202       resultsCollector.Successor = variableCreator2;
    203       variableCreator2.Successor = subScopesCounter1;
    204       subScopesCounter1.Successor = comparator1;
    205       comparator1.Successor = conditionalBranch1;
    206       conditionalBranch1.TrueBranch = selector1;
    207       conditionalBranch1.FalseBranch = selector2;
    208       conditionalBranch1.Successor = ssp1;
     165      resultsCollector.Successor = selector1;
     166      selector1.Successor = ssp1;
    209167      ssp1.Operators.Add(eo1);
    210168      ssp1.Operators.Add(solutionsCreator);
    211169      ssp1.Successor = placeholder5;
    212170      eo1.Successor = null;
    213       solutionsCreator.Successor = subScopesCounter2;
    214       subScopesCounter2.Successor = comparator2;
    215       comparator2.Successor = conditionalBranch2;
    216       conditionalBranch2.TrueBranch = ssp2;
    217       conditionalBranch2.FalseBranch = null;
    218       conditionalBranch2.Successor = ssp4;
     171      solutionsCreator.Successor = ssp2;
    219172      ssp2.Operators.Add(eo2);
    220173      ssp2.Operators.Add(placeholder1);
     
    227180      placeholder2.Successor = placeholder3;
    228181      placeholder3.Successor = subScopesRemover;
    229       subScopesRemover.Successor = null;
    230       ssp4.Operators.Add(placeholder4);
    231       ssp4.Successor = null;
     182      subScopesRemover.Successor = placeholder4;
     183      placeholder4.Successor = null;
    232184      placeholder5.Successor = counter;
    233185      counter.Successor = analyzer1;
     
    235187      comparator3.Successor = conditionalBranch3;
    236188      conditionalBranch3.TrueBranch = null;
    237       conditionalBranch3.FalseBranch = variableCreator2;
     189      conditionalBranch3.FalseBranch = selector1;
    238190      conditionalBranch3.Successor = null;
    239191    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3.csproj

    r7413 r7478  
    8989    <None Include="Plugin.cs.frame" />
    9090    <Compile Include="ExtensionMethods.cs" />
    91     <Compile Include="IMerger.cs" />
    9291    <Compile Include="IntegerVectorEqualityComparer.cs" />
     92    <Compile Include="IPopulationReducer.cs" />
    9393    <Compile Include="Plugin.cs" />
    9494    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r7443 r7478  
    148148    <Compile Include="Operators\MultiGQAPManipulator.cs" />
    149149    <Compile Include="Operators\NMoveShakingOperator.cs" />
    150     <Compile Include="Operators\QualitySimilarityMerger.cs" />
     150    <Compile Include="Operators\GQAPQualitySimilarityReducer.cs" />
    151151    <Compile Include="Operators\RandomSolutionCreator.cs" />
    152152    <Compile Include="Operators\RelocateEquipmentManipluator.cs" />
Note: See TracChangeset for help on using the changeset viewer.