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