Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/11 15:18:20 (14 years ago)
Author:
abeham
Message:

#1344

  • Adapted all algorithms to count evaluated solutions / moves and outside of the parallel region
  • Used the same pattern in every algorithm: Initialize and collect the variable in the Algorithm and increment it in the main loops and main operators
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs

    r5208 r5356  
    8989    public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
    9090      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
     91    }
     92    public LookupParameter<IntValue> EvaluatedSolutionsParameter {
     93      get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
    9194    }
    9295    #endregion
     
    126129      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
    127130      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation."));
     131      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
    128132      #endregion
    129133
     
    133137      Placeholder analyzer1 = new Placeholder();
    134138      ResultsCollector resultsCollector1 = new ResultsCollector();
    135       ResultsCollector resultsCollector2 = new ResultsCollector();
    136139      OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
    137140      IntCounter generationsCounter = new IntCounter();
     
    141144      Placeholder comparisonFactorModifier = new Placeholder();
    142145      Placeholder analyzer2 = new Placeholder();
    143       ResultsCollector resultsCollector3 = new ResultsCollector();
    144146      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
    145147      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
     
    147149
    148150      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class OffspringSelectionGeneticAlgorithm expects this to be called Generations
    149       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
    150151      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
    151152      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
     
    165166      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
    166167
    167       resultsCollector2.CopyValue = new BoolValue(true);
    168       resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
    169       resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
    170 
    171168      mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
    172169      mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
    173170      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
    174171      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
    175       mainOperator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
     172      mainOperator.EvaluatedSolutionsParameter.ActualName = EvaluatedSolutionsParameter.Name;
    176173      mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
    177174      mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
     
    200197
    201198      maxEvaluatedSolutionsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
    202       maxEvaluatedSolutionsComparator.LeftSideParameter.ActualName = "EvaluatedSolutions";
     199      maxEvaluatedSolutionsComparator.LeftSideParameter.ActualName = EvaluatedSolutionsParameter.Name;
    203200      maxEvaluatedSolutionsComparator.ResultParameter.ActualName = "TerminateEvaluatedSolutions";
    204201      maxEvaluatedSolutionsComparator.RightSideParameter.ActualName = "MaximumEvaluatedSolutions";
     
    209206      analyzer2.Name = "Analyzer (placeholder)";
    210207      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
    211 
    212       resultsCollector3.CopyValue = new BoolValue(true);
    213       resultsCollector3.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
    214       resultsCollector3.ResultsParameter.ActualName = ResultsParameter.Name;
    215208
    216209      conditionalBranch1.Name = "MaximumSelectionPressure reached?";
     
    229222      comparisonFactorInitializer.Successor = analyzer1;
    230223      analyzer1.Successor = resultsCollector1;
    231       resultsCollector1.Successor = resultsCollector2;
    232       resultsCollector2.Successor = mainOperator;
     224      resultsCollector1.Successor = mainOperator;
    233225      mainOperator.Successor = generationsCounter;
    234226      generationsCounter.Successor = maxGenerationsComparator;
     
    237229      maxEvaluatedSolutionsComparator.Successor = comparisonFactorModifier;
    238230      comparisonFactorModifier.Successor = analyzer2;
    239       analyzer2.Successor = resultsCollector3;
    240       resultsCollector3.Successor = conditionalBranch1;
     231      analyzer2.Successor = conditionalBranch1;
    241232      conditionalBranch1.FalseBranch = conditionalBranch2;
    242233      conditionalBranch1.TrueBranch = null;
Note: See TracChangeset for help on using the changeset viewer.