Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/08 00:02:43 (16 years ago)
Author:
gkronber
Message:

worked on #139:

  • fixed display of trees in the gui
  • split list representation of tree into two lists code and data
  • implemented static evaluation for all predefined functions (except ProgrammableFunction)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ExperimentalFunctionsBaking/IfThenElse.cs

    r192 r220  
    2828
    2929namespace HeuristicLab.Functions {
    30   public class IfThenElse : FunctionBase {
     30  public sealed class IfThenElse : FunctionBase {
    3131    public override string Description {
    3232      get {
     
    4141    }
    4242
    43     public override IFunctionTree GetTreeNode() {
    44       return new IfThenElseFunctionTree(this);
    45     }
    46 
    47     // special form
    48     public override double Apply(Dataset dataset, int sampleIndex, double[] args) {
    49       throw new NotImplementedException();
    50     }
    51 
    5243    public override void Accept(IFunctionVisitor visitor) {
    5344      visitor.Visit(this);
    5445    }
    5546  }
    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   }
    7547}
Note: See TracChangeset for help on using the changeset viewer.