Changeset 12988 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/DiversificationStatisticsOperator.cs
- Timestamp:
- 10/09/15 00:16:03 (9 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/DiversificationStatisticsOperator.cs
r12966 r12988 20 20 #endregion 21 21 22 using System.Linq;22 using HeuristicLab.Analysis; 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 25 26 using HeuristicLab.Operators; 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Parameters; 26 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 30 … … 29 32 [Item("SchemaCleanupOperator", "Operator which removes the schemas from the global scope after they have been evaluated.")] 30 33 [StorableClass] 31 public class SchemaCleanupOperator : SingleSuccessorOperator { 32 public SchemaCleanupOperator() { } 34 public class DiversificationStatisticsOperator : SingleSuccessorOperator { 35 private const string NumberOfChangedTreesParameterName = "NumberOfChangedTrees"; 36 private const string NumberOfSchemasParameterName = "NumberOfSchemas"; 37 private const string AverageSchemaLengthParameterName = "AverageSchemaLength"; 38 private const string ResultCollectionParameterName = "Results"; 33 39 34 protected SchemaCleanupOperator(SchemaCleanupOperator original, Cloner cloner) : base(original, cloner) { } 40 public ILookupParameter<IntValue> NumberOfChangedTreesParameter { 41 get { return (ILookupParameter<IntValue>)Parameters[NumberOfChangedTreesParameterName]; } 42 } 43 public ILookupParameter<IntValue> NumberOfSchemasParameter { 44 get { return (ILookupParameter<IntValue>)Parameters[NumberOfSchemasParameterName]; } 45 } 46 public ILookupParameter<DoubleValue> AverageSchemaLengthParameter { 47 get { return (ILookupParameter<DoubleValue>)Parameters[AverageSchemaLengthParameterName]; } 48 } 49 public ILookupParameter<ResultCollection> ResultCollectionParameter { 50 get { return (ILookupParameter<ResultCollection>)Parameters[ResultCollectionParameterName]; } 51 } 35 52 36 public override IDeepCloneable Clone(Cloner cloner) { return new SchemaCleanupOperator(this, cloner); } 53 public DiversificationStatisticsOperator() { 54 Parameters.Add(new LookupParameter<IntValue>(NumberOfChangedTreesParameterName)); 55 Parameters.Add(new LookupParameter<IntValue>(NumberOfSchemasParameterName)); 56 Parameters.Add(new LookupParameter<DoubleValue>(AverageSchemaLengthParameterName)); 57 Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName)); 58 } 59 60 protected DiversificationStatisticsOperator(DiversificationStatisticsOperator original, Cloner cloner) : base(original, cloner) { } 61 62 public override IDeepCloneable Clone(Cloner cloner) { return new DiversificationStatisticsOperator(this, cloner); } 37 63 38 64 [StorableConstructor] 39 protected SchemaCleanupOperator(bool deserializing) : base(deserializing) { }65 protected DiversificationStatisticsOperator(bool deserializing) : base(deserializing) { } 40 66 41 67 public override IOperation Apply() { 42 foreach (var scope in ExecutionContext.Scope.SubScopes.Where(x => x.Name.Equals("Schema"))) { 43 foreach (var subscope in scope.SubScopes) { subscope.Variables.Clear(); } 44 scope.SubScopes.Clear(); 45 scope.Variables.Clear(); 68 69 var results = ResultCollectionParameter.ActualValue; 70 DataTable table; 71 if (!results.ContainsKey("NumberOfChangedTrees")) { 72 table = new DataTable(); 73 results.Add(new Result("NumberOfChangedTrees", table)); 74 var row = new DataRow("Changed trees"); 75 table.Rows.Add(row); 46 76 } 47 ExecutionContext.Scope.SubScopes.RemoveAll(x => x.Name.Equals("Schema")); 77 if (!results.ContainsKey("AverageSchemaLength")) { 78 table = new DataTable(); 79 results.Add(new Result("AverageSchemaLength", table)); 80 var row = new DataRow("Average schema length"); 81 table.Rows.Add(row); 82 } 83 if (!results.ContainsKey("NumberOfSchemas")) { 84 table = new DataTable(); 85 results.Add(new Result("NumberOfSchemas", table)); 86 var row = new DataRow("Number of schemas"); 87 table.Rows.Add(row); 88 } 89 ((DataTable)results["NumberOfChangedTrees"].Value).Rows["Changed trees"].Values.Add(NumberOfChangedTreesParameter.ActualValue.Value); 90 ((DataTable)results["AverageSchemaLength"].Value).Rows["Average schema length"].Values.Add(AverageSchemaLengthParameter.ActualValue.Value); 91 ((DataTable)results["NumberOfSchemas"].Value).Rows["Number of schemas"].Values.Add(NumberOfSchemasParameter.ActualValue.Value); 92 48 93 return base.Apply(); 49 94 }
Note: See TracChangeset
for help on using the changeset viewer.