Changeset 11032
- Timestamp:
- 06/22/14 23:10:21 (10 years ago)
- 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 101 101 102 102 #region properties 103 public ICrossover Crossover {104 get { return CrossoverParameter.ActualValue; }105 }106 public IManipulator Manipulator {107 get { return ManipulatorParameter.ActualValue; }108 }109 103 public ICrossoverOperator<T> BeforeCrossoverOperator { 110 104 get { return BeforeCrossoverOperatorParameter.Value; } … … 119 113 get { return AfterManipulatorOperatorParameter.Value; } 120 114 } 121 public ISolutionCreator SolutionCreator {122 get { return SolutionCreatorParameter.ActualValue; }123 }124 115 public BoolValue EnableCrossoverTracking { 125 116 get { return EnableCrossoverTrackingParameter.Value; } … … 130 121 public BoolValue EnableSolutionCreatorTracking { 131 122 get { return EnableSolutionCreatorTrackingParameter.Value; } 132 }133 public ResultCollection Results {134 get { return ResultsParameter.ActualValue; }135 }136 public IntValue Generations {137 get { return GenerationsParameter.ActualValue; }138 123 } 139 124 … … 141 126 get { 142 127 IResult result; 143 if (!Results.ContainsKey(PopulationGraphParameterName)) { 128 var results = ResultsParameter.ActualValue; 129 if (!results.ContainsKey(PopulationGraphParameterName)) { 144 130 result = new Result(PopulationGraphParameterName, new GenealogyGraph<T>()); 145 Results.Add(result);131 results.Add(result); 146 132 } else { 147 result = Results[PopulationGraphParameterName];133 result = results[PopulationGraphParameterName]; 148 134 } 149 135 var graph = (IGenealogyGraph<T>)result.Value; … … 213 199 private void ConfigureTrackingOperators() { 214 200 // 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; 217 204 instrumentedCrossover.AfterExecutionOperators.Clear(); 218 205 instrumentedCrossover.BeforeExecutionOperators.Clear(); … … 227 214 } 228 215 } 229 230 if ( Manipulator != null) {231 var instrumentedManipulator = (InstrumentedOperator) Manipulator;216 var manipulator = ManipulatorParameter.ActualValue; 217 if (manipulator != null) { 218 var instrumentedManipulator = (InstrumentedOperator)manipulator; 232 219 instrumentedManipulator.AfterExecutionOperators.Clear(); 233 220 instrumentedManipulator.BeforeExecutionOperators.Clear(); … … 248 235 var qualities = QualityParameter.ActualValue.ToList(); 249 236 250 if (Generations.Value == 0) { 237 int currentGeneration = GenerationsParameter.ActualValue.Value; 238 if (currentGeneration == 0) { 251 239 ConfigureTrackingOperators(); 252 240 253 241 for (int i = 0; i < population.Count; ++i) { 254 242 var individual = population[i]; 255 var vertex = new GenealogyGraphNode<T>(individual) { Rank = Generations.Value};243 var vertex = new GenealogyGraphNode<T>(individual) { Rank = currentGeneration }; 256 244 GenealogyGraph.AddVertex(vertex); 257 245 // save the vertex id in the individual scope (so that we can identify graph indices) … … 276 264 277 265 var vertex = new GenealogyGraphNode<T>(prevVertex.Content) { 278 Rank = Generations.Value,266 Rank = currentGeneration, 279 267 Quality = prevVertex.Quality, 280 268 IsElite = false … … 301 289 302 290 // 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(); 304 292 foreach (var individual in discardedOffspring) { 305 293 var vertex = GenealogyGraph.GetVertex(individual); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs
r10897 r11032 20 20 #endregion 21 21 22 using System;23 22 using System.Linq; 24 23 using HeuristicLab.Common; … … 52 51 // since mutation always takes place after crossover, the vertex for the current child is already in the tree 53 52 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 }58 53 var clone = (T)ChildParameter.ActualValue.Clone(); 59 54
Note: See TracChangeset
for help on using the changeset viewer.