Changeset 155 for trunk/sources/HeuristicLab.Functions/And.cs
- Timestamp:
- 04/22/08 18:05:14 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/And.cs
r2 r155 31 31 public override string Description { 32 32 get { 33 return @"Logical AND operation. Only defined for sub-operator-results 0.0 and 1.0."; 33 return @"Logical AND operation. Only defined for sub-tree-results 0.0 and 1.0. 34 AND is a special form, sub-trees are evaluated from the first to the last. Evaluation is 35 stopped as soon as one of the sub-trees evaluates to 0.0 (false)."; 34 36 } 35 37 } … … 40 42 } 41 43 42 public And(And source, IDictionary<Guid, object> clonedObjects) 43 : base(source, clonedObjects) { 44 } 45 46 47 public override double Evaluate(Dataset dataset, int sampleIndex) { 48 foreach(IFunction subFunction in SubFunctions) { 49 double result = Math.Round(subFunction.Evaluate(dataset, sampleIndex)); 50 if(result == 0.0) return 0.0; 44 // special form 45 public override double Evaluate(Dataset dataset, int sampleIndex, IFunctionTree tree) { 46 foreach(IFunctionTree subTree in tree.SubTrees) { 47 double result = Math.Round(subTree.Evaluate(dataset, sampleIndex)); 48 if(result == 0.0) return 0.0; // one sub-tree is 0.0 (false) => return false 51 49 else if(result != 1.0) return double.NaN; 52 50 } 51 // all sub-trees evaluated to 1.0 (true) => return 1.0 (true) 53 52 return 1.0; 54 53 } 55 54 56 public override object Clone(IDictionary<Guid, object> clonedObjects) { 57 And clone = new And(this, clonedObjects); 58 clonedObjects.Add(clone.Guid, clone); 59 return clone; 55 public override double Apply(Dataset dataset, int sampleIndex, double[] args) { 56 throw new NotImplementedException(); 60 57 } 61 58
Note: See TracChangeset
for help on using the changeset viewer.