Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11032


Ignore:
Timestamp:
06/22/14 23:10:21 (10 years ago)
Author:
bburlacu
Message:

#1772: Minor change to the GenealogyAnalyzer (remove properties for retrieving LookupParameter values).

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs

    r10936 r11032  
    101101
    102102    #region properties
    103     public ICrossover Crossover {
    104       get { return CrossoverParameter.ActualValue; }
    105     }
    106     public IManipulator Manipulator {
    107       get { return ManipulatorParameter.ActualValue; }
    108     }
    109103    public ICrossoverOperator<T> BeforeCrossoverOperator {
    110104      get { return BeforeCrossoverOperatorParameter.Value; }
     
    119113      get { return AfterManipulatorOperatorParameter.Value; }
    120114    }
    121     public ISolutionCreator SolutionCreator {
    122       get { return SolutionCreatorParameter.ActualValue; }
    123     }
    124115    public BoolValue EnableCrossoverTracking {
    125116      get { return EnableCrossoverTrackingParameter.Value; }
     
    130121    public BoolValue EnableSolutionCreatorTracking {
    131122      get { return EnableSolutionCreatorTrackingParameter.Value; }
    132     }
    133     public ResultCollection Results {
    134       get { return ResultsParameter.ActualValue; }
    135     }
    136     public IntValue Generations {
    137       get { return GenerationsParameter.ActualValue; }
    138123    }
    139124
     
    141126      get {
    142127        IResult result;
    143         if (!Results.ContainsKey(PopulationGraphParameterName)) {
     128        var results = ResultsParameter.ActualValue;
     129        if (!results.ContainsKey(PopulationGraphParameterName)) {
    144130          result = new Result(PopulationGraphParameterName, new GenealogyGraph<T>());
    145           Results.Add(result);
     131          results.Add(result);
    146132        } else {
    147           result = Results[PopulationGraphParameterName];
     133          result = results[PopulationGraphParameterName];
    148134        }
    149135        var graph = (IGenealogyGraph<T>)result.Value;
     
    213199    private void ConfigureTrackingOperators() {
    214200      // at the beginning we add the before/after operators to the instrumented operators
    215       if (Crossover != null) {
    216         var instrumentedCrossover = (InstrumentedOperator)Crossover;
     201      var crossover = CrossoverParameter.ActualValue;
     202      if (crossover != null) {
     203        var instrumentedCrossover = (InstrumentedOperator)crossover;
    217204        instrumentedCrossover.AfterExecutionOperators.Clear();
    218205        instrumentedCrossover.BeforeExecutionOperators.Clear();
     
    227214        }
    228215      }
    229 
    230       if (Manipulator != null) {
    231         var instrumentedManipulator = (InstrumentedOperator)Manipulator;
     216      var manipulator = ManipulatorParameter.ActualValue;
     217      if (manipulator != null) {
     218        var instrumentedManipulator = (InstrumentedOperator)manipulator;
    232219        instrumentedManipulator.AfterExecutionOperators.Clear();
    233220        instrumentedManipulator.BeforeExecutionOperators.Clear();
     
    248235      var qualities = QualityParameter.ActualValue.ToList();
    249236
    250       if (Generations.Value == 0) {
     237      int currentGeneration = GenerationsParameter.ActualValue.Value;
     238      if (currentGeneration == 0) {
    251239        ConfigureTrackingOperators();
    252240
    253241        for (int i = 0; i < population.Count; ++i) {
    254242          var individual = population[i];
    255           var vertex = new GenealogyGraphNode<T>(individual) { Rank = Generations.Value };
     243          var vertex = new GenealogyGraphNode<T>(individual) { Rank = currentGeneration };
    256244          GenealogyGraph.AddVertex(vertex);
    257245          // save the vertex id in the individual scope (so that we can identify graph indices)
     
    276264
    277265          var vertex = new GenealogyGraphNode<T>(prevVertex.Content) {
    278             Rank = Generations.Value,
     266            Rank = currentGeneration,
    279267            Quality = prevVertex.Quality,
    280268            IsElite = false
     
    301289
    302290      // remove extra graph nodes (added by the instrumented operators in the case of offspring selection)
    303       var discardedOffspring = GenealogyGraph.Ranks[Generations.Value].Select(x => (T)x.Content).Except(population).ToList();
     291      var discardedOffspring = GenealogyGraph.Ranks[currentGeneration].Select(x => (T)x.Content).Except(population).ToList();
    304292      foreach (var individual in discardedOffspring) {
    305293        var vertex = GenealogyGraph.GetVertex(individual);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs

    r10897 r11032  
    2020#endregion
    2121
    22 using System;
    2322using System.Linq;
    2423using HeuristicLab.Common;
     
    5251      // since mutation always takes place after crossover, the vertex for the current child is already in the tree
    5352      var v = (IGenealogyGraphNode<T>)GenealogyGraph.GetVertex(ChildParameter.ActualValue);
    54 
    55       if (!v.Rank.IsAlmost(Generations.Value + 1)) {
    56         throw new Exception("Child rank should be generations.value + 1");
    57       }
    5853      var clone = (T)ChildParameter.ActualValue.Clone();
    5954
Note: See TracChangeset for help on using the changeset viewer.