Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.2/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs @ 9015

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

Removed max. and min. time offset constraints as algorithm parameters and from all engines. The time constraints were added to the relevant terminal symbols (variable & differential) instead. The time offset constraint can be changed by editing the symbols in the function library. #880 (Max and min time offsets for variable symbols are not set correctly by FunctionLibraryInjectors)

File size: 3.4 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.Collections.Generic;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.GP.Interfaces;
26using HeuristicLab.GP;
27
28namespace HeuristicLab.GP.StructureIdentification {
29  [SymbolicRegressionFunctionLibraryInjector]
30  public class SimpleFunctionLibraryInjector : FunctionLibraryInjectorBase {
31    public override string Description {
32      get { return @"Injects a simple function library for regression and classification problems."; }
33    }
34
35    protected override FunctionLibrary CreateFunctionLibrary() {
36      return Create();
37    }
38
39    public static FunctionLibrary Create() {
40      FunctionLibrary functionLibrary = new FunctionLibrary();
41
42      Variable variable = new Variable();
43      Constant constant = new Constant();
44      Differential differential = new Differential();
45      Addition addition = new Addition();
46      Cosinus cosinus = new Cosinus();
47      Division division = new Division();
48      Exponential exponential = new Exponential();
49      Logarithm logarithm = new Logarithm();
50      Multiplication multiplication = new Multiplication();
51      Power power = new Power();
52      Sinus sinus = new Sinus();
53      Sqrt sqrt = new Sqrt();
54      Subtraction subtraction = new Subtraction();
55      Tangens tangens = new Tangens();
56
57      List<IFunction> valueNodes = new List<IFunction>() {
58        differential, variable, constant
59      };
60      List<IFunction> arithmeticFunctions = new List<IFunction>() {
61      addition, division, multiplication, subtraction,
62      };
63
64      List<IFunction> complexFunctions = new List<IFunction>() {
65        cosinus, exponential, logarithm, power, sinus, sqrt, tangens
66      };
67
68      List<IFunction> allFunctions = new List<IFunction>();
69      allFunctions.AddRange(arithmeticFunctions);
70      allFunctions.AddRange(complexFunctions);
71      allFunctions.AddRange(valueNodes);
72
73      SetAllowedSubOperators(addition, allFunctions);
74      SetAllowedSubOperators(division, allFunctions);
75      SetAllowedSubOperators(multiplication, allFunctions);
76      SetAllowedSubOperators(subtraction, allFunctions);
77
78      SetAllowedSubOperators(cosinus, valueNodes);
79      SetAllowedSubOperators(exponential, valueNodes);
80      SetAllowedSubOperators(logarithm, valueNodes);
81      SetAllowedSubOperators(power, valueNodes);
82      SetAllowedSubOperators(sinus, valueNodes);
83      SetAllowedSubOperators(sqrt, valueNodes);
84      SetAllowedSubOperators(tangens, valueNodes);
85
86      allFunctions.ForEach(x => functionLibrary.AddFunction(x));
87
88      return functionLibrary;
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.