Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3650


Ignore:
Timestamp:
05/05/10 18:54:00 (15 years ago)
Author:
abeham
Message:

#999

  • ported Island GA to Analyzers
  • ported OSGA to Analyzers
  • changed OSGA to use OSGA's main operator
Location:
trunk/sources
Files:
4 edited

Legend:

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

    r3616 r3650  
    3434using HeuristicLab.Random;
    3535using HeuristicLab.Selection;
     36using HeuristicLab.Analysis;
    3637
    3738namespace HeuristicLab.Algorithms.GeneticAlgorithm {
     
    103104      get { return (ValueParameter<BoolValue>)Parameters["Parallel"]; }
    104105    }
     106    private ValueParameter<MultiAnalyzer<IMultiPopulationAnalyzer>> AnalyzerParameter {
     107      get { return (ValueParameter<MultiAnalyzer<IMultiPopulationAnalyzer>>)Parameters["Analyzer"]; }
     108    }
     109    private ValueParameter<MultiAnalyzer<IPopulationAnalyzer>> IslandAnalyzerParameter {
     110      get { return (ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>)Parameters["IslandAnalyzer"]; }
     111    }
    105112    #endregion
    106113
     
    169176      get { return ParallelParameter.Value; }
    170177      set { ParallelParameter.Value = value; }
     178    }
     179    public MultiAnalyzer<IMultiPopulationAnalyzer> Analyzer {
     180      get { return AnalyzerParameter.Value; }
     181      set { AnalyzerParameter.Value = value; }
     182    }
     183    public MultiAnalyzer<IPopulationAnalyzer> IslandAnalyzer {
     184      get { return IslandAnalyzerParameter.Value; }
     185      set { IslandAnalyzerParameter.Value = value; }
    171186    }
    172187    private List<ISelector> selectors;
     
    189204      get { return (IslandGeneticAlgorithmMainLoop)IslandProcessor.Successor; }
    190205    }
     206    private PopulationBestAverageWorstQualityAnalyzer islandQualityAnalyzer;
     207    //private MultipopulationBestAverageWorstQualityAnalyzer qualityAnalyzer;
    191208    #endregion
    192209
     
    211228      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    212229      Parameters.Add(new ValueParameter<BoolValue>("Parallel", "True if the islands should be run in parallel (also requires a parallel engine)", new BoolValue(false)));
    213 
     230      Parameters.Add(new ValueParameter<MultiAnalyzer<IMultiPopulationAnalyzer>>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer<IMultiPopulationAnalyzer>()));
     231      Parameters.Add(new ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer<IPopulationAnalyzer>()));
     232     
    214233      RandomCreator randomCreator = new RandomCreator();
    215234      SubScopesCreator populationCreator = new SubScopesCreator();
     
    251270      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
    252271      mainLoop.ResultsParameter.ActualName = "Results";
     272      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     273      mainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name;
    253274
    254275      mainLoop.Successor = null;
     
    275296      ParameterizeMainLoop();
    276297      ParameterizeSelectors();
     298      ParameterizeAnalyzers();
    277299      UpdateCrossovers();
    278300      UpdateMutators();
     301      UpdateAnalyzers();
    279302      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    280303      base.OnProblemChanged();
     
    291314      ParameterizeMainLoop();
    292315      ParameterizeSelectors();
     316      ParameterizeAnalyzers();
    293317      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    294318      base.Problem_EvaluatorChanged(sender, e);
     
    298322      UpdateCrossovers();
    299323      UpdateMutators();
     324      UpdateAnalyzers();
    300325      base.Problem_OperatorsChanged(sender, e);
    301326    }
     
    317342      ParameterizeMainLoop();
    318343      ParameterizeSelectors();
     344      ParameterizeAnalyzers();
    319345    }
    320346    private void MigrationRateParameter_ValueChanged(object sender, EventArgs e) {
     
    331357    private void Initialize() {
    332358      InitializeSelectors();
     359      InitializeAnalyzers();
    333360      UpdateSelectors();
     361      UpdateAnalyzers();
    334362      InitializeMigrators();
    335363      UpdateMigrators();
     
    368396      immigrationReplacers.AddRange(ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name));
    369397      ParameterizeSelectors();
     398    }
     399    private void InitializeAnalyzers() {
     400      islandQualityAnalyzer = new PopulationBestAverageWorstQualityAnalyzer();
     401      //qualityAnalyzer = new MultipopulationBestAverageWorstQualityAnalyzer();
     402      ParameterizeAnalyzers();
    370403    }
    371404    private void InitializeMigrators() {
     
    403436      }
    404437    }
     438    private void ParameterizeAnalyzers() {
     439      islandQualityAnalyzer.ResultsParameter.ActualName = "Results";
     440      //qualityAnalyzer.ResultsParameter.ActualName = "Results";
     441      if (Problem != null) {
     442        islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     443        islandQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
     444        islandQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
     445      }
     446    }
    405447    private void UpdateSelectors() {
    406448      ISelector oldSelector = SelectorParameter.Value;
     
    465507      }
    466508    }
     509    private void UpdateAnalyzers() {
     510      IslandAnalyzer.Operators.Clear();
     511      Analyzer.Operators.Clear();
     512      IslandAnalyzer.Operators.Add(islandQualityAnalyzer);
     513      //Analyzer.Operators.Add(qualityAnalyzer);
     514      if (Problem != null) {
     515        foreach (IPopulationAnalyzer analyzer in Problem.Operators.OfType<IPopulationAnalyzer>().OrderBy(x => x.Name)) {
     516          IslandAnalyzer.Operators.Add(analyzer);
     517        }
     518        foreach (IMultiPopulationAnalyzer analyzer in Problem.Operators.OfType<IMultiPopulationAnalyzer>().OrderBy(x => x.Name))
     519          Analyzer.Operators.Add(analyzer);
     520      }
     521    }
    467522    #endregion
    468523  }
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithmMainLoop.cs

    r3616 r3650  
    102102    public ValueLookupParameter<IOperator> AnalyzerParameter {
    103103      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
     104    }
     105    public ValueLookupParameter<IOperator> IslandAnalyzerParameter {
     106      get { return (ValueLookupParameter<IOperator>)Parameters["IslandAnalyzer"]; }
    104107    }
    105108    #endregion
     
    129132      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
    130133      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
    131       Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each island."));
     134      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands."));
     135      Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
    132136      #endregion
    133137
     
    136140      UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
    137141      VariableCreator islandVariableCreator = new VariableCreator();
    138       BestQualityMemorizer islandBestQualityMemorizer1 = new BestQualityMemorizer();
    139       BestAverageWorstQualityCalculator islandBestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
    140       DataTableValuesCollector islandDataTableValuesCollector1 = new DataTableValuesCollector();
    141       QualityDifferenceCalculator islandQualityDifferenceCalculator1 = new QualityDifferenceCalculator();
    142142      Placeholder islandAnalyzer1 = new Placeholder();
    143       ResultsCollector islandResultsCollector = new ResultsCollector();
    144       BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
    145       BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
    146       BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
    147       DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
    148       QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
    149       ResultsCollector resultsCollector = new ResultsCollector();
     143      Placeholder analyzer1 = new Placeholder();
     144      ResultsCollector resultsCollector1 = new ResultsCollector();
     145      ResultsCollector resultsCollector2 = new ResultsCollector();
    150146      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
    151147      Placeholder selector = new Placeholder();
     
    162158      RightReducer rightReducer = new RightReducer();
    163159      MergingReducer mergingReducer = new MergingReducer();
    164       BestQualityMemorizer islandBestQualityMemorizer2 = new BestQualityMemorizer();
    165       BestAverageWorstQualityCalculator islandBestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
    166       DataTableValuesCollector islandDataTableValuesCollector2 = new DataTableValuesCollector();
    167       QualityDifferenceCalculator islandQualityDifferenceCalculator2 = new QualityDifferenceCalculator();
    168160      Placeholder islandAnalyzer2 = new Placeholder();
    169161      IntCounter generationsCounter = new IntCounter();
     
    179171      Placeholder immigrationReplacer = new Placeholder();
    180172      Comparator generationsComparator = new Comparator();
    181       BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
    182       BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
    183       BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
    184       DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
    185       QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
     173      Placeholder analyzer2 = new Placeholder();
     174      ResultsCollector resultsCollector3 = new ResultsCollector();
    186175      ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
    187176
     
    190179      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
    191180
    192       islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("IslandResults", new ResultCollection()));
    193 
    194       islandBestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
    195       islandBestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    196       islandBestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
    197 
    198       islandBestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
    199       islandBestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
    200       islandBestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    201       islandBestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
    202       islandBestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
    203 
    204       islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    205       islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    206       islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    207       islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    208       islandDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, "BestKnownQuality"));
    209       islandDataTableValuesCollector1.DataTableParameter.ActualName = "Qualities";
    210 
    211       islandQualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    212       islandQualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    213       islandQualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    214       islandQualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
    215 
    216       islandAnalyzer1.Name = "Analyzer";
    217       islandAnalyzer1.OperatorParameter.ActualName = "Analyzer";
    218 
    219       islandResultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    220       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    221       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    222       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    223       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    224       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, "BestKnownQuality"));
    225       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
    226       islandResultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
    227       islandResultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
    228       islandResultsCollector.ResultsParameter.ActualName = "IslandResults";
    229 
    230       bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
    231       bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    232       bestQualityMemorizer1.QualityParameter.ActualName = "BestQuality";
    233 
    234       bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
    235       bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    236       bestQualityMemorizer2.QualityParameter.ActualName = "BestQuality";
    237 
    238       bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
    239       bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestBestQuality";
    240       bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    241       bestAverageWorstQualityCalculator1.QualityParameter.ActualName = "CurrentBestQuality";
    242       bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
    243 
    244       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
    245       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
    246       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
    247       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    248       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    249       dataTableValuesCollector1.DataTableParameter.ActualName = "BestQualities";
    250 
    251       qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    252       qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    253       qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    254       qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
    255 
    256       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
    257       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
    258       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
    259       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
    260       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    261       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    262       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
    263       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
    264       resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("BestQualities"));
    265       resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("IslandResults", "Result set for each island"));
    266       resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
     181      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
     182
     183      islandAnalyzer1.Name = "Island Analyzer (placeholder)";
     184      islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
     185
     186      analyzer1.Name = "Analyzer (placeholder)";
     187      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
     188
     189      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
     190      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     191      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
     192
     193      resultsCollector2.Name = "Reference Island Results";
     194      resultsCollector2.CopyValue = new BoolValue(false);
     195      resultsCollector2.CollectedValues.Add(new SubScopesLookupParameter<ResultCollection>("IslandResults", "Result set for each island", "Results"));
     196      resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
    267197
    268198      selector.Name = "Selector (placeholder)";
     
    290220      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
    291221
    292       islandBestQualityMemorizer2.BestQualityParameter.ActualName = "BestQuality";
    293       islandBestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    294       islandBestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;
    295 
    296       islandBestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality";
    297       islandBestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality";
    298       islandBestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    299       islandBestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name;
    300       islandBestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality";
    301 
    302       islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    303       islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    304       islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    305       islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    306       islandDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    307       islandDataTableValuesCollector2.DataTableParameter.ActualName = "Qualities";
    308 
    309       islandQualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    310       islandQualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    311       islandQualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    312       islandQualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
    313 
    314       islandAnalyzer2.Name = "Analyzer";
    315       islandAnalyzer2.OperatorParameter.ActualName = "Analyzer";
     222      islandAnalyzer2.Name = "Island Analyzer (placeholder)";
     223      islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
    316224
    317225      generationsCounter.Name = "Generations + 1";
     
    355263      generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
    356264
    357       bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
    358       bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
    359       bestQualityMemorizer3.QualityParameter.ActualName = "BestQuality";
    360 
    361       bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
    362       bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
    363       bestQualityMemorizer4.QualityParameter.ActualName = "BestQuality";
    364 
    365       bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageBestQuality";
    366       bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestBestQuality";
    367       bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    368       bestAverageWorstQualityCalculator2.QualityParameter.ActualName = "CurrentBestQuality";
    369       bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstBestQuality";
    370 
    371       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best BestQuality", null, "CurrentBestBestQuality"));
    372       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average BestQuality", null, "CurrentAverageBestQuality"));
    373       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst BestQuality", null, "CurrentWorstBestQuality"));
    374       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    375       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    376       dataTableValuesCollector2.DataTableParameter.ActualName = "BestQualities";
    377 
    378       qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    379       qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    380       qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    381       qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
     265      analyzer2.Name = "Analyzer (placeholder)";
     266      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
     267
     268      resultsCollector3.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
     269      resultsCollector3.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     270      resultsCollector3.ResultsParameter.ActualName = ResultsParameter.Name;
    382271
    383272      generationsTerminationCondition.Name = "Terminate?";
     
    389278      variableCreator.Successor = uniformSubScopesProcessor0;
    390279      uniformSubScopesProcessor0.Operator = islandVariableCreator;
    391       uniformSubScopesProcessor0.Successor = bestQualityMemorizer1;
    392       islandVariableCreator.Successor = islandBestQualityMemorizer1;
    393       islandBestQualityMemorizer1.Successor = islandBestAverageWorstQualityCalculator1;
    394       islandBestAverageWorstQualityCalculator1.Successor = islandDataTableValuesCollector1;
    395       islandDataTableValuesCollector1.Successor = islandQualityDifferenceCalculator1;
    396       islandQualityDifferenceCalculator1.Successor = islandAnalyzer1;
    397       islandAnalyzer1.Successor = islandResultsCollector;
    398       bestQualityMemorizer1.Successor = bestQualityMemorizer2;
    399       bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
    400       bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
    401       dataTableValuesCollector1.Successor = qualityDifferenceCalculator1;
    402       qualityDifferenceCalculator1.Successor = resultsCollector;
    403       resultsCollector.Successor = uniformSubScopesProcessor1;
     280      uniformSubScopesProcessor0.Successor = analyzer1;
     281      islandVariableCreator.Successor = islandAnalyzer1;
     282      islandAnalyzer1.Successor = null;
     283      analyzer1.Successor = resultsCollector1;
     284      resultsCollector1.Successor = resultsCollector2;
     285      resultsCollector2.Successor = uniformSubScopesProcessor1;
    404286      uniformSubScopesProcessor1.Operator = selector;
    405287      uniformSubScopesProcessor1.Successor = generationsCounter;
     
    423305      bestSelector.Successor = rightReducer;
    424306      rightReducer.Successor = null;
    425       mergingReducer.Successor = islandBestQualityMemorizer2;
    426       islandBestQualityMemorizer2.Successor = islandBestAverageWorstQualityCalculator2;
    427       islandBestAverageWorstQualityCalculator2.Successor = islandDataTableValuesCollector2;
    428       islandDataTableValuesCollector2.Successor = islandQualityDifferenceCalculator2;
    429       islandQualityDifferenceCalculator2.Successor = islandAnalyzer2;
     307      mergingReducer.Successor = islandAnalyzer2;
    430308      islandAnalyzer2.Successor = null;
    431309      generationsCounter.Successor = generationsSinceLastMigrationCounter;
     
    442320      uniformSubScopesProcessor4.Operator = immigrationReplacer;
    443321      uniformSubScopesProcessor4.Successor = null;
    444       generationsComparator.Successor = bestQualityMemorizer3;
    445       bestQualityMemorizer3.Successor = bestQualityMemorizer4;
    446       bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
    447       bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2;
    448       dataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
    449       qualityDifferenceCalculator2.Successor = generationsTerminationCondition;
     322      generationsComparator.Successor = analyzer2;
     323      analyzer2.Successor = resultsCollector3;
     324      resultsCollector3.Successor = generationsTerminationCondition;
    450325      generationsTerminationCondition.TrueBranch = null;
    451326      generationsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs

    r3616 r3650  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Analysis;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    27 using HeuristicLab.Operators;
    2828using HeuristicLab.Optimization;
    2929using HeuristicLab.Optimization.Operators;
     
    101101      get { return (ValueLookupParameter<IntValue>)Parameters["SelectedParents"]; }
    102102    }
     103    private ValueParameter<MultiAnalyzer<IPopulationAnalyzer>> AnalyzerParameter {
     104      get { return (ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>)Parameters["Analyzer"]; }
     105    }
    103106    #endregion
    104107
     
    167170      get { return SelectedParentsParameter.Value; }
    168171      set { SelectedParentsParameter.Value = value; }
     172    }
     173    public MultiAnalyzer<IPopulationAnalyzer> Analyzer {
     174      get { return AnalyzerParameter.Value; }
     175      set { AnalyzerParameter.Value = value; }
    169176    }
    170177    private RandomCreator RandomCreator {
     
    204211      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.", new BoolValue(false)));
    205212      Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "Should be about 2 * PopulationSize, for large problems use a smaller value to decrease memory footprint.", new IntValue(200)));
    206 
     213      Parameters.Add(new ValueParameter<MultiAnalyzer<IPopulationAnalyzer>>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer<IPopulationAnalyzer>()));
     214     
    207215      RandomCreator randomCreator = new RandomCreator();
    208216      SolutionsCreator solutionsCreator = new SolutionsCreator();
     
    250258      ParameterizMainLoop();
    251259      ParameterizeSelectors();
     260      ParameterizeAnalyzers();
    252261      UpdateCrossovers();
    253262      UpdateMutators();
     263      UpdateAnalyzers();
    254264      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    255265      base.OnProblemChanged();
     
    266276      ParameterizMainLoop();
    267277      ParameterizeSelectors();
     278      ParameterizeAnalyzers();
    268279      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    269280      base.Problem_EvaluatorChanged(sender, e);
     
    273284      UpdateCrossovers();
    274285      UpdateMutators();
     286      UpdateAnalyzers();
    275287      base.Problem_OperatorsChanged(sender, e);
    276288    }
     
    292304      ParameterizMainLoop();
    293305      ParameterizeSelectors();
     306      ParameterizeAnalyzers();
    294307    }
    295308    #endregion
     
    299312    private void Initialize() {
    300313      InitializeSelectors();
     314      InitializeAnalyzers();
    301315      UpdateSelectors();
     316      UpdateAnalyzers();
    302317      InitializeComparisonFactorModifiers();
    303318      UpdateComparisonFactorModifiers();
     
    317332    }
    318333    private void ParameterizMainLoop() {
    319       MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    320334      MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    321335      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     
    330344      selectors.AddRange(ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name));
    331345      ParameterizeSelectors();
     346    }
     347    private void InitializeAnalyzers() {
     348      //qualityAnalyzer = new PopulationBestAverageWorstQualityAnalyzer();
     349      ParameterizeAnalyzers();
    332350    }
    333351    private void InitializeComparisonFactorModifiers() {
     
    348366          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    349367        }
     368      }
     369    }
     370    private void ParameterizeAnalyzers() {
     371      //qualityAnalyzer.ResultsParameter.ActualName = "Results";
     372      if (Problem != null) {
     373        //qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
     374        //qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
     375        //qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
    350376      }
    351377    }
     
    406432      }
    407433    }
     434    private void UpdateAnalyzers() {
     435      Analyzer.Operators.Clear();
     436      //Analyzer.Operators.Add(qualityAnalyzer);
     437      if (Problem != null) {
     438        foreach (IPopulationAnalyzer analyzer in Problem.Operators.OfType<IPopulationAnalyzer>().OrderBy(x => x.Name))
     439          Analyzer.Operators.Add(analyzer);
     440      }
     441    }
    408442    #endregion
    409443  }
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs

    r3479 r3650  
    4646      get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; }
    4747    }
    48     public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
    49       get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    50     }
    5148    public ValueLookupParameter<IOperator> SelectorParameter {
    5249      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
     
    7370      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
    7471    }
    75     public ValueLookupParameter<IOperator> VisualizerParameter {
    76       get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
    77     }
    78     public LookupParameter<IItem> VisualizationParameter {
    79       get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
     72    public ValueLookupParameter<IOperator> AnalyzerParameter {
     73      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
    8074    }
    8175    public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
     
    120114      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
    121115      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."));
     116      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
    124117      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
    125118      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start)."));
     
    131124
    132125      #region Create operators
    133       ConditionalBranch initializationBranch = new ConditionalBranch();
    134126      VariableCreator variableCreator = new VariableCreator();
    135       Assigner variableAssigner = new Assigner();
    136       BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer();
    137       BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer();
    138       BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator1 = new BestAverageWorstQualityCalculator();
    139       DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector();
    140       DataTableValuesCollector selPressDataTableValuesCollector1 = new DataTableValuesCollector();
    141       QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator();
    142       Placeholder visualizer1 = new Placeholder();
    143       ResultsCollector resultsCollector = new ResultsCollector();
    144       Placeholder selector = new Placeholder();
    145       SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
    146       ChildrenCreator childrenCreator = new ChildrenCreator();
    147       UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
    148       Placeholder crossover = new Placeholder();
    149       ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();
    150       Placeholder evaluator1 = new Placeholder();
    151       IntCounter evaluationCounter1 = new IntCounter();
    152       WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
    153       StochasticBranch mutationBranch1 = new StochasticBranch();
    154       Placeholder mutator1 = new Placeholder();
    155       Placeholder evaluator2 = new Placeholder();
    156       IntCounter evaluationCounter2 = new IntCounter();
    157       StochasticBranch mutationBranch2 = new StochasticBranch();
    158       Placeholder mutator2 = new Placeholder();
    159       Placeholder evaluator3 = new Placeholder();
    160       IntCounter evaluationCounter3 = new IntCounter();
    161       WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();
    162       SubScopesRemover subScopesRemover = new SubScopesRemover();
    163       ConditionalSelector conditionalSelector = new ConditionalSelector();
    164       OffspringSelector offspringSelector = new OffspringSelector();
    165       SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
    166       BestSelector bestSelector = new BestSelector();
    167       RightReducer rightReducer = new RightReducer();
    168       MergingReducer mergingReducer = new MergingReducer();
    169       IntCounter intCounter = new IntCounter();
    170127      Placeholder comparisonFactorModifier = new Placeholder();
    171       Comparator comparator1 = new Comparator();
    172       Comparator comparator2 = new Comparator();
    173       Assigner evaluatedSolutionsAssigner = new Assigner();
    174       ResultsCollector evalSolCollector = new ResultsCollector();
    175       BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer();
    176       BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer();
    177       BestAverageWorstQualityCalculator bestAverageWorstQualityCalculator2 = new BestAverageWorstQualityCalculator();
    178       DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector();
    179       DataTableValuesCollector selPressDataTableValuesCollector2 = new DataTableValuesCollector();
    180       QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator();
    181       Placeholder visualizer2 = new Placeholder();
     128      Placeholder analyzer1 = new Placeholder();
     129      ResultsCollector resultsCollector1 = new ResultsCollector();
     130      OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
     131      IntCounter generationsCounter = new IntCounter();
     132      Comparator maxGenerationsComparator = new Comparator();
     133      Comparator maxSelectionPressureComparator = new Comparator();
     134      Placeholder analyzer2 = new Placeholder();
     135      ResultsCollector resultsCollector2 = new ResultsCollector();
    182136      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
    183137      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
    184138
    185       initializationBranch.ConditionParameter.ActualName = "IsInitialized";
    186 
    187       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // this variable is referenced in SASEGASAMainLoop, do not change!
     139      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
    188140      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
    189141      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
    190142      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
    191       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutionsResult", new IntValue(0)));
    192       variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsInitialized", new BoolValue(true)));
    193 
    194       variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor"; // this variable is referenced in SASEGASA, OffspringSelectionGeneticAlgorithm, do not change!
    195       variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
    196 
    197       bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
    198       bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    199       bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name;
    200 
    201       bestQualityMemorizer2.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
    202       bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    203       bestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name;
    204 
    205       bestAverageWorstQualityCalculator1.AverageQualityParameter.ActualName = "CurrentAverageQuality";
    206       bestAverageWorstQualityCalculator1.BestQualityParameter.ActualName = "CurrentBestQuality";
    207       bestAverageWorstQualityCalculator1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    208       bestAverageWorstQualityCalculator1.QualityParameter.ActualName = QualityParameter.Name;
    209       bestAverageWorstQualityCalculator1.WorstQualityParameter.ActualName = "CurrentWorstQuality";
    210 
    211       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    212       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    213       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    214       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    215       dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    216       dataTableValuesCollector1.DataTableParameter.ActualName = "Qualities";
    217 
    218       selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
    219       selPressDataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
    220       selPressDataTableValuesCollector1.DataTableParameter.ActualName = "SelectionPressures";
    221 
    222       qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    223       qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    224       qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    225       qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality";
    226 
    227       visualizer1.Name = "Visualizer (placeholder)";
    228       visualizer1.OperatorParameter.ActualName = VisualizerParameter.Name;
    229 
    230       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    231       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    232       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    233       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    234       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    235       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    236       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
    237       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
    238       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
    239       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
    240       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
    241       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
    242       resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name));
    243       resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));
    244       resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("SelectionPressures"));
    245       resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
    246 
    247       selector.Name = "Selector (placeholder)";
    248       selector.OperatorParameter.ActualName = SelectorParameter.Name;
    249 
    250       childrenCreator.ParentsPerChild = new IntValue(2);
    251 
    252       crossover.Name = "Crossover (placeholder)";
    253       crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
    254 
    255       osBeforeMutationBranch.Name = "Apply OS before mutation?";
    256       osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
    257 
    258       evaluator1.Name = "Evaluator (placeholder)";
    259       evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;
    260 
    261       evaluationCounter1.Name = "EvaluatedSolutions++";
    262       evaluationCounter1.Increment = new IntValue(1);
    263       evaluationCounter1.ValueParameter.ActualName = "EvaluatedSolutions";
    264 
    265       qualityComparer1.ComparisonFactorParameter.ActualName = "ComparisonFactor";
    266       qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;
    267       qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
    268       qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
    269       qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";
    270 
    271       mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
    272       mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;
    273 
    274       mutator1.Name = "Mutator (placeholder)";
    275       mutator1.OperatorParameter.ActualName = MutatorParameter.Name;
    276 
    277       evaluator2.Name = "Evaluator (placeholder)";
    278       evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;
    279 
    280       evaluationCounter2.Name = "EvaluatedSolutions++";
    281       evaluationCounter2.Increment = new IntValue(1);
    282       evaluationCounter2.ValueParameter.ActualName = "EvaluatedSolutions";
    283 
    284       mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
    285       mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;
    286 
    287       mutator2.Name = "Mutator (placeholder)";
    288       mutator2.OperatorParameter.ActualName = MutatorParameter.Name;
    289 
    290       evaluator3.Name = "Evaluator (placeholder)";
    291       evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;
    292 
    293       evaluationCounter3.Name = "EvaluatedSolutions++";
    294       evaluationCounter3.Increment = new IntValue(1);
    295       evaluationCounter3.ValueParameter.ActualName = "EvaluatedSolutions";
    296 
    297       qualityComparer2.ComparisonFactorParameter.ActualName = "ComparisonFactor";
    298       qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;
    299       qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    300       qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
    301       qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";
    302 
    303       subScopesRemover.RemoveAllSubScopes = true;
    304 
    305       conditionalSelector.CopySelected = new BoolValue(false);
    306       conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
    307 
    308       offspringSelector.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
    309       offspringSelector.LuckyLosersParameter.ActualName = "OSLuckyLosers";
    310       offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
    311       offspringSelector.SelectionPressureParameter.ActualName = "SelectionPressure";
    312       offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
    313       offspringSelector.WinnersParameter.ActualName = "OSWinners";
    314 
    315       bestSelector.CopySelected = new BoolValue(false);
    316       bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
    317       bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
    318       bestSelector.QualityParameter.ActualName = QualityParameter.Name;
    319 
    320       intCounter.Increment = new IntValue(1);
    321       intCounter.ValueParameter.ActualName = "Generations";
    322143
    323144      comparisonFactorModifier.Name = "Modify ComparisonFactor (placeholder)";
    324145      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
    325146
    326       comparator1.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
    327       comparator1.LeftSideParameter.ActualName = "Generations";
    328       comparator1.ResultParameter.ActualName = "TerminateMaximumGenerations";
    329       comparator1.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
    330 
    331       comparator2.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
    332       comparator2.LeftSideParameter.ActualName = "SelectionPressure";
    333       comparator2.ResultParameter.ActualName = "TerminateSelectionPressure";
    334       comparator2.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
    335 
    336       evaluatedSolutionsAssigner.LeftSideParameter.ActualName = "EvaluatedSolutionsResult";
    337       evaluatedSolutionsAssigner.RightSideParameter.ActualName = "EvaluatedSolutions";
    338 
    339       evalSolCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
    340       evalSolCollector.ResultsParameter.ActualName = ResultsParameter.Name;
    341 
    342       bestQualityMemorizer3.BestQualityParameter.ActualName = "BestQuality";
    343       bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name;
    344       bestQualityMemorizer3.QualityParameter.ActualName = QualityParameter.Name;
    345 
    346       bestQualityMemorizer4.BestQualityParameter.ActualName = BestKnownQualityParameter.Name;
    347       bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name;
    348       bestQualityMemorizer4.QualityParameter.ActualName = QualityParameter.Name;
    349 
    350       bestAverageWorstQualityCalculator2.AverageQualityParameter.ActualName = "CurrentAverageQuality";
    351       bestAverageWorstQualityCalculator2.BestQualityParameter.ActualName = "CurrentBestQuality";
    352       bestAverageWorstQualityCalculator2.MaximizationParameter.ActualName = MaximizationParameter.Name;
    353       bestAverageWorstQualityCalculator2.QualityParameter.ActualName = QualityParameter.Name;
    354       bestAverageWorstQualityCalculator2.WorstQualityParameter.ActualName = "CurrentWorstQuality";
    355 
    356       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    357       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
    358       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Worst Quality", null, "CurrentWorstQuality"));
    359       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality"));
    360       dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name));
    361       dataTableValuesCollector2.DataTableParameter.ActualName = "Qualities";
    362 
    363       selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Selection Pressure", null, "SelectionPressure"));
    364       selPressDataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Maximum Selection Pressure", null, MaximumSelectionPressureParameter.Name));
    365       selPressDataTableValuesCollector2.DataTableParameter.ActualName = "SelectionPressures";
    366 
    367       qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest";
    368       qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name;
    369       qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest";
    370       qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality";
    371 
    372       visualizer2.Name = "Visualizer (placeholder)";
    373       visualizer2.OperatorParameter.ActualName = VisualizerParameter.Name;
     147      analyzer1.Name = "Analyzer (placeholder)";
     148      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
     149
     150      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     151      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
     152      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
     153      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
     154      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
     155      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
     156
     157      mainOperator.ComparisonFactorParameter.ActualName = "ComparisonFactor";
     158      mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
     159      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
     160      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
     161      mainOperator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
     162      mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
     163      mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
     164      mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
     165      mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
     166      mainOperator.MutatorParameter.ActualName = MutatorParameter.Name;
     167      mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
     168      mainOperator.QualityParameter.ActualName = QualityParameter.Name;
     169      mainOperator.RandomParameter.ActualName = RandomParameter.Name;
     170      mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
     171      mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
     172      mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
     173
     174      generationsCounter.Increment = new IntValue(1);
     175      generationsCounter.ValueParameter.ActualName = "Generations";
     176
     177      maxGenerationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     178      maxGenerationsComparator.LeftSideParameter.ActualName = "Generations";
     179      maxGenerationsComparator.ResultParameter.ActualName = "TerminateMaximumGenerations";
     180      maxGenerationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
     181
     182      maxSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     183      maxSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
     184      maxSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
     185      maxSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
     186
     187      analyzer2.Name = "Analyzer (placeholder)";
     188      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
     189
     190      resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     191      resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
     192      resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
     193      resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
     194      resultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
     195      resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;
    374196
    375197      conditionalBranch1.Name = "MaximumSelectionPressure reached?";
     
    377199
    378200      conditionalBranch2.Name = "MaximumGenerations reached?";
    379       conditionalBranch2.ConditionParameter.ActualName = "TerminateMaximumGenerations"; // this variable is referenced in SASEGASAMainLoop, do not change!
     201      conditionalBranch2.ConditionParameter.ActualName = "TerminateMaximumGenerations";
    380202      #endregion
    381203
    382204      #region Create operator graph
    383       OperatorGraph.InitialOperator = initializationBranch;
    384       initializationBranch.FalseBranch = variableCreator;
    385       initializationBranch.Successor = selector;
    386       variableCreator.Successor = variableAssigner;
    387       variableAssigner.Successor = bestQualityMemorizer1;
    388       bestQualityMemorizer1.Successor = bestQualityMemorizer2;
    389       bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
    390       bestAverageWorstQualityCalculator1.Successor = dataTableValuesCollector1;
    391       dataTableValuesCollector1.Successor = selPressDataTableValuesCollector1;
    392       selPressDataTableValuesCollector1.Successor = qualityDifferenceCalculator1;
    393       qualityDifferenceCalculator1.Successor = visualizer1;
    394       visualizer1.Successor = resultsCollector;
    395       resultsCollector.Successor = null;
    396       selector.Successor = subScopesProcessor1;
    397       subScopesProcessor1.Operators.Add(new EmptyOperator());
    398       subScopesProcessor1.Operators.Add(childrenCreator);
    399       subScopesProcessor1.Successor = offspringSelector;
    400       childrenCreator.Successor = uniformSubScopesProcessor;
    401       uniformSubScopesProcessor.Operator = crossover;
    402       uniformSubScopesProcessor.Successor = conditionalSelector;
    403       crossover.Successor = osBeforeMutationBranch;
    404       osBeforeMutationBranch.TrueBranch = evaluator1;
    405       osBeforeMutationBranch.FalseBranch = mutationBranch2;
    406       osBeforeMutationBranch.Successor = subScopesRemover;
    407       evaluator1.Successor = evaluationCounter1;
    408       evaluationCounter1.Successor = qualityComparer1;
    409       qualityComparer1.Successor = mutationBranch1;
    410       mutationBranch1.FirstBranch = mutator1;
    411       mutationBranch1.SecondBranch = null;
    412       mutationBranch1.Successor = null;
    413       mutator1.Successor = evaluator2;
    414       evaluator2.Successor = evaluationCounter2;
    415       evaluationCounter2.Successor = null;
    416       mutationBranch2.FirstBranch = mutator2;
    417       mutationBranch2.SecondBranch = null;
    418       mutationBranch2.Successor = evaluator3;
    419       mutator2.Successor = null;
    420       evaluator3.Successor = evaluationCounter3;
    421       evaluationCounter3.Successor = qualityComparer2;
    422       subScopesRemover.Successor = null;
    423       offspringSelector.OffspringCreator = selector;
    424       offspringSelector.Successor = subScopesProcessor2;
    425       subScopesProcessor2.Operators.Add(bestSelector);
    426       subScopesProcessor2.Operators.Add(new EmptyOperator());
    427       subScopesProcessor2.Successor = mergingReducer;
    428       bestSelector.Successor = rightReducer;
    429       rightReducer.Successor = null;
    430       mergingReducer.Successor = intCounter;
    431       intCounter.Successor = comparisonFactorModifier;
    432       comparisonFactorModifier.Successor = comparator1;
    433       comparator1.Successor = comparator2;
    434       comparator2.Successor = evaluatedSolutionsAssigner;
    435       evaluatedSolutionsAssigner.Successor = evalSolCollector;
    436       evalSolCollector.Successor = bestQualityMemorizer3;
    437       bestQualityMemorizer3.Successor = bestQualityMemorizer4;
    438       bestQualityMemorizer4.Successor = bestAverageWorstQualityCalculator2;
    439       bestAverageWorstQualityCalculator2.Successor = dataTableValuesCollector2;
    440       dataTableValuesCollector2.Successor = selPressDataTableValuesCollector2;
    441       selPressDataTableValuesCollector2.Successor = qualityDifferenceCalculator2;
    442       qualityDifferenceCalculator2.Successor = visualizer2;
    443       visualizer2.Successor = conditionalBranch1;
     205      OperatorGraph.InitialOperator = variableCreator;
     206      variableCreator.Successor = comparisonFactorModifier;
     207      comparisonFactorModifier.Successor = analyzer1;
     208      analyzer1.Successor = resultsCollector1;
     209      resultsCollector1.Successor = mainOperator;
     210      mainOperator.Successor = generationsCounter;
     211      generationsCounter.Successor = maxGenerationsComparator;
     212      maxGenerationsComparator.Successor = maxSelectionPressureComparator;
     213      maxSelectionPressureComparator.Successor = analyzer2;
     214      analyzer2.Successor = resultsCollector2;
     215      resultsCollector2.Successor = conditionalBranch1;
    444216      conditionalBranch1.FalseBranch = conditionalBranch2;
    445217      conditionalBranch1.TrueBranch = null;
    446218      conditionalBranch1.Successor = null;
    447       conditionalBranch2.FalseBranch = selector;
     219      conditionalBranch2.FalseBranch = mainOperator;
    448220      conditionalBranch2.TrueBranch = null;
    449221      conditionalBranch2.Successor = null;
Note: See TracChangeset for help on using the changeset viewer.