Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification/3.3/SymbolTable.cs @ 2210

Last change on this file since 2210 was 2210, checked in by gkronber, 15 years ago

GP Refactoring #713

  • introduced a plugin for GP interfaces
  • created a new interface IGeneticProgrammingModel which represents GP models in HL scopes instead of IFunctionTree
  • changed interfaces IFunction and IFunctionTree
  • moved some files to new directories (general housekeeping)
  • changed all GP operators and engines to work with IGeneticProgrammingModels
  • removed parameters TreeSize and TreeHeight in all GP operators
  • changed parameter OperatorLibrary to FunctionLibrary in all GP operators
File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28using HeuristicLab.GP.Interfaces;
29
30namespace HeuristicLab.GP.StructureIdentification {
31  class EvaluatorSymbolTable : StorableBase {
32    public const byte ADDITION = 1;
33    public const byte AND = 2;
34    public const byte AVERAGE = 3;
35    public const byte CONSTANT = 4;
36    public const byte COSINUS = 5;
37    public const byte DIFFERENTIAL = 25;
38    public const byte DIVISION = 6;
39    public const byte EQU = 7;
40    public const byte EXP = 8;
41    public const byte GT = 9;
42    public const byte IFTE = 10;
43    public const byte LT = 11;
44    public const byte LOG = 12;
45    public const byte MULTIPLICATION = 13;
46    public const byte NOT = 14;
47    public const byte OR = 15;
48    public const byte POWER = 16;
49    public const byte SIGNUM = 17;
50    public const byte SINUS = 18;
51    public const byte SQRT = 19;
52    public const byte SUBTRACTION = 20;
53    public const byte TANGENS = 21;
54    public const byte VARIABLE = 22;
55    public const byte XOR = 23;
56    public const byte UNKNOWN = 24;
57
58    private static Dictionary<Type, byte> staticTypes = new Dictionary<Type, byte>();
59
60    // needs to be public for persistence mechanism (Activator.CreateInstance needs empty constructor)
61    static EvaluatorSymbolTable() {
62      staticTypes = new Dictionary<Type, byte>();
63      staticTypes[typeof(Addition)] = ADDITION;
64      staticTypes[typeof(And)] = AND;
65      staticTypes[typeof(Average)] = AVERAGE;
66      staticTypes[typeof(Constant)] = CONSTANT;
67      staticTypes[typeof(Cosinus)] = COSINUS;
68      staticTypes[typeof(Division)] = DIVISION;
69      staticTypes[typeof(Equal)] = EQU;
70      staticTypes[typeof(Exponential)] = EXP;
71      staticTypes[typeof(GreaterThan)] = GT;
72      staticTypes[typeof(IfThenElse)] = IFTE;
73      staticTypes[typeof(LessThan)] = LT;
74      staticTypes[typeof(Logarithm)] = LOG;
75      staticTypes[typeof(Multiplication)] = MULTIPLICATION;
76      staticTypes[typeof(Not)] = NOT;
77      staticTypes[typeof(Or)] = OR;
78      staticTypes[typeof(Power)] = POWER;
79      staticTypes[typeof(Signum)] = SIGNUM;
80      staticTypes[typeof(Sinus)] = SINUS;
81      staticTypes[typeof(Sqrt)] = SQRT;
82      staticTypes[typeof(Subtraction)] = SUBTRACTION;
83      staticTypes[typeof(Tangens)] = TANGENS;
84      staticTypes[typeof(Variable)] = VARIABLE;
85      staticTypes[typeof(Xor)] = XOR;
86      staticTypes[typeof(Differential)] = DIFFERENTIAL;
87    }
88
89    internal static byte MapFunction(IFunction function) {
90      if(staticTypes.ContainsKey(function.GetType())) return staticTypes[function.GetType()];
91      else return UNKNOWN;
92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.