Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/11 15:18:20 (13 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
Location:
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3
Files:
2 edited

Legend:

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

    r5143 r5356  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Operators;
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Optimization.Operators;
     
    139140    }
    140141    private RankAndCrowdingSorter RankAndCrowdingSorter {
    141       get { return (RankAndCrowdingSorter)SolutionsCreator.Successor; }
     142      get { return (RankAndCrowdingSorter)((SubScopesCounter)SolutionsCreator.Successor).Successor; }
    142143    }
    143144    private NSGA2MainLoop MainLoop {
    144       get { return (NSGA2MainLoop)RankAndCrowdingSorter.Successor; }
     145      get {
     146        return (NSGA2MainLoop)(
     147          (ResultsCollector)RankAndCrowdingSorter.Successor
     148        ).Successor;
     149      }
    145150    }
    146151    #endregion
     
    151156    [StorableConstructor]
    152157    protected NSGA2(bool deserializing) : base(deserializing) { }
    153     protected NSGA2(NSGA2 original, Cloner cloner) : base (original, cloner) {
     158    protected NSGA2(NSGA2 original, Cloner cloner)
     159      : base(original, cloner) {
    154160      paretoFrontAnalyzer = (RankBasedParetoFrontAnalyzer)cloner.Clone(original.paretoFrontAnalyzer);
    155161      AttachEventHandlers();
     
    170176      RandomCreator randomCreator = new RandomCreator();
    171177      SolutionsCreator solutionsCreator = new SolutionsCreator();
     178      SubScopesCounter subScopesCounter = new SubScopesCounter();
    172179      RankAndCrowdingSorter rankAndCrowdingSorter = new RankAndCrowdingSorter();
     180      ResultsCollector resultsCollector = new ResultsCollector();
    173181      NSGA2MainLoop mainLoop = new NSGA2MainLoop();
    174      
     182
    175183      OperatorGraph.InitialOperator = randomCreator;
    176184
     
    183191
    184192      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
    185       solutionsCreator.Successor = rankAndCrowdingSorter;
     193      solutionsCreator.Successor = subScopesCounter;
     194
     195      subScopesCounter.Name = "Initialize EvaluatedSolutions";
     196      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
     197      subScopesCounter.Successor = rankAndCrowdingSorter;
    186198
    187199      rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName = "CrowdingDistance";
    188200      rankAndCrowdingSorter.RankParameter.ActualName = "Rank";
    189       rankAndCrowdingSorter.Successor = mainLoop;
     201      rankAndCrowdingSorter.Successor = resultsCollector;
     202
     203      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
     204      resultsCollector.ResultsParameter.ActualName = "Results";
     205      resultsCollector.Successor = mainLoop;
    190206
    191207      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
     
    199215      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
    200216      mainLoop.ResultsParameter.ActualName = "Results";
     217      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
    201218
    202219      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is ISingleObjectiveSelector)).OrderBy(x => x.Name))
     
    218235
    219236    public override IDeepCloneable Clone(Cloner cloner) {
    220       return new NSGA2(this, cloner);     
     237      return new NSGA2(this, cloner);
    221238    }
    222239
  • trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2MainLoop.cs

    r5208 r5356  
    7575    public ValueLookupParameter<IOperator> AnalyzerParameter {
    7676      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
     77    }
     78    public LookupParameter<IntValue> EvaluatedSolutionsParameter {
     79      get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
    7780    }
    7881    #endregion
     
    101104      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
    102105      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
     106      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
    103107      #endregion
    104108
     
    119123      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
    120124      Placeholder evaluator = new Placeholder();
     125      SubScopesCounter subScopesCounter = new SubScopesCounter();
    121126      MergingReducer mergingReducer = new MergingReducer();
    122127      RankAndCrowdingSorter rankAndCrowdingSorter = new RankAndCrowdingSorter();
     
    125130      IntCounter intCounter = new IntCounter();
    126131      Comparator comparator = new Comparator();
    127       ResultsCollector resultsCollector2 = new ResultsCollector();
    128132      Placeholder analyzer2 = new Placeholder();
    129133      ConditionalBranch conditionalBranch = new ConditionalBranch();
     
    163167      evaluator.Name = "Evaluator";
    164168      evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name;
     169
     170      subScopesCounter.Name = "Increment EvaluatedSolutions";
     171      subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
    165172
    166173      rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName = "CrowdingDistance";
     
    177184      comparator.ResultParameter.ActualName = "Terminate";
    178185      comparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
    179 
    180       resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    181       resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
    182186
    183187      analyzer2.Name = "Analyzer";
     
    210214      subScopesRemover.Successor = null;
    211215      uniformSubScopesProcessor2.Operator = evaluator;
    212       uniformSubScopesProcessor2.Successor = null;
     216      uniformSubScopesProcessor2.Successor = subScopesCounter;
    213217      evaluator.Successor = null;
     218      subScopesCounter.Successor = null;
    214219      mergingReducer.Successor = rankAndCrowdingSorter;
    215220      rankAndCrowdingSorter.Successor = leftSelector;
     
    217222      rightReducer.Successor = intCounter;
    218223      intCounter.Successor = comparator;
    219       comparator.Successor = resultsCollector2;
    220       resultsCollector2.Successor = analyzer2;
     224      comparator.Successor = analyzer2;
    221225      analyzer2.Successor = conditionalBranch;
    222226      conditionalBranch.FalseBranch = selector;
Note: See TracChangeset for help on using the changeset viewer.