private void Initialize() {
      #region symbol declaration
      var add = new Addition();
      var sub = new Subtraction();
      var mul = new Multiplication();
      var div = new Division();
      var mean = new Average();
      var sin = new Sine();
      var cos = new Cosine();
      var tan = new Tangent();
      var log = new Logarithm();
      var pow = new Power();
      var square = new Square();
      var root = new Root();
      var sqrt = new SquareRoot();
      var exp = new Exponential();

      var airyA = new AiryA();
      var airyB = new AiryB();
      var bessel = new Bessel();
      var cosineIntegral = new CosineIntegral();
      var dawson = new Dawson();
      var erf = new Erf();
      var expIntegralEi = new ExponentialIntegralEi();
      var fresnelCosineIntegral = new FresnelCosineIntegral();
      var fresnelSineIntegral = new FresnelSineIntegral();
      var gamma = new Gamma();
      var hypCosineIntegral = new HyperbolicCosineIntegral();
      var hypSineIntegral = new HyperbolicSineIntegral();
      var norm = new Norm();
      var psi = new Psi();
      var sineIntegral = new SineIntegral();

      var @if = new IfThenElse();
      var gt = new GreaterThan();
      var lt = new LessThan();
      var and = new And();
      var or = new Or();
      var not = new Not();
      var xor = new Xor();
      var variableCondition = new VariableCondition();

      var timeLag = new TimeLag();
      var integral = new Integral();
      var derivative = new Derivative();

      var constant = new Constant();
      constant.MinValue = -20;
      constant.MaxValue = 20;
      var variableSymbol = new Variable();
      var laggedVariable = new LaggedVariable();
      var autoregressiveVariable = new AutoregressiveTargetVariable();
      #endregion

      #region group symbol declaration
      var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean });
      var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan });
      var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log });
      var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, 
        fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral});
      var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol });
      var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols });

      var powerSymbols = new GroupSymbol(PowerFunctionsName, new List<ISymbol> { square, pow, sqrt, root });

      var conditionSymbols = new GroupSymbol(ConditionsName, new List<ISymbol> { @if, variableCondition });
      var comparisonSymbols = new GroupSymbol(ComparisonsName, new List<ISymbol> { gt, lt });
      var booleanOperationSymbols = new GroupSymbol(BooleanOperatorsName, new List<ISymbol> { and, or, not, xor });
      var conditionalSymbols = new GroupSymbol(ConditionalSymbolsName, new List<ISymbol> { conditionSymbols, comparisonSymbols, booleanOperationSymbols });

      var timeSeriesSymbols = new GroupSymbol(TimeSeriesSymbolsName, new List<ISymbol> { timeLag, integral, derivative, laggedVariable, autoregressiveVariable });
      #endregion

      AddSymbol(realValuedSymbols);
      AddSymbol(powerSymbols);
      AddSymbol(conditionalSymbols);
      AddSymbol(timeSeriesSymbols);

      #region subtree count configuration
      SetSubtreeCount(arithmeticSymbols, 2, 2);
      SetSubtreeCount(trigonometricSymbols, 1, 1);
      SetSubtreeCount(pow, 2, 2);
      SetSubtreeCount(root, 2, 2);
      SetSubtreeCount(square, 1, 1);
      SetSubtreeCount(sqrt, 1, 1);
      SetSubtreeCount(exponentialAndLogarithmicSymbols, 1, 1);
      SetSubtreeCount(specialFunctions, 1, 1);
      SetSubtreeCount(terminalSymbols, 0, 0);

      SetSubtreeCount(@if, 3, 3);
      SetSubtreeCount(variableCondition, 2, 2);
      SetSubtreeCount(comparisonSymbols, 2, 2);
      SetSubtreeCount(and, 2, 2);
      SetSubtreeCount(or, 2, 2);
      SetSubtreeCount(not, 1, 1);
      SetSubtreeCount(xor, 2, 2);

      SetSubtreeCount(timeLag, 1, 1);
      SetSubtreeCount(integral, 1, 1);
      SetSubtreeCount(derivative, 1, 1);
      SetSubtreeCount(laggedVariable, 0, 0);
      SetSubtreeCount(autoregressiveVariable, 0, 0);
      #endregion

      #region allowed child symbols configuration
      AddAllowedChildSymbol(StartSymbol, realValuedSymbols);
      AddAllowedChildSymbol(StartSymbol, powerSymbols);
      AddAllowedChildSymbol(StartSymbol, conditionSymbols);
      AddAllowedChildSymbol(StartSymbol, timeSeriesSymbols);
      AddAllowedChildSymbol(StartSymbol, specialFunctions);

      AddAllowedChildSymbol(DefunSymbol, realValuedSymbols);
      AddAllowedChildSymbol(DefunSymbol, powerSymbols);
      AddAllowedChildSymbol(DefunSymbol, conditionSymbols);
      AddAllowedChildSymbol(DefunSymbol, timeSeriesSymbols);
      AddAllowedChildSymbol(DefunSymbol, specialFunctions);

      AddAllowedChildSymbol(realValuedSymbols, realValuedSymbols);
      AddAllowedChildSymbol(realValuedSymbols, powerSymbols);
      AddAllowedChildSymbol(realValuedSymbols, conditionSymbols);
      AddAllowedChildSymbol(realValuedSymbols, timeSeriesSymbols);
      AddAllowedChildSymbol(realValuedSymbols, specialFunctions);

      AddAllowedChildSymbol(powerSymbols, variableSymbol, 0);
      AddAllowedChildSymbol(powerSymbols, laggedVariable, 0);
      AddAllowedChildSymbol(powerSymbols, autoregressiveVariable, 0);
      AddAllowedChildSymbol(powerSymbols, constant, 1);

      AddAllowedChildSymbol(square, realValuedSymbols, 0);
      AddAllowedChildSymbol(square, conditionSymbols, 0);
      AddAllowedChildSymbol(square, timeSeriesSymbols, 0);

      AddAllowedChildSymbol(sqrt, realValuedSymbols, 0);
      AddAllowedChildSymbol(sqrt, conditionSymbols, 0);
      AddAllowedChildSymbol(sqrt, timeSeriesSymbols, 0);

      AddAllowedChildSymbol(@if, comparisonSymbols, 0);
      AddAllowedChildSymbol(@if, booleanOperationSymbols, 0);
      AddAllowedChildSymbol(@if, conditionSymbols, 1);
      AddAllowedChildSymbol(@if, realValuedSymbols, 1);
      AddAllowedChildSymbol(@if, powerSymbols, 1);
      AddAllowedChildSymbol(@if, timeSeriesSymbols, 1);
      AddAllowedChildSymbol(@if, conditionSymbols, 2);
      AddAllowedChildSymbol(@if, realValuedSymbols, 2);
      AddAllowedChildSymbol(@if, powerSymbols, 2);
      AddAllowedChildSymbol(@if, timeSeriesSymbols, 2);

      AddAllowedChildSymbol(booleanOperationSymbols, comparisonSymbols);
      AddAllowedChildSymbol(comparisonSymbols, realValuedSymbols);
      AddAllowedChildSymbol(comparisonSymbols, powerSymbols);
      AddAllowedChildSymbol(comparisonSymbols, conditionSymbols);
      AddAllowedChildSymbol(comparisonSymbols, timeSeriesSymbols);

      AddAllowedChildSymbol(variableCondition, realValuedSymbols);
      AddAllowedChildSymbol(variableCondition, powerSymbols);
      AddAllowedChildSymbol(variableCondition, conditionSymbols);
      AddAllowedChildSymbol(variableCondition, timeSeriesSymbols);


      AddAllowedChildSymbol(timeLag, realValuedSymbols);
      AddAllowedChildSymbol(timeLag, powerSymbols);
      AddAllowedChildSymbol(timeLag, conditionSymbols);

      AddAllowedChildSymbol(integral, realValuedSymbols);
      AddAllowedChildSymbol(integral, powerSymbols);
      AddAllowedChildSymbol(integral, conditionSymbols);

      AddAllowedChildSymbol(derivative, realValuedSymbols);
      AddAllowedChildSymbol(derivative, powerSymbols);
      AddAllowedChildSymbol(derivative, conditionSymbols);
      #endregion
    }
