Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/25/19 12:04:30 (5 years ago)
Author:
pfleck
Message:

#3040 Added Vector symbols to TypeCoherentExpressionGrammar & fixes.

Location:
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r17180 r17369  
    4242    private const string SpecialFunctionsName = "Special Functions";
    4343    private const string TimeSeriesSymbolsName = "Time Series Symbols";
     44    private const string BasicVectorOperationSymbolsName = "Basic Vector Operations";
     45    private const string VectorAggregationSymbolsName = "Vector Aggregation";
     46    private const string VectorSymbolsName = "Vector Symbols";
    4447
    4548    [StorableConstructor]
     
    113116      var laggedVariable = new LaggedVariable();
    114117      var autoregressiveVariable = new AutoregressiveTargetVariable();
     118
     119      var vectorVariable = new VectorVariable();
     120      var vectorAdd = new VectorAddition();
     121      var vectorSub = new VectorSubtraction();
     122      var vectorMul = new VectorMultiplication();
     123      var vectorDiv = new VectorDivision();
     124      var vectorSum = new VectorSum();
     125      var vectorAvg = new VectorAverage();
    115126      #endregion
    116127
    117128      #region group symbol declaration
    118129      var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean });
    119       var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan, tanh});
    120       var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log});
     130      var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan, tanh });
     131      var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log });
    121132      var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi,
    122133        fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient});
     
    132143
    133144      var timeSeriesSymbols = new GroupSymbol(TimeSeriesSymbolsName, new List<ISymbol> { timeLag, integral, derivative, laggedVariable, autoregressiveVariable });
     145
     146      var basicVectorOperationSymbols = new GroupSymbol(BasicVectorOperationSymbolsName, new List<ISymbol>() { vectorAdd, vectorSub, vectorMul, vectorDiv });
     147      var vectorAggregationSymbols = new GroupSymbol(VectorAggregationSymbolsName, new List<ISymbol>() { vectorSum, vectorAvg });
     148      var vectorSymbols = new GroupSymbol(VectorSymbolsName, new List<ISymbol>() { vectorVariable, basicVectorOperationSymbols, vectorAggregationSymbols });
    134149      #endregion
    135150
     
    138153      AddSymbol(conditionalSymbols);
    139154      AddSymbol(timeSeriesSymbols);
     155      AddSymbol(vectorSymbols);
    140156
    141157      #region subtree count configuration
     
    149165      SetSubtreeCount(cubeRoot, 1, 1);
    150166      SetSubtreeCount(exponentialAndLogarithmicSymbols, 1, 1);
    151       foreach(var sy in specialFunctions.Symbols.Except(new[] { analyticalQuotient})) {
     167      foreach (var sy in specialFunctions.Symbols.Except(new[] { analyticalQuotient })) {
    152168        SetSubtreeCount(sy, 1, 1);
    153169      }
     
    169185      SetSubtreeCount(laggedVariable, 0, 0);
    170186      SetSubtreeCount(autoregressiveVariable, 0, 0);
     187
     188
     189      SetSubtreeCount(vectorVariable, 0, 0);
     190      SetSubtreeCount(basicVectorOperationSymbols, 2, 2);
     191      SetSubtreeCount(vectorAggregationSymbols, 1, 1);
    171192      #endregion
    172193
     
    237258      AddAllowedChildSymbol(derivative, powerSymbols);
    238259      AddAllowedChildSymbol(derivative, conditionSymbols);
     260
     261      AddAllowedChildSymbol(realValuedSymbols, vectorAggregationSymbols);
     262      AddAllowedChildSymbol(vectorAggregationSymbols, basicVectorOperationSymbols);
     263      AddAllowedChildSymbol(vectorAggregationSymbols, vectorVariable);
     264      AddAllowedChildSymbol(basicVectorOperationSymbols, basicVectorOperationSymbols);
     265      AddAllowedChildSymbol(basicVectorOperationSymbols, vectorVariable);
    239266      #endregion
    240267    }
     
    249276      Symbols.First(s => s.Name == ConditionalSymbolsName).Enabled = false;
    250277      Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = false;
     278      Symbols.First(s => s.Name == VectorSymbolsName).Enabled = false;
    251279    }
    252280
     
    262290      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
    263291      Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = false;
     292      Symbols.First(s => s.Name == VectorSymbolsName).Enabled = false;
    264293    }
    265294
     
    272301      Symbols.First(s => s.Name == ConditionalSymbolsName).Enabled = false;
    273302      Symbols.First(s => s.Name == SpecialFunctionsName).Enabled = false;
     303      Symbols.First(s => s.Name == VectorSymbolsName).Enabled = false;
    274304
    275305      Symbols.Single(s => s.Name == "Variable").Enabled = false;
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r17344 r17369  
    219219    <Compile Include="SymbolicDataAnalysisProblem.cs" />
    220220    <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" />
     221    <Compile Include="Symbols\VectorAverage.cs" />
     222    <Compile Include="Symbols\VectorSum.cs" />
     223    <Compile Include="Symbols\VectorSubtraction.cs" />
     224    <Compile Include="Symbols\VectorMultiplication.cs" />
     225    <Compile Include="Symbols\VectorDivision.cs" />
     226    <Compile Include="Symbols\VectorAddition.cs" />
    221227    <Compile Include="Symbols\Addition.cs" />
    222228    <Compile Include="Symbols\AnalyticQuotient.cs" />
     
    237243    <Compile Include="Symbols\CubeRoot.cs" />
    238244    <Compile Include="Symbols\HyperbolicTangent.cs" />
     245    <Compile Include="Symbols\VectorVariableTreeNode.cs" />
     246    <Compile Include="Symbols\VectorVariable.cs" />
    239247    <Compile Include="Symbols\VariableBase.cs" />
    240248    <Compile Include="Symbols\VariableTreeNodeBase.cs" />
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs

    r17367 r17369  
    552552            DoubleVector s = VectorEvaluate(dataset, ref row, state);
    553553            for (int i = 1; i < currentInstr.nArguments; i++) {
    554               s += Evaluate(dataset, ref row, state);
     554              s += VectorEvaluate(dataset, ref row, state);
    555555            }
    556556            return s;
     
    559559            DoubleVector s = VectorEvaluate(dataset, ref row, state);
    560560            for (int i = 1; i < currentInstr.nArguments; i++) {
    561               s -= Evaluate(dataset, ref row, state);
     561              s -= VectorEvaluate(dataset, ref row, state);
    562562            }
    563563            return s;
     
    566566            DoubleVector s = VectorEvaluate(dataset, ref row, state);
    567567            for (int i = 1; i < currentInstr.nArguments; i++) {
    568               s *= Evaluate(dataset, ref row, state);
     568              s *= VectorEvaluate(dataset, ref row, state);
    569569            }
    570570            return s;
     
    573573            DoubleVector s = VectorEvaluate(dataset, ref row, state);
    574574            for (int i = 1; i < currentInstr.nArguments; i++) {
    575               s /= Evaluate(dataset, ref row, state);
     575              s /= VectorEvaluate(dataset, ref row, state);
    576576            }
    577577            return s;
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r17180 r17369  
    239239        }
    240240      }
     241      foreach (var vectorVariableSymbol in grammar.Symbols.OfType<VectorVariable>()) {
     242        if (!vectorVariableSymbol.Fixed) {
     243          vectorVariableSymbol.AllVariableNames = problemData.InputVariables.Select(x => x.Value).Where(x => ds.VariableHasType<DoubleVector>(x));
     244          vectorVariableSymbol.VariableNames = problemData.AllowedInputVariables.Where(x => ds.VariableHasType<DoubleVector>(x));
     245        }
     246      }
    241247    }
    242248
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VectorVariable.cs

    r17367 r17369  
    3232    private VectorVariable(StorableConstructorFlag _) : base(_) {
    3333    }
    34     private VectorVariable(Variable original, Cloner cloner)
     34    private VectorVariable(VectorVariable original, Cloner cloner)
    3535      : base(original, cloner) {
    3636    }
Note: See TracChangeset for help on using the changeset viewer.