Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8711


Ignore:
Timestamp:
10/01/12 22:53:20 (12 years ago)
Author:
ascheibe
Message:

#1886 added a combined operator for mutation

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/AfterCrossoverCombinedOperator.cs

    r8709 r8711  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Operators;
    2524using HeuristicLab.Optimization;
    2625using HeuristicLab.Optimization.Operators;
     
    3130  [Item("AfterCrossoverCombinedOperator", "An operator that contains all operators that need to be executed after crossover.")]
    3231  [StorableClass]
    33   public class AfterCrossoverCombinedOperator : MultiOperator<IOperator> {
    34 
    35     private CrossoverPerformanceAnalyzer cxAnalyzer;
    36 
    37     private ScopeParameter CurrentScopeParameter {
    38       get { return (ScopeParameter)Parameters["CurrentScope"]; }
    39     }
    40     public IScope CurrentScope {
    41       get { return CurrentScopeParameter.ActualValue; }
    42     }
     32  public class AfterCrossoverCombinedOperator : CombinedOperator {
    4333    public ILookupParameter<IEvaluator> EvaluatorParameter {
    4434      get { return ((LookupParameter<IEvaluator>)Parameters["Evaluator"]); }
     
    4939
    5040    [StorableConstructor]
    51     private AfterCrossoverCombinedOperator(bool deserializing) : base(deserializing) { }
    52     private AfterCrossoverCombinedOperator(AfterCrossoverCombinedOperator original, Cloner cloner)
     41    protected AfterCrossoverCombinedOperator(bool deserializing) : base(deserializing) { }
     42    protected AfterCrossoverCombinedOperator(AfterCrossoverCombinedOperator original, Cloner cloner)
    5343      : base(original, cloner) {
    5444    }
     
    5646    public AfterCrossoverCombinedOperator()
    5747      : base() {
    58       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose variables and sub-scopes should be removed."));
    5948      Parameters.Add(new LookupParameter<IEvaluator>("Evaluator", "The operator which is used to evaluate new solutions."));
    6049      Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator"));
    6150
    6251      SimilarityCalculatorParameter.ValueChanged += new System.EventHandler(SimilarityCalculatorParameter_ValueChanged);
    63 
    64       cxAnalyzer = new CrossoverPerformanceAnalyzer();
    65       var varDuplicator = new VariableDuplicator();
    66 
    67       Operators.Add(cxAnalyzer);
    68       Operators.Add(varDuplicator);
    6952    }
    7053
     
    7255      SimilarityCalculatorParameter.Value.QualityVariableName = "TSPTourLength";
    7356      SimilarityCalculatorParameter.Value.SolutionVariableName = "TSPTour";
    74       cxAnalyzer.SimilarityCalculatorParameter.Value = SimilarityCalculatorParameter.Value;
    7557    }
    7658
     
    7961    }
    8062
    81     public override IOperation Apply() {
    82       if (!Operators.Contains(EvaluatorParameter.ActualValue)) {
    83         Operators.Insert(0, EvaluatorParameter.ActualValue);
    84       }
     63    public override void InitializeOperators() {
     64      var cxAnalyzer = new CrossoverPerformanceAnalyzer();
     65      cxAnalyzer.SimilarityCalculatorParameter.Value = SimilarityCalculatorParameter.Value;
     66      var varDuplicator = new VariableDuplicator();
    8567
    86       OperationCollection next = new OperationCollection(base.Apply());
    87       OperationCollection inner = new OperationCollection();
    88       inner.Parallel = false;
    89 
    90       for (int i = 0; i < Operators.Count; i++) {
    91         inner.Add(ExecutionContext.CreateOperation(Operators[i], CurrentScope));
    92       }
    93       next.Insert(0, inner);
    94       return next;
     68      Operators.Add(EvaluatorParameter.ActualValue);
     69      Operators.Add(cxAnalyzer);
     70      Operators.Add(varDuplicator);
    9571    }
    9672  }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj

    r8709 r8711  
    116116  </ItemGroup>
    117117  <ItemGroup>
     118    <Compile Include="CombinedOperator.cs" />
     119    <Compile Include="AlgorithmBehaviorHelpers.cs" />
    118120    <Compile Include="AfterCrossoverCombinedOperator.cs" />
    119     <Compile Include="AlgorithmBehaviorHelpers.cs" />
     121    <Compile Include="AfterMutationCombinedOperator.cs" />
    120122    <Compile Include="PathRelinkerPerformanceAnalyzer.cs" />
    121123    <Compile Include="VariableRemover.cs" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/VariableRemover.cs

    r8661 r8711  
    5252      Parameters.Add(new ValueParameter<StringValue>("VariableName", "The name of the variable to remove from the current scope."));
    5353      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose variables and sub-scopes should be removed."));
     54      VariableNameParameter.Value.Value = "TSPTourClone";
    5455    }
    5556
Note: See TracChangeset for help on using the changeset viewer.