Changeset 220 for branches/ExperimentalFunctionsBaking/IfThenElse.cs
- Timestamp:
- 05/07/08 00:02:43 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ExperimentalFunctionsBaking/IfThenElse.cs
r192 r220 28 28 29 29 namespace HeuristicLab.Functions { 30 public class IfThenElse : FunctionBase {30 public sealed class IfThenElse : FunctionBase { 31 31 public override string Description { 32 32 get { … … 41 41 } 42 42 43 public override IFunctionTree GetTreeNode() {44 return new IfThenElseFunctionTree(this);45 }46 47 // special form48 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {49 throw new NotImplementedException();50 }51 52 43 public override void Accept(IFunctionVisitor visitor) { 53 44 visitor.Visit(this); 54 45 } 55 46 } 56 57 class IfThenElseFunctionTree : FunctionTree {58 public IfThenElseFunctionTree() : base() { }59 public IfThenElseFunctionTree(IfThenElse ifte) : base(ifte) { }60 61 public override double Evaluate(Dataset dataset, int sampleIndex) {62 double condition = Math.Round(SubTrees[0].Evaluate(dataset, sampleIndex));63 if(condition < .5) return SubTrees[1].Evaluate(dataset, sampleIndex);64 else if(condition >= .5) return SubTrees[2].Evaluate(dataset, sampleIndex);65 else return double.NaN;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 }74 }75 47 }
Note: See TracChangeset
for help on using the changeset viewer.