Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/08 08:55:19 (16 years ago)
Author:
gkronber
Message:

merged changes (r201 r203 r206 r208 r220 r223 r224 r225 r226 r227) from branch ExperimentalFunctionsBaking into the trunk. (ticket #139)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Functions/And.cs

    r192 r229  
    2828
    2929namespace HeuristicLab.Functions {
    30   public class And : FunctionBase {
     30  public sealed class And : FunctionBase {
    3131    public override string Description {
    3232      get {
     
    4242    }
    4343
    44     public override IFunctionTree GetTreeNode() {
    45       return new AndFunctionTree(this);
    46     }
    47 
    48     // special form
    49     public override double Apply(Dataset dataset, int sampleIndex, double[] args) {
    50       throw new NotImplementedException();
    51     }
    52 
    5344    public override void Accept(IFunctionVisitor visitor) {
    5445      visitor.Visit(this);
    5546    }
    5647  }
    57 
    58   class AndFunctionTree : FunctionTree {
    59     public AndFunctionTree() : base() { }
    60     public AndFunctionTree(And and) : base(and) { }
    61 
    62     public override double Evaluate(Dataset dataset, int sampleIndex) {
    63       foreach(IFunctionTree subTree in SubTrees) {
    64         double result = Math.Round(subTree.Evaluate(dataset, sampleIndex));
    65         if(result == 0.0) return 0.0; // one sub-tree is 0.0 (false) => return false
    66         else if(result != 1.0) return double.NaN;
    67       }
    68       // all sub-trees evaluated to 1.0 (true) => return 1.0 (true)
    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;
    77     }
    78   }
    7948}
Note: See TracChangeset for help on using the changeset viewer.