Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/16/14 16:37:56 (10 years ago)
Author:
bburlacu
Message:

#1772: Small changes to the GenealogyGraph. Added generic Fragment class and interface. Added the SymbolicDataAnalysisPopulationDiversityAnalyzer. Added specialized tracking operators for symbolic data analysis. Merged trunk changes.

File:
1 edited

Legend:

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

    r10300 r10347  
    1515  where T : class,IItem {
    1616
    17     private AfterCrossoverOperator<T> afterCrossoverOperator;
    18     private AfterManipulatorOperator<T> afterManipulatorOperator;
    19     private BeforeManipulatorOperator<T> beforeManipulatorOperator;
    2017    public string CrossoverParentsParameterName { get; set; }
    2118    public string CrossoverChildParameterName { get; set; }
     
    2421    public IScopeTreeLookupParameter<DoubleValue> QualityParameter;
    2522    public IScopeTreeLookupParameter<T> PopulationParameter;
     23
     24    public ICrossoverOperator<T> BeforeCrossoverOperator { get; set; }
     25    public ICrossoverOperator<T> AfterCrossoverOperator { get; set; }
     26    public IManipulatorOperator<T> BeforeManipulatorOperator { get; set; }
     27    public IManipulatorOperator<T> AfterManipulatorOperator { get; set; }
    2628
    2729    private const string PopulationParameterName = "Population";
     
    130132      : base(original, cloner) {
    131133    }
     134    [StorableHook(HookType.AfterDeserialization)]
     135    private void AfterDeserialization() {
     136      // the instrumented operators
     137      if (!Parameters.ContainsKey(CrossoverParameterName))
     138        Parameters.Add(new LookupParameter<ICrossover>(CrossoverParameterName, "The crossover operator."));
     139      if (!Parameters.ContainsKey(ManipulatorParameterName))
     140        Parameters.Add(new LookupParameter<IManipulator>(ManipulatorParameterName, "The manipulator operator."));
     141      if (!Parameters.ContainsKey(SolutionCreatorParameterName))
     142        Parameters.Add(new LookupParameter<ISolutionCreator>(SolutionCreatorParameterName, "The solution creator operator."));
     143      // the analyzer parameters
     144      if (!Parameters.ContainsKey(EnableCrossoverTrackingParameterName))
     145        Parameters.Add(new ValueParameter<BoolValue>(EnableCrossoverTrackingParameterName, new BoolValue(true)));
     146      if (!Parameters.ContainsKey(EnableManipulatorTrackingParameterName))
     147        Parameters.Add(new ValueParameter<BoolValue>(EnableManipulatorTrackingParameterName, new BoolValue(true)));
     148      if (!Parameters.ContainsKey(EnableSolutionCreatorTrackingParameterName))
     149        Parameters.Add(new ValueParameter<BoolValue>(EnableSolutionCreatorTrackingParameterName, new BoolValue(true)));
     150      // parameters required by the analyzer to do its work
     151      if (!Parameters.ContainsKey(GenerationsParameterName))
     152        Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations so far."));
     153      if (!Parameters.ContainsKey(ResultsParameterName))
     154        Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
     155      if (!Parameters.ContainsKey(PopulationParameterName)) {
     156        PopulationParameter = new ScopeTreeLookupParameter<T>(PopulationParameterName);
     157        Parameters.Add(PopulationParameter);
     158      }
     159      if (!Parameters.ContainsKey(QualityParameterName)) {
     160        QualityParameter = new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName);
     161        Parameters.Add(QualityParameter);
     162      }
     163    }
    132164
    133165    public bool EnabledByDefault {
     
    146178        // at the beginning we add the before/after operators to the instrumented operators
    147179        if (EnableCrossoverTracking.Value) {
    148           if (afterCrossoverOperator == null) {
    149             afterCrossoverOperator = new AfterCrossoverOperator<T>();
    150             afterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
    151             afterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
    152           }
    153           var instrumentedCrossover = (InstrumentedOperator)Crossover;
    154           instrumentedCrossover.AfterExecutionOperators.Add(afterCrossoverOperator);
     180          if (BeforeCrossoverOperator != null) {
     181            BeforeCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
     182            BeforeCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
     183            var instrumentedCrossover = (InstrumentedOperator)Crossover;
     184            instrumentedCrossover.BeforeExecutionOperators.Add(BeforeCrossoverOperator);
     185          }
     186          if (AfterCrossoverOperator != null) {
     187            AfterCrossoverOperator.ParentsParameter.ActualName = CrossoverParentsParameterName;
     188            AfterCrossoverOperator.ChildParameter.ActualName = CrossoverChildParameterName;
     189            var instrumentedCrossover = (InstrumentedOperator)Crossover;
     190            instrumentedCrossover.AfterExecutionOperators.Add(AfterCrossoverOperator);
     191          }
    155192        }
    156193
    157194        if (EnableManipulatorTracking.Value && Manipulator != null) {
    158           if (beforeManipulatorOperator == null) {
    159             beforeManipulatorOperator = new BeforeManipulatorOperator<T>();
    160             beforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
    161           }
    162           if (afterManipulatorOperator == null) {
    163             afterManipulatorOperator = new AfterManipulatorOperator<T>();
    164             afterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
    165           }
    166           var instrumentedManipulator = (InstrumentedOperator)Manipulator;
    167           instrumentedManipulator.BeforeExecutionOperators.Add(beforeManipulatorOperator);
    168           instrumentedManipulator.AfterExecutionOperators.Add(afterManipulatorOperator);
     195          if (BeforeManipulatorOperator == null) {
     196            BeforeManipulatorOperator = new BeforeManipulatorOperator<T>();
     197            BeforeManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
     198            var instrumentedManipulator = (InstrumentedOperator)Manipulator;
     199            instrumentedManipulator.BeforeExecutionOperators.Add(BeforeManipulatorOperator);
     200          }
     201          if (AfterManipulatorOperator == null) {
     202            AfterManipulatorOperator = new AfterManipulatorOperator<T>();
     203            AfterManipulatorOperator.ChildParameter.ActualName = ManipulatorChildParameterName;
     204            var instrumentedManipulator = (InstrumentedOperator)Manipulator;
     205            instrumentedManipulator.AfterExecutionOperators.Add(AfterManipulatorOperator);
     206          }
    169207        }
    170208      } else {
Note: See TracChangeset for help on using the changeset viewer.