Changeset 10347 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers
- Timestamp:
- 01/16/14 16:37:56 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r10300 r10347 15 15 where T : class,IItem { 16 16 17 private AfterCrossoverOperator<T> afterCrossoverOperator;18 private AfterManipulatorOperator<T> afterManipulatorOperator;19 private BeforeManipulatorOperator<T> beforeManipulatorOperator;20 17 public string CrossoverParentsParameterName { get; set; } 21 18 public string CrossoverChildParameterName { get; set; } … … 24 21 public IScopeTreeLookupParameter<DoubleValue> QualityParameter; 25 22 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; } 26 28 27 29 private const string PopulationParameterName = "Population"; … … 130 132 : base(original, cloner) { 131 133 } 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 } 132 164 133 165 public bool EnabledByDefault { … … 146 178 // at the beginning we add the before/after operators to the instrumented operators 147 179 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 } 155 192 } 156 193 157 194 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 } 169 207 } 170 208 } else {
Note: See TracChangeset
for help on using the changeset viewer.