Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/05/10 02:07:54 (15 years ago)
Author:
abeham
Message:

Ported ES to use analyzers #999

Location:
trunk/sources/HeuristicLab.Algorithms.EvolutionStrategy/3.3
Files:
2 edited

Legend:

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

    r3376 r3620  
    7777      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
    7878    }
    79     public ValueLookupParameter<IOperator> VisualizerParameter {
    80       get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
    81     }
    82     public LookupParameter<IItem> VisualizationParameter {
    83       get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
     79    public ValueLookupParameter<IOperator> AnalyzerParameter {
     80      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
    8481    }
    8582    private ScopeParameter CurrentScopeParameter {
     
    120117      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions."));
    121118      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
    122       Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
    123       Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
     119      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
    124120      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the EvolutionStrategy should be applied."));
    125121      Parameters.Add(new ValueLookupParameter<IOperator>("StrategyParameterManipulator", "The operator to mutate the endogeneous strategy parameters."));
     
    129125      #region Create operators
    130126      VariableCreator variableCreator = new VariableCreator();
    131       BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
    132       BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
    133       BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
    134       DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
    135       QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
    136       Placeholder visualizer1 = new Placeholder();
    137       ResultsCollector resultsCollector = new ResultsCollector();
     127      ResultsCollector resultsCollector1 = new ResultsCollector();
     128      Placeholder analyzer1 = new Placeholder();
    138129      WithoutRepeatingBatchedRandomSelector selector = new WithoutRepeatingBatchedRandomSelector();
    139130      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
     
    159150      IntCounter intCounter = new IntCounter();
    160151      Comparator comparator = new Comparator();
    161       BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
    162       BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
    163       BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
    164       DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
    165       QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
    166       Placeholder visualizer2 = new Placeholder();
     152      ResultsCollector resultsCollector2 = new ResultsCollector();
     153      Placeholder analyzer2 = new Placeholder();
    167154      ConditionalBranch conditionalBranch = new ConditionalBranch();
    168155
    169156      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
    170157
    171       bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
    172       bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    173       bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
    174 
    175       bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
    176       bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    177       bestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;
    178 
    179       bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
    180       bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
    181       bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    182       bestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
    183       bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
    184 
    185       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    186       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    187       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    188       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    189       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    190       dataTableValuesCollector1.DataTableParameter.ActualName = "Qualities";
    191 
    192       qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    193       qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    194       qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    195       qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
    196 
    197       visualizer1.Name = "Visualizer (placeholder)";
    198       visualizer1.OperatorParameter.ActualName = VisualizerParameter.Name;
    199 
    200       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    201       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    202       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    203       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    204       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    205       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    206       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
    207       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
    208       resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));
    209       resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
    210       resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
     158      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     159      resultsCollector1.ResultsParameter.ActualName = "Results";
     160
     161      analyzer1.Name = "Analyzer (placeholder)";
     162      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
    211163
    212164      selector.Name = "ES Random Selector";
     
    267219      comparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
    268220
    269       bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
    270       bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
    271       bestQualityMemorizer3.QualityParameter.ActualName = QualityParameter.Name;
    272 
    273       bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
    274       bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
    275       bestQualityMemorizer4.QualityParameter.ActualName = QualityParameter.Name;
    276 
    277       bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality";
    278       bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality";
    279       bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    280       bestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name;
    281       bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality";
    282 
    283       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    284       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    285       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    286       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    287       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    288       dataTableValuesCollector2.DataTableParameter.ActualName = "Qualities";
    289 
    290       qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    291       qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    292       qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    293       qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
    294 
    295       visualizer2.Name = "Visualizer (placeholder)";
    296       visualizer2.OperatorParameter.ActualName = VisualizerParameter.Name;
     221      resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     222      resultsCollector2.ResultsParameter.ActualName = "Results";
     223
     224      analyzer2.Name = "Analyzer (placeholder)";
     225      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
    297226
    298227      conditionalBranch.ConditionParameter.ActualName = "Terminate";
     
    301230      #region Create operator graph
    302231      OperatorGraph.InitialOperator = variableCreator;
    303       variableCreator.Successor = bestQualityMemorizer1;
    304       bestQualityMemorizer1.Successor = bestQualityMemorizer2;
    305       bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
    306       bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
    307       dataTableValuesCollector1.Successor = qualityDifferenceCalculator1;
    308       qualityDifferenceCalculator1.Successor = visualizer1;
    309       visualizer1.Successor = resultsCollector;
    310       resultsCollector.Successor = selector;
     232      variableCreator.Successor = resultsCollector1;
     233      resultsCollector1.Successor = analyzer1;
     234      analyzer1.Successor = selector;
    311235      selector.Successor = subScopesProcessor1;
    312236      subScopesProcessor1.Operators.Add(new EmptyOperator());
     
    336260      rightReducer.Successor = intCounter;
    337261      intCounter.Successor = comparator;
    338       comparator.Successor = bestQualityMemorizer3;
    339       bestQualityMemorizer3.Successor = bestQualityMemorizer4;
    340       bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
    341       bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2;
    342       dataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
    343       qualityDifferenceCalculator2.Successor = visualizer2;
    344       visualizer2.Successor = conditionalBranch;
     262      comparator.Successor = resultsCollector2;
     263      resultsCollector2.Successor = analyzer2;
     264      analyzer2.Successor = conditionalBranch;
    345265      conditionalBranch.FalseBranch = selector;
    346266      conditionalBranch.TrueBranch = null;
Note: See TracChangeset for help on using the changeset viewer.