Пример #2
0
 private Gamma(Gamma original, Cloner cloner) : base(original, cloner) { }
    private void Initialize() {
      var add = new Addition();
      var sub = new Subtraction();
      var mul = new Multiplication();
      var div = new Division();
      var mean = new Average();
      var sin = new Sine();
      var cos = new Cosine();
      var tan = new Tangent();
      var log = new Logarithm();
      var pow = new Power();
      pow.InitialFrequency = 0.0;
      var square = new Square();
      square.InitialFrequency = 0.0;
      var root = new Root();
      root.InitialFrequency = 0.0;
      var sqrt = new SquareRoot();
      sqrt.InitialFrequency = 0.0;
      var airyA = new AiryA();
      airyA.InitialFrequency = 0.0;
      var airyB = new AiryB();
      airyB.InitialFrequency = 0.0;
      var bessel = new Bessel();
      bessel.InitialFrequency = 0.0;
      var cosineIntegral = new CosineIntegral();
      cosineIntegral.InitialFrequency = 0.0;
      var dawson = new Dawson();
      dawson.InitialFrequency = 0.0;
      var erf = new Erf();
      erf.InitialFrequency = 0.0;
      var expIntegralEi = new ExponentialIntegralEi();
      expIntegralEi.InitialFrequency = 0.0;
      var fresnelCosineIntegral = new FresnelCosineIntegral();
      fresnelCosineIntegral.InitialFrequency = 0.0;
      var fresnelSineIntegral = new FresnelSineIntegral();
      fresnelSineIntegral.InitialFrequency = 0.0;
      var gamma = new Gamma();
      gamma.InitialFrequency = 0.0;
      var hypCosineIntegral = new HyperbolicCosineIntegral();
      hypCosineIntegral.InitialFrequency = 0.0;
      var hypSineIntegral = new HyperbolicSineIntegral();
      hypSineIntegral.InitialFrequency = 0.0;
      var norm = new Norm();
      norm.InitialFrequency = 0.0;
      var psi = new Psi();
      psi.InitialFrequency = 0.0;
      var sineIntegral = new SineIntegral();
      sineIntegral.InitialFrequency = 0.0;

      var exp = new Exponential();
      var @if = new IfThenElse();
      var gt = new GreaterThan();
      var lt = new LessThan();
      var and = new And();
      var or = new Or();
      var not = new Not();
      var xor = new Xor();

      var timeLag = new TimeLag();
      timeLag.InitialFrequency = 0.0;
      var integral = new Integral();
      integral.InitialFrequency = 0.0;
      var derivative = new Derivative();
      derivative.InitialFrequency = 0.0;

      var variableCondition = new VariableCondition();
      variableCondition.InitialFrequency = 0.0;

      var constant = new Constant();
      constant.MinValue = -20;
      constant.MaxValue = 20;
      var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable();
      var laggedVariable = new LaggedVariable();
      laggedVariable.InitialFrequency = 0.0;
      var autoregressiveVariable = new AutoregressiveTargetVariable();
      autoregressiveVariable.InitialFrequency = 0.0;
      autoregressiveVariable.Enabled = false;

      var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp,
        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral,
        @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, laggedVariable,autoregressiveVariable, variableCondition };
      var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative,
        airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral
      };

      var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, variableCondition };
      var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or, xor };
      var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable, autoregressiveVariable };

      foreach (var symb in allSymbols)
        AddSymbol(symb);

      foreach (var funSymb in ternarySymbols) {
        SetSubtreeCount(funSymb, 1, 3);
      }
      foreach (var funSymb in unaryFunctionSymbols) {
        SetSubtreeCount(funSymb, 1, 1);
      }
      foreach (var funSymb in binaryFunctionSymbols) {
        SetSubtreeCount(funSymb, 2, 2);
      }
      foreach (var terminalSymbol in terminalSymbols) {
        SetSubtreeCount(terminalSymbol, 0, 0);
      }

      SetSubtreeCount(@if, 3, 3);


      // allow each symbol as child of the start symbol
      foreach (var symb in allSymbols) {
        AddAllowedChildSymbol(StartSymbol, symb);
        AddAllowedChildSymbol(DefunSymbol, symb);
      }

      // allow each symbol as child of every other symbol (except for terminals that have maxSubtreeCount == 0)
      foreach (var parent in allSymbols.Except(terminalSymbols)) {
        foreach (var child in allSymbols)
          AddAllowedChildSymbol(parent, child);
      }
    }