Changeset 229 for trunk/sources/HeuristicLab.Functions
- Timestamp:
- 05/11/08 08:55:19 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Functions
- Files:
-
- 1 deleted
- 26 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/Addition.cs
r155 r229 30 30 31 31 namespace HeuristicLab.Functions { 32 public class Addition : FunctionBase {32 public sealed class Addition : FunctionBase { 33 33 public override string Description { 34 34 get { … … 46 46 } 47 47 48 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {49 // (+ 3) => 350 // (+ 2 3) => 551 // (+ 3 4 5) => 1252 double sum = 0.0;53 for (int i = 0; i < args.Length; i++) {54 sum += args[i];55 }56 return sum;57 }58 59 48 public override void Accept(IFunctionVisitor visitor) { 60 49 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/And.cs
r192 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class And : FunctionBase {30 public sealed class And : FunctionBase { 31 31 public override string Description { 32 32 get { … … 42 42 } 43 43 44 public override IFunctionTree GetTreeNode() {45 return new AndFunctionTree(this);46 }47 48 // special form49 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {50 throw new NotImplementedException();51 }52 53 44 public override void Accept(IFunctionVisitor visitor) { 54 45 visitor.Visit(this); 55 46 } 56 47 } 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 false66 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 }79 48 } -
trunk/sources/HeuristicLab.Functions/Average.cs
r155 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class Average : FunctionBase {30 public sealed class Average : FunctionBase { 31 31 public override string Description { 32 32 get { … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 double sum = 0.0;44 for(int i = 0; i < args.Length; i++) {45 sum += args[i];46 }47 return sum / args.Length;48 }49 50 42 public override void Accept(IFunctionVisitor visitor) { 51 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Constant.cs
r192 r229 30 30 31 31 namespace HeuristicLab.Functions { 32 public class Constant : FunctionBase {32 public sealed class Constant : FunctionBase { 33 33 public const string VALUE = "Value"; 34 34 … … 51 51 AddConstraint(new NumberOfSubOperatorsConstraint(0, 0)); 52 52 } 53 54 public override IFunctionTree GetTreeNode() {55 return new ConstantFunctionTree(this);56 }57 58 // can't apply a constant59 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {60 throw new NotSupportedException();61 }62 63 53 public override void Accept(IFunctionVisitor visitor) { 64 54 visitor.Visit(this); 65 55 } 66 56 } 67 68 class ConstantFunctionTree : FunctionTree {69 private ConstrainedDoubleData value;70 public ConstantFunctionTree() : base() { }71 public ConstantFunctionTree(Constant constant) : base(constant) {72 UpdateCachedValues();73 }74 75 private void UpdateCachedValues() {76 value = (ConstrainedDoubleData)GetLocalVariable(Constant.VALUE).Value;77 }78 79 public override double Evaluate(Dataset dataset, int sampleIndex) {80 return value.Data;81 }82 83 public override object Clone(IDictionary<Guid, object> clonedObjects) {84 ConstantFunctionTree clone = new ConstantFunctionTree();85 clonedObjects.Add(clone.Guid, clone);86 FillClone(clone, clonedObjects);87 clone.UpdateCachedValues();88 return clone;89 }90 91 public override void Populate(System.Xml.XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {92 base.Populate(node, restoredObjects);93 UpdateCachedValues();94 }95 }96 57 } -
trunk/sources/HeuristicLab.Functions/Cosinus.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Cosinus : FunctionBase {31 public sealed class Cosinus : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the cosinus of the first sub-tree."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 return Math.Cos(args[0]);44 }45 46 42 public override void Accept(IFunctionVisitor visitor) { 47 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Division.cs
r155 r229 30 30 31 31 namespace HeuristicLab.Functions { 32 public class Division : FunctionBase {32 public sealed class Division : FunctionBase { 33 33 private const double EPSILON = 10.0E-20; // if any divisor is < EPSILON return 0 34 34 … … 52 52 } 53 53 54 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {55 // (/ 3) => 1/356 // (/ 2 3) => 2/357 // (/ 3 4 5) => 3/2058 59 if(args.Length == 1) {60 double divisor = args[0];61 if(Math.Abs(divisor) < EPSILON) return 0;62 else return 1.0 / divisor;63 } else {64 double result = args[0];65 for(int i = 1; i < args.Length; i++) {66 double divisor = args[i];67 if(Math.Abs(divisor) < EPSILON) return 0.0;68 result /= divisor;69 }70 return result;71 }72 }73 74 54 public override void Accept(IFunctionVisitor visitor) { 75 55 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Equal.cs
r155 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class Equal : FunctionBase {30 public sealed class Equal : FunctionBase { 31 31 public override string Description { 32 32 get { … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 if(args[0] == args[1]) return 1.0;44 else return 0.0;45 }46 47 42 public override void Accept(IFunctionVisitor visitor) { 48 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Exponential.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Exponential : FunctionBase {31 public sealed class Exponential : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns returns exponential of the first sub-tree (power(e, x))."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 return Math.Exp(args[0]);44 }45 46 42 public override void Accept(IFunctionVisitor visitor) { 47 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/FunctionBase.cs
r189 r229 34 34 /// </summary> 35 35 public abstract class FunctionBase : OperatorBase, IFunction { 36 37 public abstract double Apply(Dataset dataset, int sampleIndex, double[] args); 36 37 public virtual double Apply(Dataset dataset, int sampleIndex, double[] args) { 38 throw new NotImplementedException(); 39 } 38 40 39 41 public virtual void Accept(IFunctionVisitor visitor) { … … 42 44 43 45 public virtual IFunctionTree GetTreeNode() { 44 return new FunctionTree(this);46 return new BakedFunctionTree(this); 45 47 } 46 48 -
trunk/sources/HeuristicLab.Functions/GreaterThan.cs
r159 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class GreaterThan : FunctionBase {30 public sealed class GreaterThan : FunctionBase { 31 31 public override string Description { 32 32 get { … … 39 39 AddConstraint(new NumberOfSubOperatorsConstraint(2, 2)); 40 40 } 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 if(args[0] > args[1]) return 1.0;44 else return 0.0;45 }46 47 41 public override void Accept(IFunctionVisitor visitor) { 48 42 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj
r185 r229 49 49 <ItemGroup> 50 50 <Compile Include="Addition.cs" /> 51 <Compile Include="And.cs" /> 51 <Compile Include="And.cs"> 52 <SubType>Code</SubType> 53 </Compile> 52 54 <Compile Include="Average.cs" /> 55 <Compile Include="BakedFunctionTree.cs" /> 56 <Compile Include="BakedTreeEvaluator.cs" /> 53 57 <Compile Include="Constant.cs" /> 54 58 <Compile Include="GreaterThan.cs" /> 55 <Compile Include="FunctionTree.cs" /> 59 <Compile Include="IfThenElse.cs"> 60 <SubType>Code</SubType> 61 </Compile> 56 62 <Compile Include="IFunctionTree.cs" /> 57 63 <Compile Include="ModelAnalyzerExporter.cs" /> 64 <Compile Include="Or.cs"> 65 <SubType>Code</SubType> 66 </Compile> 58 67 <Compile Include="ProgrammableFunction.cs" /> 59 68 <Compile Include="Equal.cs" /> … … 64 73 <DependentUpon>FunctionView.cs</DependentUpon> 65 74 </Compile> 66 <Compile Include="IfThenElse.cs" />67 75 <Compile Include="IFunctionVisitor.cs" /> 68 76 <Compile Include="LessThan.cs" /> 69 77 <Compile Include="Not.cs" /> 70 <Compile Include="Or.cs" />71 78 <Compile Include="Signum.cs" /> 72 79 <Compile Include="Logarithm.cs" /> -
trunk/sources/HeuristicLab.Functions/IfThenElse.cs
r192 r229 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 } -
trunk/sources/HeuristicLab.Functions/LessThan.cs
r155 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class LessThan : FunctionBase {30 public sealed class LessThan : FunctionBase { 31 31 public override string Description { 32 32 get { … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 if(args[0] < args[1]) return 1.0;44 else return 0.0;45 }46 47 42 public override void Accept(IFunctionVisitor visitor) { 48 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Logarithm.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Logarithm : FunctionBase {31 public sealed class Logarithm : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the natural (base e) logarithm of the first sub-tree."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 return Math.Log(args[0]);44 }45 46 42 public override void Accept(IFunctionVisitor visitor) { 47 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Multiplication.cs
r155 r229 30 30 31 31 namespace HeuristicLab.Functions { 32 public class Multiplication : FunctionBase {32 public sealed class Multiplication : FunctionBase { 33 33 public override string Description { 34 34 get { … … 46 46 } 47 47 48 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {49 // (* 3) => 350 // (* 2 3) => 651 // (* 3 4 5) => 6052 double result = 1.0;53 for(int i = 0; i < args.Length; i++) {54 result *= args[i];55 }56 return result;57 }58 59 48 public override void Accept(IFunctionVisitor visitor) { 60 49 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Not.cs
r155 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class Not : FunctionBase {30 public sealed class Not : FunctionBase { 31 31 public override string Description { 32 32 get { … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 double result = Math.Round(args[0]);44 if(result == 0.0) return 1.0;45 else if(result == 1.0) return 0.0;46 else return double.NaN;47 }48 49 42 public override void Accept(IFunctionVisitor visitor) { 50 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Or.cs
r192 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class Or : FunctionBase {30 public sealed class Or : FunctionBase { 31 31 public override string Description { 32 32 get { … … 41 41 } 42 42 43 public override IFunctionTree GetTreeNode() {44 return new OrFunctionTree(this);45 }46 // or is a special form and can't be applied47 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {48 throw new NotImplementedException();49 }50 43 public override void Accept(IFunctionVisitor visitor) { 51 44 visitor.Visit(this); 52 45 } 53 46 } 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.063 else if(result != 0.0) return double.NaN;64 }65 // all sub-trees evaluated to 0.0 (false) return false66 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 }76 47 } -
trunk/sources/HeuristicLab.Functions/Power.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Power : FunctionBase {31 public sealed class Power : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the result of the first sub-tree to the power of the second sub-tree (power(x, y))."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 return Math.Pow(args[0], args[1]);44 }45 46 42 public override void Accept(IFunctionVisitor visitor) { 47 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/ProgrammableFunction.cs
r189 r229 36 36 37 37 namespace HeuristicLab.Functions { 38 public class ProgrammableFunction : ProgrammableOperator, IFunction {38 public sealed class ProgrammableFunction : ProgrammableOperator, IFunction { 39 39 private MethodInfo applyMethod; 40 40 public ProgrammableFunction() … … 120 120 121 121 public IFunctionTree GetTreeNode() { 122 return new ProgrammableFunctionTree(this);122 return new BakedFunctionTree(this); 123 123 } 124 124 … … 187 187 } 188 188 189 class ProgrammableFunctionTree : FunctionTree {190 private ProgrammableFunction progFun;191 public ProgrammableFunctionTree() : base() { }192 public ProgrammableFunctionTree(ProgrammableFunction progFun) : base(progFun) {193 this.progFun = progFun;194 }195 public override double Evaluate(Dataset dataset, int sampleIndex) {196 // evaluate sub-trees197 double[] evaluationResults = new double[SubTrees.Count];198 for(int subTree = 0; subTree < SubTrees.Count; subTree++) {199 evaluationResults[subTree] = SubTrees[subTree].Evaluate(dataset, sampleIndex);200 }201 202 // collect parameters203 object[] parameters = new object[LocalVariables.Count + 3];204 parameters[0] = dataset;205 parameters[1] = sampleIndex;206 int i = 2;207 // all local variables are available in the custom function208 foreach(IVariable variable in LocalVariables) {209 parameters[i] = variable;210 i++;211 }212 parameters[i] = evaluationResults;213 return progFun.Call(parameters);214 }215 }189 //class ProgrammableFunctionTree : FunctionTree { 190 // private ProgrammableFunction progFun; 191 // public ProgrammableFunctionTree() : base() { } 192 // public ProgrammableFunctionTree(ProgrammableFunction progFun) : base(progFun) { 193 // this.progFun = progFun; 194 // } 195 // public override double Evaluate(Dataset dataset, int sampleIndex) { 196 // // evaluate sub-trees 197 // double[] evaluationResults = new double[SubTrees.Count]; 198 // for(int subTree = 0; subTree < SubTrees.Count; subTree++) { 199 // evaluationResults[subTree] = SubTrees[subTree].Evaluate(dataset, sampleIndex); 200 // } 201 202 // // collect parameters 203 // object[] parameters = new object[LocalVariables.Count + 3]; 204 // parameters[0] = dataset; 205 // parameters[1] = sampleIndex; 206 // int i = 2; 207 // // all local variables are available in the custom function 208 // foreach(IVariable variable in LocalVariables) { 209 // parameters[i] = variable; 210 // i++; 211 // } 212 // parameters[i] = evaluationResults; 213 // return progFun.Call(parameters); 214 // } 215 //} 216 216 } -
trunk/sources/HeuristicLab.Functions/Signum.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Signum : FunctionBase {31 public sealed class Signum : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the signum of the first sub-tree."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 double value = args[0];44 if(value < 0) return -1;45 if(value > 0) return 1;46 return 0;47 }48 49 42 public override void Accept(IFunctionVisitor visitor) { 50 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Sinus.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Sinus : FunctionBase {31 public sealed class Sinus : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the sinus of the first sub-tree."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 return Math.Sin(args[0]);44 }45 46 42 public override void Accept(IFunctionVisitor visitor) { 47 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Sqrt.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Sqrt : FunctionBase {31 public sealed class Sqrt : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the square root of the first sub-tree."; } … … 40 40 } 41 41 42 43 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {44 return Math.Sqrt(args[0]);45 }46 47 42 public override void Accept(IFunctionVisitor visitor) { 48 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Substraction.cs
r155 r229 30 30 31 31 namespace HeuristicLab.Functions { 32 public class Substraction : FunctionBase {32 public sealed class Substraction : FunctionBase { 33 33 public override string Description { 34 34 get { … … 46 46 } 47 47 48 49 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {50 if(args.Length == 1) {51 return -args[0];52 } else {53 double result = args[0];54 for(int i = 1; i < args.Length; i++) {55 result -= args[i];56 }57 return result;58 }59 }60 61 48 public override void Accept(IFunctionVisitor visitor) { 62 49 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Tangens.cs
r155 r229 29 29 30 30 namespace HeuristicLab.Functions { 31 public class Tangens : FunctionBase {31 public sealed class Tangens : FunctionBase { 32 32 public override string Description { 33 33 get { return "Returns the tangens of the first sub-tree."; } … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 return Math.Tan(args[0]);44 }45 46 42 public override void Accept(IFunctionVisitor visitor) { 47 43 visitor.Visit(this); -
trunk/sources/HeuristicLab.Functions/Variable.cs
r193 r229 30 30 31 31 namespace HeuristicLab.Functions { 32 public class Variable : FunctionBase {32 public sealed class Variable : FunctionBase { 33 33 34 34 public const string WEIGHT = "Weight"; … … 37 37 38 38 public override string Description { 39 get { return @"Variable reads a value from a dataset, multiplies that value with a given factor and returns the result. 39 get { 40 return @"Variable reads a value from a dataset, multiplies that value with a given factor and returns the result. 40 41 The variable 'SampleOffset' can be used to read a value from previous or following rows. 41 The index of the row that is actually read is SampleIndex+SampleOffset)."; } 42 The index of the row that is actually read is SampleIndex+SampleOffset)."; 43 } 42 44 } 43 45 … … 68 70 } 69 71 70 public override IFunctionTree GetTreeNode() {71 return new VariableFunctionTree(this);72 }73 74 // can't apply a variable75 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {76 throw new NotSupportedException();77 }78 79 72 public override void Accept(IFunctionVisitor visitor) { 80 73 visitor.Visit(this); 81 74 } 82 75 } 83 class VariableFunctionTree : FunctionTree {84 private ConstrainedDoubleData weight;85 private ConstrainedIntData index;86 private ConstrainedIntData offset;87 88 public VariableFunctionTree() : base() { }89 public VariableFunctionTree(Variable variable) : base(variable) {90 UpdateCachedValues();91 }92 93 protected void UpdateCachedValues() {94 weight = (ConstrainedDoubleData)GetLocalVariable(Variable.WEIGHT).Value;95 index = (ConstrainedIntData)GetLocalVariable(Variable.INDEX).Value;96 offset = (ConstrainedIntData)GetLocalVariable(Variable.OFFSET).Value;97 }98 99 public override double Evaluate(Dataset dataset, int sampleIndex) {100 if(sampleIndex + offset.Data < 0 || sampleIndex + offset.Data >= dataset.Rows) return double.NaN;101 return weight.Data * dataset.GetValue(sampleIndex + offset.Data, index.Data);102 }103 104 public override object Clone(IDictionary<Guid, object> clonedObjects) {105 VariableFunctionTree clone = new VariableFunctionTree();106 clonedObjects.Add(clone.Guid, clone);107 FillClone(clone, clonedObjects);108 clone.UpdateCachedValues();109 return clone;110 }111 112 public override void Populate(System.Xml.XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {113 base.Populate(node, restoredObjects);114 UpdateCachedValues();115 }116 }117 76 } -
trunk/sources/HeuristicLab.Functions/Xor.cs
r155 r229 28 28 29 29 namespace HeuristicLab.Functions { 30 public class Xor : FunctionBase {30 public sealed class Xor : FunctionBase { 31 31 public override string Description { 32 32 get { … … 40 40 } 41 41 42 public override double Apply(Dataset dataset, int sampleIndex, double[] args) {43 if(args[0] == 0.0 && args[1] == 0.0) return 0.0;44 if(args[0] * args[1] == 0.0) return 1.0;45 return 0.0;46 }47 48 42 public override void Accept(IFunctionVisitor visitor) { 49 43 visitor.Visit(this);
Note: See TracChangeset
for help on using the changeset viewer.