Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/17/20 16:22:18 (4 years ago)
Author:
pfleck
Message:

#3040

  • Extended importer (vectorvariable, vec-aggregations, ...).
  • Started adding unit test for vector simplifications.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs

    r17180 r17606  
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2727
     28using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
     29
    2830namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2931  public class SymbolicExpressionImporter {
    3032    private const string VARSTART = "VAR";
    3133    private const string LAGGEDVARSTART = "LAGVARIABLE";
     34    private const string VECVARSTART = "VEC";
    3235    private const string INTEGRALSTART = "INTEG";
    3336    private const string DEFUNSTART = "DEFUN";
     
    7073        {"EXPINT", new ExponentialIntegralEi()},
    7174        {"AQ", new AnalyticQuotient() },
    72         {"MEAN", new Average()},
     75        //{"MEAN", new Average()},
    7376        {"IF", new IfThenElse()},
    7477        {">", new GreaterThan()},
     
    8285        {"MAIN", new StartSymbol()},
    8386        {"FACTOR", new FactorVariable() },
    84         {"BINFACTOR", new BinaryFactorVariable()}
     87        {"BINFACTOR", new BinaryFactorVariable()},
     88        {"SUM", new Sum() },
     89        {"MEAN", new Mean()},
     90        {"LENGTH", new Length()},
     91        {"STDEV", new StandardDeviation()},
     92        {"VAR", new Variance()}
    8593      };
    8694
    8795    Constant constant = new Constant();
    88     Variable variable = new Variable();
     96    Variable variable = new Variable() { VariableDataType = typeof(double) };
    8997    LaggedVariable laggedVariable = new LaggedVariable();
     98    Variable vectorVariable = new Variable() { VariableDataType = typeof(DoubleVector) };
    9099    Defun defun = new Defun();
    91100    TimeLag timeLag = new TimeLag();
     
    129138        } else if (tokens.Peek().StringValue.StartsWith(LAGGEDVARSTART)) {
    130139          tree = ParseLaggedVariable(tokens);
     140        } else if (tokens.Peek().StringValue.StartsWith(VECVARSTART)) {
     141          tree = ParseVectorVariable(tokens);
    131142        } else if (tokens.Peek().StringValue.StartsWith(TIMELAGSTART)) {
    132143          tree = ParseTimeLag(tokens);
     
    216227    }
    217228
     229    private ISymbolicExpressionTreeNode ParseVectorVariable(Queue<Token> tokens) {
     230      Token varTok = tokens.Dequeue();
     231      Debug.Assert(varTok.StringValue == "VECTORVARIABLE");
     232      VariableTreeNode t = (VariableTreeNode)vectorVariable.CreateTreeNode();
     233      t.Weight = tokens.Dequeue().DoubleValue;
     234      t.VariableName = tokens.Dequeue().StringValue;
     235      return t;
     236    }
     237
    218238    private ISymbolicExpressionTreeNode ParseFactor(Queue<Token> tokens) {
    219239      Token tok = tokens.Dequeue();
Note: See TracChangeset for help on using the changeset viewer.