private void ApplyBacktransformation(ITransformation transformation, ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) {
   if (transformation.Column != targetVariable) {
     var variableNodes = symbolicExpressionTree.IterateNodesBreadth()
       .OfType<VariableTreeNode>()
       .Where(n => n.VariableName == transformation.Column);
     ApplyRegularBacktransformation(transformation, variableNodes);
   } else if (!(transformation is CopyColumnTransformation)) {
     ApplyInverseBacktransformation(transformation, symbolicExpressionTree);
   }
 }
Esempio n. 2
0
 private void ApplyBacktransformation(ITransformation transformation, ISymbolicExpressionTree symbolicExpressionTree, string targetVariable)
 {
     if (transformation.Column != targetVariable)
     {
         var variableNodes = symbolicExpressionTree.IterateNodesBreadth()
                             .OfType <VariableTreeNode>()
                             .Where(n => n.VariableName == transformation.Column);
         ApplyRegularBacktransformation(transformation, variableNodes);
     }
     else if (!(transformation is CopyColumnTransformation))
     {
         ApplyInverseBacktransformation(transformation, symbolicExpressionTree);
     }
 }
Esempio n. 3
0
 public string Format(ISymbolicExpressionTree symbolicExpressionTree, string targetVariable)
 {
     try {
         StringBuilder strBuilder = new StringBuilder();
         constants.Clear();
         constIndex               = 0;
         this.targetVariable      = targetVariable;
         containsTimeSeriesSymbol = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsTimeSeriesSymbol(n.Symbol));
         strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root));
         return(strBuilder.ToString());
     } catch (NotImplementedException ex) {
         return(ex.Message + Environment.NewLine + ex.StackTrace);
     }
 }
Esempio n. 4
0
        public string Format(ISymbolicExpressionTree symbolicExpressionTree)
        {
            var    root            = symbolicExpressionTree.Root;
            var    actualRoot      = root.SubtreeCount == 0 ? root.GetSubtree(0) : root;
            var    nodeCoordinates = layoutEngine.CalculateLayout(actualRoot).ToDictionary(n => n.Content, n => new PointF(n.X, n.Y));
            var    sb = new StringBuilder();
            var    nl = Environment.NewLine;
            double ws = 1;
            double hs = 0.7;

            sb.Append("\\documentclass[class=minimal,border=0pt]{standalone}" + nl +
                      "\\usepackage{tikz}" + nl +
                      "\\begin{document}" + nl +
                      "\\begin{tikzpicture}" + nl +
                      "\\def\\ws{1}" + nl +
                      "\\def\\hs{0.7}" + nl);

            var nodeIndices = new Dictionary <ISymbolicExpressionTreeNode, int>();
            var nodes       = symbolicExpressionTree.IterateNodesBreadth().ToList();

            for (int i = 0; i < nodes.Count; ++i)
            {
                var node = nodes[i];
                nodeIndices.Add(node, i);
                var coord    = nodeCoordinates[node];
                var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString();
                sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1},\\hs*{2}) {{{3}}};", i, ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName)));
            }

            for (int i = 0; i < nodes.Count; ++i)
            {
                foreach (var s in nodes[i].Subtrees)
                {
                    sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\draw ({0}) -- ({1});", i, nodeIndices[s]));
                }
            }

            sb.Append("\\end{tikzpicture}" + nl +
                      "\\end{document}" + nl);
            return(sb.ToString());
        }
    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
      var root = symbolicExpressionTree.Root;
      var actualRoot = root.SubtreeCount == 0 ? root.GetSubtree(0) : root;
      var nodeCoordinates = layoutEngine.CalculateLayout(actualRoot).ToDictionary(n => n.Content, n => new PointF(n.X, n.Y));
      var sb = new StringBuilder();
      var nl = Environment.NewLine;
      double ws = 1;
      double hs = 0.7;

      sb.Append("\\documentclass[class=minimal,border=0pt]{standalone}" + nl +
                "\\usepackage{tikz}" + nl +
                "\\begin{document}" + nl +
                "\\begin{tikzpicture}" + nl +
                "\\def\\ws{1}" + nl +
                "\\def\\hs{0.7}" + nl);

      var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>();
      var nodes = symbolicExpressionTree.IterateNodesBreadth().ToList();
      for (int i = 0; i < nodes.Count; ++i) {
        var node = nodes[i];
        nodeIndices.Add(node, i);
        var coord = nodeCoordinates[node];
        var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString();
        sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1},\\hs*{2}) {{{3}}};", i, ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName)));
      }

      for (int i = 0; i < nodes.Count; ++i) {
        foreach (var s in nodes[i].Subtrees) {
          sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\draw ({0}) -- ({1});", i, nodeIndices[s]));
        }
      }

      sb.Append("\\end{tikzpicture}" + nl +
                "\\end{document}" + nl);
      return sb.ToString();
    }