Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/08 18:05:14 (16 years ago)
Author:
gkronber
Message:

merged FunctionsAndStructIdRefactoring-branch (r142, r143, r144, r145, r146, r147, r148, r149, r152, r153) back into the trunk (ticket #112)

File:
1 edited

Legend:

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

    r2 r155  
    3131    public override string Description {
    3232      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.
     34AND is a special form, sub-trees are evaluated from the first to the last. Evaluation is
     35stopped as soon as one of the sub-trees evaluates to 0.0 (false).";
    3436      }
    3537    }
     
    4042    }
    4143
    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
    5149        else if(result != 1.0) return double.NaN;
    5250      }
     51      // all sub-trees evaluated to 1.0 (true) => return 1.0 (true)
    5352      return 1.0;
    5453    }
    5554
    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();
    6057    }
    6158
Note: See TracChangeset for help on using the changeset viewer.