Changeset 12958 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 09/21/15 01:03:12 (9 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r12951 r12958 333 333 //trim 334 334 if (TrimOlderGenerations) { 335 for (int i = 0; i < generation - 1; ++i) { 336 var vertices = genealogyGraph.GetByRank(i).ToList(); 337 genealogyGraph.RemoveVertices(vertices); 338 } 335 var vertices = genealogyGraph.Vertices.Where(x => x.Rank < generation - 1).ToList(); // select all ranks older than the previous generation 336 genealogyGraph.RemoveVertices(vertices); 339 337 } 340 338 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r11969 r12958 121 121 base.RemoveVertex(vertex); 122 122 } 123 124 public override void RemoveVertices(IEnumerable<IVertex> vertices) { 125 foreach (var v in vertices) 126 this.RemoveVertex(v); 127 } 128 123 129 public IGenealogyGraphNode GetByContent(object content) { 124 130 IGenealogyGraphNode result; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCleanupOperator.cs
r12951 r12958 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic .Tracking{28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 29 29 [Item("SchemaCleanupOperator", "Operator which removes the schemas from the global scope after they have been evaluated.")] 30 30 [StorableClass] -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaCreator.cs
r12952 r12958 33 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 34 35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic .Tracking{35 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 36 36 [Item("SchemaCreator", "An operator that builds schemas based on the heredity relationship in the genealogy graph.")] 37 37 [StorableClass] … … 59 59 get { return (IFixedValueParameter<PercentValue>)Parameters[ReplacementRatioParameterName]; } 60 60 } 61 62 private IFixedValueParameter<BoolValue> RandomReplacementParameter {63 get { return (IFixedValueParameter<BoolValue>)Parameters[RandomReplacementParameterName]; }64 }65 61 #endregion 66 62 … … 70 66 } 71 67 #endregion 68 69 private SchemaEvaluator schemaEvaluator; 70 private SchemaCleanupOperator schemaCleanupOperator; 71 private DataReducer changedTreesReducer; 72 private DataTableValuesCollector valuesCollector; 73 private ResultsCollector resultsCollector; 74 75 private void ParameterizeOperators() { 76 schemaEvaluator = new SchemaEvaluator(); 77 schemaCleanupOperator = new SchemaCleanupOperator(); 78 79 changedTreesReducer = new DataReducer(); 80 changedTreesReducer.ParameterToReduce.ActualName = schemaEvaluator.ChangedTreesParameter.ActualName; 81 changedTreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); 82 changedTreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter 83 changedTreesReducer.TargetParameter.ActualName = "NumberOfChangedTrees"; 84 85 valuesCollector = new DataTableValuesCollector(); 86 valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfChangedTrees")); 87 valuesCollector.DataTableParameter.ActualName = "Diversification"; 88 89 resultsCollector = new ResultsCollector(); 90 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Diversification")); 91 } 72 92 73 93 public SchemaCreator() { … … 77 97 Parameters.Add(new FixedValueParameter<PercentValue>(ReplacementRatioParameterName, new PercentValue(0.2))); 78 98 Parameters.Add(new FixedValueParameter<BoolValue>(RandomReplacementParameterName, new BoolValue(false))); 99 100 ParameterizeOperators(); 79 101 } 80 102 … … 98 120 var anySubtreeSymbol = new AnySubtreeSymbol(); 99 121 100 var schemaEvaluator = new SchemaEvaluator();101 122 var scopes = new ScopeList(this.ExecutionContext.Scope.SubScopes); 102 var schemaCleanupOperator = new SchemaCleanupOperator(); 103 104 var changedTreesReducer = new DataReducer(); 105 changedTreesReducer.ParameterToReduce.ActualName = schemaEvaluator.ChangedTreesParameter.ActualName; 106 changedTreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); 107 changedTreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter 108 changedTreesReducer.TargetParameter.ActualName = "NumberOfChangedTrees"; 109 110 var valuesCollector = new DataTableValuesCollector(); 111 valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfChangedTrees")); 112 valuesCollector.DataTableParameter.ActualName = "Diversification"; 113 114 var resultCollector = new ResultsCollector(); 115 resultCollector.CollectedValues.Add(new LookupParameter<DataTable>("Diversification")); 123 124 if (schemaEvaluator == null || schemaCleanupOperator == null || changedTreesReducer == null || valuesCollector == null || resultsCollector == null) 125 ParameterizeOperators(); 116 126 117 127 var reduceChangedTrees = ExecutionContext.CreateChildOperation(changedTreesReducer); 118 128 var collectValues = ExecutionContext.CreateChildOperation(valuesCollector); 119 var collectResults = ExecutionContext.CreateChildOperation(result Collector);129 var collectResults = ExecutionContext.CreateChildOperation(resultsCollector); 120 130 121 131 var oc = new OperationCollection(); … … 132 142 var indices = arcs.Select(x => ((IFragment<ISymbolicExpressionTreeNode>)x.Data).Index1).Distinct().ToArray(); 133 143 Array.Sort(indices); 134 var nodesToReplace = indices. Where(x => x >= 2).Select(x => nodes[x]).ToList();144 var nodesToReplace = indices.Select(x => nodes[x]).ToList(); 135 145 for (int i = nodesToReplace.Count - 1; i >= 0; --i) { 136 146 var node = nodesToReplace[i]; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/SchemaEvaluator.cs
r12952 r12958 31 31 using HeuristicLab.Random; 32 32 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic .Tracking{33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 34 34 [Item("SchemaEvaluator", "An operator that builds schemas based on the heredity relationship in the genealogy graph.")] 35 35 [StorableClass] … … 95 95 get { return (LookupParameter<IntValue>)Parameters[ChangedTreesParameterName]; } 96 96 } 97 98 97 #endregion 99 98 … … 180 179 181 180 var s = SchemaParameter.ActualValue; 182 var matchingIndividuals = new ScopeList(from ind in individuals 183 let t = (ISymbolicExpressionTree)ind.Variables["SymbolicExpressionTree"].Value 184 where qm.Match(t, s) 185 select ind); 181 var matchingIndividuals = new ScopeList(); 182 foreach (var ind in individuals) { 183 var t = (ISymbolicExpressionTree)ind.Variables["SymbolicExpressionTree"].Value; 184 if (t.Length >= s.Length && qm.Match(t, s)) 185 matchingIndividuals.Add(ind); 186 } 186 187 187 188 if (matchingIndividuals.Count < MinimumSchemaFrequency.Value * individuals.Count) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/UpdateEstimatedValuesOperator.cs
r12951 r12958 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic .Tracking{31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 32 32 [Item("UpdateEstimatedValuesOperator", "Put the estimated values of the tree in the scope to be used by the phenotypic similarity calculator")] 33 33 [StorableClass] … … 82 82 else 83 83 variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(estimatedValues))); 84 var quality = (DoubleValue)variables["Quality"].Value;85 if (double.IsNaN(quality.Value))86 quality.Value = 0.0;87 84 return base.Apply(); 88 85 }
Note: See TracChangeset
for help on using the changeset viewer.