- Timestamp:
- 04/25/08 14:46:58 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Functions
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/And.cs
r189 r192 67 67 } 68 68 // all sub-trees evaluated to 1.0 (true) => return 1.0 (true) 69 return 1.0; 69 return 1.0; 70 } 71 72 public override object Clone(IDictionary<Guid, object> clonedObjects) { 73 AndFunctionTree clone = new AndFunctionTree(); 74 clonedObjects.Add(clone.Guid, clone); 75 FillClone(clone, clonedObjects); 76 return clone; 70 77 } 71 78 } -
trunk/sources/HeuristicLab.Functions/Constant.cs
r189 r192 82 82 83 83 public override object Clone(IDictionary<Guid, object> clonedObjects) { 84 ConstantFunctionTree clone = (ConstantFunctionTree)base.Clone(clonedObjects); 84 ConstantFunctionTree clone = new ConstantFunctionTree(); 85 clonedObjects.Add(clone.Guid, clone); 86 FillClone(clone, clonedObjects); 85 87 clone.UpdateCachedValues(); 86 88 return clone; -
trunk/sources/HeuristicLab.Functions/FunctionTree.cs
r189 r192 93 93 } 94 94 95 double[] evaluationResults; 95 96 public virtual double Evaluate(Dataset dataset, int sampleIndex) { 96 double[] evaluationResults = new double[SubTrees.Count]; 97 // lazy creation of evaluationResults to unburden the GC 98 if(evaluationResults == null) { 99 evaluationResults = new double[SubTrees.Count]; 100 } 97 101 for(int i = 0; i < evaluationResults.Length; i++) { 98 102 evaluationResults[i] = SubTrees[i].Evaluate(dataset, sampleIndex); … … 128 132 129 133 public override object Clone(IDictionary<Guid, object> clonedObjects) { 130 FunctionTree clone = (FunctionTree)base.Clone(clonedObjects); 134 FunctionTree clone = new FunctionTree(); 135 clonedObjects.Add(clone.Guid, clone); 136 FillClone(clone, clonedObjects); 137 return clone; 138 } 139 140 public void FillClone(FunctionTree clone, IDictionary<Guid, object> clonedObjects) { 141 clone.function = function; 142 foreach(IVariable variable in localVariables) { 143 clone.AddVariable((IVariable)variable.Clone(clonedObjects)); 144 } 131 145 foreach(IFunctionTree tree in subTrees) { 132 146 clone.AddSubTree((IFunctionTree)tree.Clone(clonedObjects)); 133 147 } 134 foreach(IVariable variable in localVariables) {135 clone.AddVariable((IVariable)variable.Clone(clonedObjects));136 }137 clone.function = function;138 return clone;139 148 } 140 149 -
trunk/sources/HeuristicLab.Functions/IfThenElse.cs
r189 r192 65 65 else return double.NaN; 66 66 } 67 68 public override object Clone(IDictionary<Guid, object> clonedObjects) { 69 IfThenElseFunctionTree clone = new IfThenElseFunctionTree(); 70 clonedObjects.Add(clone.Guid, clone); 71 FillClone(clone, clonedObjects); 72 return clone; 73 } 67 74 } 68 75 } -
trunk/sources/HeuristicLab.Functions/Or.cs
r189 r192 66 66 return 0.0; 67 67 } 68 69 public override object Clone(IDictionary<Guid, object> clonedObjects) { 70 OrFunctionTree clone = new OrFunctionTree(); 71 clonedObjects.Add(clone.Guid, clone); 72 FillClone(clone, clonedObjects); 73 return clone; 74 } 68 75 } 69 76 } -
trunk/sources/HeuristicLab.Functions/Variable.cs
r189 r192 102 102 103 103 public override object Clone(IDictionary<Guid, object> clonedObjects) { 104 VariableFunctionTree clone = (VariableFunctionTree)base.Clone(clonedObjects); 104 VariableFunctionTree clone = new VariableFunctionTree(); 105 clonedObjects.Add(clone.Guid, clone); 106 FillClone(clone, clonedObjects); 105 107 clone.UpdateCachedValues(); 106 108 return clone;
Note: See TracChangeset
for help on using the changeset viewer.