Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/11/08 18:35:45 (16 years ago)
Author:
gkronber
Message:

fixed #169 (Possibility to extend the set of available functions for GP via plugins)

Location:
trunk/sources/HeuristicLab.Functions
Files:
4 edited

Legend:

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

    r523 r642  
    4040      public int arity;
    4141      public int symbol;
     42      public IFunction function;
    4243    }
    4344
     
    7980            break;
    8081          }
     82        case EvaluatorSymbolTable.UNKNOWN: {
     83            instr.function = f.functionType;
     84            break;
     85          }
    8186      }
    8287      return instr;
     
    9398      int i = 1;
    9499      while(i > 0) {
    95         i+=codeArr[PC++].arity;
     100        i += codeArr[PC++].arity;
    96101        i--;
    97102      }
     
    247252            return Math.Abs(x - y);
    248253          }
    249         case EvaluatorSymbolTable.UNKNOWN:
     254        case EvaluatorSymbolTable.UNKNOWN: { // evaluate functions which are not statically defined directly
     255            return currInstr.function.Apply();
     256          }
    250257        default: {
    251258            throw new NotImplementedException();
  • trunk/sources/HeuristicLab.Functions/FunctionBase.cs

    r529 r642  
    4242    private int maxArity = -1;
    4343
    44     public virtual double Apply(Dataset dataset, int sampleIndex, double[] args) {
     44    public virtual double Apply() {
    4545      throw new NotImplementedException();
    4646    }
  • trunk/sources/HeuristicLab.Functions/IFunction.cs

    r525 r642  
    2929  public interface IFunction : IOperator {
    3030    IFunctionTree GetTreeNode();
    31     double Apply(Dataset dataset, int sampleIndex, double[] args);
     31    double Apply();
    3232    void Accept(IFunctionVisitor visitor);
    3333    IList<IFunction> AllowedSubFunctions(int index);
  • trunk/sources/HeuristicLab.Functions/SymbolTable.cs

    r365 r642  
    2828
    2929namespace HeuristicLab.Functions {
    30   class EvaluatorSymbolTable : StorableBase{
     30  class EvaluatorSymbolTable : StorableBase {
    3131    public const int ADDITION = 1;
    3232    public const int AND = 2;
     
    5555    public const int UNKNOWN = 24;
    5656
    57     private static Dictionary<Type, int> staticTypes = new Dictionary<Type,int>();
     57    private static Dictionary<Type, int> staticTypes = new Dictionary<Type, int>();
    5858
    5959    // needs to be public for persistence mechanism (Activator.CreateInstance needs empty constructor)
    60     static EvaluatorSymbolTable () {
     60    static EvaluatorSymbolTable() {
    6161      staticTypes = new Dictionary<Type, int>();
    6262      staticTypes[typeof(Addition)] = ADDITION;
     
    8787
    8888    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;
    9091    }
    9192  }
Note: See TracChangeset for help on using the changeset viewer.