Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Functions/SymbolTable.cs @ 320

Last change on this file since 320 was 319, checked in by gkronber, 16 years ago

simplified symbol-table mechanism (ticket #168)

File size: 3.3 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;
28
29namespace HeuristicLab.Functions {
30  class EvaluatorSymbolTable : StorableBase{
31    public const int ADDITION = 1;
32    public const int AND = 2;
33    public const int AVERAGE = 3;
34    public const int CONSTANT = 4;
35    public const int COSINUS = 5;
36    public const int DIVISION = 6;
37    public const int EQU = 7;
38    public const int EXP = 8;
39    public const int GT = 9;
40    public const int IFTE = 10;
41    public const int LT = 11;
42    public const int LOG = 12;
43    public const int MULTIPLICATION = 13;
44    public const int NOT = 14;
45    public const int OR = 15;
46    public const int POWER = 16;
47    public const int SIGNUM = 17;
48    public const int SINUS = 18;
49    public const int SQRT = 19;
50    public const int SUBTRACTION = 20;
51    public const int TANGENS = 21;
52    public const int VARIABLE = 22;
53    public const int XOR = 23;
54    public const int UNKNOWN = 24;
55
56    private static Dictionary<Type, int> staticTypes = new Dictionary<Type,int>();
57
58    // needs to be public for persistence mechanism (Activator.CreateInstance needs empty constructor)
59    static EvaluatorSymbolTable () {
60      staticTypes = new Dictionary<Type, int>();
61      staticTypes[typeof(Addition)] = ADDITION;
62      staticTypes[typeof(And)] = AND;
63      staticTypes[typeof(Average)] = AVERAGE;
64      staticTypes[typeof(Constant)] = CONSTANT;
65      staticTypes[typeof(Cosinus)] = COSINUS;
66      staticTypes[typeof(Division)] = DIVISION;
67      staticTypes[typeof(Equal)] = EQU;
68      staticTypes[typeof(Exponential)] = EXP;
69      staticTypes[typeof(GreaterThan)] = GT;
70      staticTypes[typeof(IfThenElse)] = IFTE;
71      staticTypes[typeof(LessThan)] = LT;
72      staticTypes[typeof(Logarithm)] = LOG;
73      staticTypes[typeof(Multiplication)] = MULTIPLICATION;
74      staticTypes[typeof(Not)] = NOT;
75      staticTypes[typeof(Or)] = OR;
76      staticTypes[typeof(Power)] = POWER;
77      staticTypes[typeof(Signum)] = SIGNUM;
78      staticTypes[typeof(Sinus)] = SINUS;
79      staticTypes[typeof(Sqrt)] = SQRT;
80      staticTypes[typeof(Subtraction)] = SUBTRACTION;
81      staticTypes[typeof(Tangens)] = TANGENS;
82      staticTypes[typeof(Variable)] = VARIABLE;
83      staticTypes[typeof(Xor)] = XOR;
84    }
85
86    internal static int MapFunction(IFunction function) {
87      return staticTypes[function.GetType()];
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.