Changeset 642 for trunk/sources
- Timestamp:
- 10/11/08 18:35:45 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Functions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs
r523 r642 40 40 public int arity; 41 41 public int symbol; 42 public IFunction function; 42 43 } 43 44 … … 79 80 break; 80 81 } 82 case EvaluatorSymbolTable.UNKNOWN: { 83 instr.function = f.functionType; 84 break; 85 } 81 86 } 82 87 return instr; … … 93 98 int i = 1; 94 99 while(i > 0) { 95 i +=codeArr[PC++].arity;100 i += codeArr[PC++].arity; 96 101 i--; 97 102 } … … 247 252 return Math.Abs(x - y); 248 253 } 249 case EvaluatorSymbolTable.UNKNOWN: 254 case EvaluatorSymbolTable.UNKNOWN: { // evaluate functions which are not statically defined directly 255 return currInstr.function.Apply(); 256 } 250 257 default: { 251 258 throw new NotImplementedException(); -
trunk/sources/HeuristicLab.Functions/FunctionBase.cs
r529 r642 42 42 private int maxArity = -1; 43 43 44 public virtual double Apply( Dataset dataset, int sampleIndex, double[] args) {44 public virtual double Apply() { 45 45 throw new NotImplementedException(); 46 46 } -
trunk/sources/HeuristicLab.Functions/IFunction.cs
r525 r642 29 29 public interface IFunction : IOperator { 30 30 IFunctionTree GetTreeNode(); 31 double Apply( Dataset dataset, int sampleIndex, double[] args);31 double Apply(); 32 32 void Accept(IFunctionVisitor visitor); 33 33 IList<IFunction> AllowedSubFunctions(int index); -
trunk/sources/HeuristicLab.Functions/SymbolTable.cs
r365 r642 28 28 29 29 namespace HeuristicLab.Functions { 30 class EvaluatorSymbolTable : StorableBase {30 class EvaluatorSymbolTable : StorableBase { 31 31 public const int ADDITION = 1; 32 32 public const int AND = 2; … … 55 55 public const int UNKNOWN = 24; 56 56 57 private static Dictionary<Type, int> staticTypes = new Dictionary<Type, int>();57 private static Dictionary<Type, int> staticTypes = new Dictionary<Type, int>(); 58 58 59 59 // needs to be public for persistence mechanism (Activator.CreateInstance needs empty constructor) 60 static EvaluatorSymbolTable 60 static EvaluatorSymbolTable() { 61 61 staticTypes = new Dictionary<Type, int>(); 62 62 staticTypes[typeof(Addition)] = ADDITION; … … 87 87 88 88 internal static int MapFunction(IFunction function) { 89 return staticTypes[function.GetType()]; 89 if(staticTypes.ContainsKey(function.GetType())) return staticTypes[function.GetType()]; 90 else return UNKNOWN; 90 91 } 91 92 }
Note: See TracChangeset
for help on using the changeset viewer.