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/Or.cs

    r192 r229  
    2828
    2929namespace HeuristicLab.Functions {
    30   public class Or : FunctionBase {
     30  public sealed class Or : FunctionBase {
    3131    public override string Description {
    3232      get {
     
    4141    }
    4242
    43     public override IFunctionTree GetTreeNode() {
    44       return new OrFunctionTree(this);
    45     }
    46     // or is a special form and can't be applied
    47     public override double Apply(Dataset dataset, int sampleIndex, double[] args) {
    48       throw new NotImplementedException();
    49     }
    5043    public override void Accept(IFunctionVisitor visitor) {
    5144      visitor.Visit(this);
    5245    }
    5346  }
    54 
    55   class OrFunctionTree : FunctionTree {
    56     public OrFunctionTree() : base() { }
    57     public OrFunctionTree(Or or) : base(or) { }
    58 
    59     public override double Evaluate(Dataset dataset, int sampleIndex) {
    60       foreach(IFunctionTree subTree in SubTrees) {
    61         double result = Math.Round(subTree.Evaluate(dataset, sampleIndex));
    62         if(result == 1.0) return 1.0; // sub-tree evaluates to 1.0 (true) return 1.0
    63         else if(result != 0.0) return double.NaN;
    64       }
    65       // all sub-trees evaluated to 0.0 (false) return false
    66       return 0.0;
    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     }
    75   }
    7647}
Note: See TracChangeset for help on using the changeset viewer.