Changeset 17902 for trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/IntervalArithmeticGrammar.cs
- Timestamp:
- 03/16/21 14:23:41 (3 years ago)
- Location:
- trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/IntervalArithmeticGrammar.cs
r17884 r17902 1 using System.Collections.Generic; 1 #region License Information 2 3 /* HeuristicLab 4 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 * 6 * This file is part of HeuristicLab. 7 * 8 * HeuristicLab is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * HeuristicLab is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #endregion 23 using System.Collections.Generic; 2 24 using System.Linq; 3 25 using HEAL.Attic; … … 8 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 9 31 [StorableType("5A2300A0-D0FC-4F2D-B910-F86384FE9052")] 10 [Item("IntervalArithmeticGrammar", "Represents a grammar for interval arithmetic ")]32 [Item("IntervalArithmeticGrammar", "Represents a grammar for interval arithmetic which includes linear scaling parts implicitly.")] 11 33 public class IntervalArithmeticGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 12 34 public IntervalArithmeticGrammar() : base(ItemAttribute.GetName(typeof(IntervalArithmeticGrammar)), … … 35 57 var cos = new Cosine(); 36 58 var tan = new Tangent(); 59 var tanh = new HyperbolicTangent(); 37 60 var log = new Logarithm(); 38 var pow = new Power();61 var exp = new Exponential(); 39 62 var square = new Square(); 40 var root = new Root();41 63 var sqrt = new SquareRoot(); 42 var exp = new Exponential(); 43 var tanh = new HyperbolicTangent(); 64 var cube = new Cube(); 65 var cbrt = new CubeRoot(); 66 var abs = new Absolute(); 67 var aq = new AnalyticQuotient(); 44 68 var constant = new Constant(); 45 var aq = new AnalyticQuotient();46 69 constant.MinValue = -20; 47 70 constant.MaxValue = 20; … … 51 74 52 75 //Special symbols 53 var offset = new Addition { Name = "Offset"};54 var scaling = new Multiplication { Name = "Scaling"};76 var offset = new Addition { Name = "Offset" }; 77 var scaling = new Multiplication { Name = "Scaling" }; 55 78 //all other symbols 56 79 var allSymbols = new List<Symbol> { 57 add, sub, mul, div, constant, variableSymbol, sin, cos, tan, log, pow, square, root, sqrt, exp,58 tanh, aq 80 add, sub, mul, div, constant, variableSymbol, sin, cos, tan, log, square, sqrt, cube, cbrt, exp, 81 tanh, aq, abs 59 82 }; 60 83 61 var arithmeticSymbols = new List<Symbol> {add, sub, mul, div}; 62 var trigonometricSymbols = new List<Symbol> {sin, cos, tan, tanh}; 63 var exponentialAndLogarithmicSymbols = new List<Symbol> {exp, log}; 64 var powerSymbols = new List<Symbol> {square, pow, sqrt, root}; 65 var specialSymbols = new List<Symbol> {aq}; 66 var realValueSymbols = new List<Symbol> 67 {add, sub, mul, div, sin, cos, tan, tanh, exp, log, variableSymbol, constant, aq}; 84 var bivariateFuncs = new List<Symbol> { add, sub, mul, div, aq }; 85 var univariateFuncs = new List<Symbol> { sin, cos, tan, tanh, exp, log, abs, square, cube, sqrt, cbrt }; 86 var realValueSymbols = new List<Symbol> { 87 add, sub, mul, div, sin, cos, tan, tanh, exp, log, aq, abs, square, cube, sqrt, cbrt, 88 variableSymbol, constant, 89 }; 68 90 69 91 … … 76 98 #region define subtree count for special symbols 77 99 78 foreach (var symb in arithmeticSymbols) SetSubtreeCount(symb, 2, 2);100 foreach (var symb in bivariateFuncs) SetSubtreeCount(symb, 2, 2); 79 101 80 foreach (var symb in trigonometricSymbols) SetSubtreeCount(symb, 1, 1); 81 82 foreach (var symb in exponentialAndLogarithmicSymbols) SetSubtreeCount(symb, 1, 1); 102 foreach (var symb in univariateFuncs) SetSubtreeCount(symb, 1, 1); 83 103 84 104 SetSubtreeCount(offset, 2, 2); 85 105 SetSubtreeCount(scaling, 2, 2); 86 SetSubtreeCount(pow, 2, 2);87 SetSubtreeCount(root, 2, 2);88 SetSubtreeCount(square, 1, 1);89 SetSubtreeCount(sqrt, 1, 1);90 SetSubtreeCount(aq, 2, 2);91 106 92 107 #endregion … … 109 124 } 110 125 111 //define childs for power symbols112 foreach (var symb in powerSymbols) {113 AddAllowedChildSymbol(symb, variableSymbol, 0);114 AddAllowedChildSymbol(symb, constant, 1);115 }116 117 //define child for sqrt and square118 foreach (var c in realValueSymbols) {119 AddAllowedChildSymbol(square, c, 0);120 AddAllowedChildSymbol(sqrt, c, 0);121 }122 123 //define child for aq124 foreach (var c in realValueSymbols) {125 AddAllowedChildSymbol(aq, c, 0);126 AddAllowedChildSymbol(aq, c, 1);127 }128 129 126 #endregion 130 127 131 Symbols.First(s => s is Power).Enabled = false;132 Symbols.First(s => s is Root).Enabled = false;133 Symbols.First(s => s is A nalyticQuotient).Enabled = false;128 Symbols.First(s => s is Cube).Enabled = false; 129 Symbols.First(s => s is CubeRoot).Enabled = false; 130 Symbols.First(s => s is Absolute).Enabled = false; 134 131 } 135 132 }
Note: See TracChangeset
for help on using the changeset viewer.