Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/21 14:23:41 (3 years ago)
Author:
gkronber
Message:

#3073 merged reintegration branch to trunk

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic

  • 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
     23using System.Collections.Generic;
    224using System.Linq;
    325using HEAL.Attic;
     
    830namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    931  [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.")]
    1133  public class IntervalArithmeticGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar {
    1234    public IntervalArithmeticGrammar() : base(ItemAttribute.GetName(typeof(IntervalArithmeticGrammar)),
     
    3557      var cos = new Cosine();
    3658      var tan = new Tangent();
     59      var tanh = new HyperbolicTangent();
    3760      var log = new Logarithm();
    38       var pow = new Power();
     61      var exp = new Exponential();
    3962      var square = new Square();
    40       var root = new Root();
    4163      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();
    4468      var constant = new Constant();
    45       var aq = new AnalyticQuotient();
    4669      constant.MinValue = -20;
    4770      constant.MaxValue = 20;
     
    5174
    5275      //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" };
    5578      //all other symbols
    5679      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
    5982      };
    6083
    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        };
    6890
    6991
     
    7698      #region define subtree count for special symbols
    7799
    78       foreach (var symb in arithmeticSymbols) SetSubtreeCount(symb, 2, 2);
     100      foreach (var symb in bivariateFuncs) SetSubtreeCount(symb, 2, 2);
    79101
    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);
    83103
    84104      SetSubtreeCount(offset, 2, 2);
    85105      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);
    91106
    92107      #endregion
     
    109124      }
    110125
    111       //define childs for power symbols
    112       foreach (var symb in powerSymbols) {
    113         AddAllowedChildSymbol(symb, variableSymbol, 0);
    114         AddAllowedChildSymbol(symb, constant, 1);
    115       }
    116 
    117       //define child for sqrt and square
    118       foreach (var c in realValueSymbols) {
    119         AddAllowedChildSymbol(square, c, 0);
    120         AddAllowedChildSymbol(sqrt, c, 0);
    121       }
    122 
    123       //define child for aq
    124       foreach (var c in realValueSymbols) {
    125         AddAllowedChildSymbol(aq, c, 0);
    126         AddAllowedChildSymbol(aq, c, 1);
    127       }
    128 
    129126      #endregion
    130127
    131       Symbols.First(s => s is Power).Enabled = false;
    132       Symbols.First(s => s is Root).Enabled = false;
    133       Symbols.First(s => s is AnalyticQuotient).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;
    134131    }
    135132  }
Note: See TracChangeset for help on using the changeset viewer.