コード例 #1
0
ファイル: Rectangle.cs プロジェクト: harmanpa/csv-compare
        /// <summary>
        /// Calculates a lower and an upper tube curve.
        /// </summary>
        /// <param name="reference">Reference curve with x and y values.</param>
        /// <param name="size">Size of tube.</param>
        /// <returns>Collection of return values.</returns>
        public override TubeReport Calculate(Curve reference, TubeSize size)
        {
            TubeReport report = new TubeReport();
            successful = false;

            if (reference != null && size != null)
            {
                report.Reference = reference;
                report.Size = size;
                report.Algorithm = AlgorithmOptions.Rectangle;
                report.Lower = CalculateLower(reference, size);
                report.Upper = CalculateUpper(reference, size);
                if (report.Lower.ImportSuccessful && report.Upper.ImportSuccessful)
                    successful = true;
            }
            return report;
        }
コード例 #2
0
        /// <summary>
        /// Calculates a lower and an upper tube curve.
        /// </summary>
        /// <param name="reference">Reference curve with x and y values.</param>
        /// <param name="size">Size of tube.</param>
        /// <returns>Collection of return values.</returns>
        public override TubeReport Calculate(Curve reference, TubeSize size)
        {
            TubeReport report = new TubeReport();

            successful = false;

            if (reference != null && size != null)
            {
                report.Reference = reference;
                report.Size      = size;
                report.Algorithm = AlgorithmOptions.Rectangle;
                report.Lower     = CalculateLower(reference, size);
                report.Upper     = CalculateUpper(reference, size);
                if (report.Lower.ImportSuccessful && report.Upper.ImportSuccessful)
                {
                    successful = true;
                }
            }
            return(report);
        }
コード例 #3
0
ファイル: Ellipse.cs プロジェクト: cristix20/csv-compare
        /// <summary>
        /// Calculates a lower and an upper tube curve.
        /// </summary>
        /// <param name="reference">Reference curve with x and y values..</param>
        /// <param name="size">Size of tube.</param>
        /// <returns>Collection of return values.</returns>
        public override TubeReport Calculate(Curve reference, TubeSize size)
        {
            /*
             * ///This method generates tubes around a given curve.
             * /// @param x The time values for the base curve
             * /// @param y The y values of the base curve
             * /// @param x_low An empty, initialized list that is to be filled with the time values for the lower tube curve
             * /// @param y_low An empty, initialized list that is to be filled with the y values for the lower tube curve
             * /// @param x_high An empty, initialized list that is to be filled with the time values for the upper tube curve
             * /// @param y_high An empty, initialized list that is to be filled with the y values for the upper tube curve
             * /// @param r relative tolerance argument
             * /// @param bAllIntervals used all intervals
             * */
            double[] x = reference.X.ToArray();
            double[] y = reference.Y.ToArray();
            _dDelta = size.X;
            List <double> xHigh = new List <double>();
            List <double> yHigh = new List <double>();
            List <double> xLow  = new List <double>();
            List <double> yLow  = new List <double>();

            TubeReport report = new TubeReport();

            successful = false;

            if (reference != null && size != null)
            {
                report.Reference = reference;
                report.Size      = size;
                report.Algorithm = AlgorithmOptions.Ellipse;

                /// SBR: Wir gehen erstmal prinzipiell davon aus das der Algorithmus korrekt verläuft.
                //_bAllIntervals = true;
                // set tStart and tStop
                _dtStart   = x[0];
                _dtStop    = x[x.Length - 1];
                _dXMinStep = ((_dtStop - _dtStart) + Math.Abs(_dtStart)) * _dXRelEps;

                // Initialize lists (upper tube)
                _lmh  = new ArrayList(x.Length); // slope in i
                _li0h = new ArrayList(x.Length); // i
                _li1h = new ArrayList(x.Length); // i - 1

                // Initialize lists (lower tube)
                _lml  = new ArrayList(x.Length);        // slope in i
                _li0l = new ArrayList(x.Length);        // i
                _li1l = new ArrayList(x.Length);        // i-1

                // calculate the tubes delta
                //_dDelta = r * (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart));

                // calculate S:
                double max = y[0];
                double min = y[0];

                xHigh.Clear();
                yHigh.Clear();
                xLow.Clear();
                yLow.Clear();

                if (xHigh.Capacity < x.Length)
                {
                    xHigh.Capacity = x.Length;
                }
                if (yHigh.Capacity < x.Length)
                {
                    yHigh.Capacity = x.Length;
                }
                if (xLow.Capacity < x.Length)
                {
                    xLow.Capacity = x.Length;
                }
                if (yLow.Capacity < x.Length)
                {
                    yLow.Capacity = x.Length;
                }

                for (int i = 1; i < y.Length; i++)
                {
                    try
                    {
                        double Y = y[i];
                        if (Y > max)
                        {
                            max = Y;
                        }
                        if (Y < min)
                        {
                            min = Y;
                        }
                    }
                    catch (IndexOutOfRangeException) { break; }
                }
                //            _dS = Math.Abs(4 * (max - min) / (Math.Abs(_dtStop - _dtStart)));
                _dS = (Math.Abs(max - min) + Math.Abs(min)) / (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart));

                if (_dS < 0.0004 / (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart)))
                {
                    _dS = 0.0004 / (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart));
                }

                bool bJump = false;

                // Begin calculation for the tubes
                for (int i = 1; i < x.Length; i++)
                {
                    try
                    {
                        // get current value
                        _dX1 = x[i];
                        _dY1 = y[i];

                        // get previous value
                        _dX2 = x[i - 1];
                        _dY2 = y[i - 1];
                    }
                    catch (IndexOutOfRangeException) { break; }

                    // catch jumps
                    bJump = false;
                    if ((_dX1 <= _dX2) && (_dY1 == _dY2) && (xHigh.Count == 0))
                    {
                        continue;
                    }
                    if ((_dX1 <= _dX2) && (_dY1 == _dY2))
                    {
                        _dX1 = Math.Max(x[(int)_li1l[_li1l.Count - 1]] + _dXMinStep, Math.Max(x[(int)_li1h[_li1h.Count - 1]] + _dXMinStep, _dX1));
                        x.SetValue(_dX1, i);
                        _dCurrentSlope = (double)_lmh[_lmh.Count - 1];
                    }
                    else
                    {
                        if (_dX1 <= _dX2)
                        {
                            bJump = true;
                            _dX1  = _dX2 + _dXMinStep;
                            x.SetValue(_dX1, i);
                        }
                        _dCurrentSlope = (_dY1 - _dY2) / (_dX1 - _dX2); // calculate current slope ( 3.2.6.1)
                    }

                    // fill lists with new values: values upper tube
                    _li0h.Add(i);
                    _li1h.Add(i - 1);
                    _lmh.Add(_dCurrentSlope);

                    // fill lists with new values: values lower tube
                    _li0l.Add(i);
                    _li1l.Add(i - 1);
                    if ((_dX1 <= _dX2) && (_dY1 == _dY2))
                    {
                        _dCurrentSlope = (double)_lml[_lml.Count - 1];
                    }
                    _lml.Add(_dCurrentSlope);

                    if (xHigh.Count == 0) // 1st interval (3.2.5)
                    {
                        if (bJump)
                        {
                            // initial values upper tube
                            _li0h[0] = i - 1;
                            _lmh[0]  = 0.0;
                            xHigh.Add(_dX2 - _dDelta - _dXMinStep);
                            yHigh.Add(_dY2 + _dDelta * _dS);
                            _li0h.Add(i);
                            _li1h.Add(i - 1);
                            _lmh.Add(_dCurrentSlope);
                            xHigh.Add(_dX2 - _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                            yHigh.Add(_dY2 + _dDelta * _dS);

                            // initial values lower tube
                            _li0l[0] = i - 1;
                            _lml[0]  = 0.0;
                            xLow.Add(_dX2 - _dDelta - _dXMinStep);
                            yLow.Add(_dY2 - _dDelta * _dS);
                            _li0l.Add(i);
                            _li1l.Add(i - 1);
                            _lml.Add(_dCurrentSlope);
                            xLow.Add(_dX2 + _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                            yLow.Add(_dY2 - _dDelta * _dS);
                        }
                        else
                        {       // initial values upper tube
                            xHigh.Add(_dX2 - _dDelta);
                            yHigh.Add(_dY2 - _dCurrentSlope * _dDelta + _dDelta * Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS)));

                            // initial values lower tube
                            xLow.Add(_dX2 - _dDelta);
                            yLow.Add(_dY2 - _dCurrentSlope * _dDelta - _dDelta * Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS)));
                        }
                    }
                    else        // if not 1st interval (3.2.6)
                    {
                        // fill lists with new values, set X and Y to arbitrary value (3.2.6.1)
                        xHigh.Add(1);
                        yHigh.Add(1);

                        xLow.Add(1);
                        yLow.Add(1);

                        // begin procedure for upper tube
                        GenerateHighTube(x, y, xHigh, yHigh);

                        // begin procedure for lower tube
                        GenerateLowTube(x, y, xLow, yLow);
                    }
                }

                // calculate terminal value
                _dX2 = (double)x.GetValue(x.Length - 1);
                if (bJump)
                {
                    _dY2 = (double)y.GetValue(y.Length - 1);
                    // upper tube
                    _dCurrentSlope = (double)_lmh[_lmh.Count - 1];

                    xHigh.Add(_dX2 - _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                    yHigh.Add(_dY2 + _dDelta * _dS);
                    xHigh.Add(_dX2 + _dDelta + _dXMinStep);
                    yHigh.Add(_dY2 + _dDelta * _dS);

                    // lower tube
                    _dCurrentSlope = (double)_lml[_lml.Count - 1];

                    xLow.Add(_dX2 + _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                    yLow.Add(_dY2 - _dDelta * _dS);
                    xLow.Add(_dX2 + _dDelta + _dXMinStep);
                    yLow.Add(_dY2 - _dDelta * _dS);
                }
                else
                {
                    // upper tube
                    _dX1 = (double)xHigh[xHigh.Count - 1];
                    _dY1 = (double)yHigh[yHigh.Count - 1];

                    _dCurrentSlope = (double)_lmh[_lmh.Count - 1];

                    xHigh.Add(_dX2 + _dDelta);
                    yHigh.Add(_dY1 + _dCurrentSlope * (_dX2 + _dDelta - _dX1));

                    // lower tube
                    _dX1 = (double)xLow[xLow.Count - 1];
                    _dY1 = (double)yLow[yLow.Count - 1];

                    _dCurrentSlope = (double)_lml[_lml.Count - 1];

                    xLow.Add(_dX2 + _dDelta);
                    yLow.Add(_dY1 + _dCurrentSlope * (_dX2 + _dDelta - _dX1));
                }
                report.Lower = new Curve("Lower", xLow.ToArray(), yLow.ToArray());
                report.Upper = new Curve("Upper", xHigh.ToArray(), yHigh.ToArray());
                if (report.Lower.ImportSuccessful && report.Upper.ImportSuccessful)
                {
                    successful = true;
                }
            }
            return(report);
        }
コード例 #4
0
        private void PrepareCharts(Curve reference, Curve compare, Curve error, Report rep, TubeReport tubeReport, KeyValuePair <string, List <double> > res, bool bDrawBitmapPlots)
        {
            Chart ch = new Chart()
            {
                LabelX    = "Time",
                LabelY    = res.Key,
                Errors    = (null != error && null != error.X) ? error.X.Length : 0,
                Title     = string.Format("{0}.{1}", Path.GetFileNameWithoutExtension(this._fileName), res.Key),
                UseBitmap = bDrawBitmapPlots
            };

            if (null != compare)
            {
                ch.Series.Add(new Series()
                {
                    Color       = Color.Orange,
                    ArrayString = (bDrawBitmapPlots) ? string.Empty : Series.GetArrayString(reference.X, reference.Y),
                    Title       = "Base (to compare with)",
                    XAxis       = (bDrawBitmapPlots) ? reference.X : null,
                    YAxis       = (bDrawBitmapPlots) ? reference.Y : null
                });

                ch.Series.Add(new Series()
                {
                    Color       = Color.Green,
                    ArrayString = (bDrawBitmapPlots) ? string.Empty : Series.GetArrayString(compare.X, compare.Y),
                    Title       = "Result",
                    XAxis       = (bDrawBitmapPlots) ? compare.X : null,
                    YAxis       = (bDrawBitmapPlots) ? compare.Y : null
                });
                ch.Series.Add(new Series()
                {
                    Color       = Color.LightBlue,
                    ArrayString = (bDrawBitmapPlots) ? string.Empty : Series.GetArrayString(tubeReport.Lower.X, tubeReport.Lower.Y),
                    Title       = "Low Tube",
                    XAxis       = (bDrawBitmapPlots) ? tubeReport.Lower.X : null,
                    YAxis       = (bDrawBitmapPlots) ? tubeReport.Lower.Y : null
                });
                ch.Series.Add(new Series()
                {
                    Color       = Color.LightGreen,
                    ArrayString = (bDrawBitmapPlots) ? string.Empty : Series.GetArrayString(tubeReport.Upper.X, tubeReport.Upper.Y),
                    Title       = "High Tube",
                    XAxis       = (bDrawBitmapPlots) ? tubeReport.Upper.X : null,
                    YAxis       = (bDrawBitmapPlots) ? tubeReport.Upper.Y : null
                });
            }
            else
            {
                ch.Series.Add(new Series()
                {
                    Color       = Color.Green,
                    ArrayString = (bDrawBitmapPlots) ? string.Empty : Series.GetArrayString(reference.X, reference.Y),
                    Title       = "Compare",
                    XAxis       = (bDrawBitmapPlots) ? reference.X : null,
                    YAxis       = (bDrawBitmapPlots) ? reference.Y : null
                });
            }
            if (null != error && null != error.X && error.X.Length > 0)
            {
                //Get complete error curve as "error" only holds error points
                Curve curveErrors = new Curve("ERRORS", new double[compare.X.Length], new double[compare.X.Length]);
                int   j           = 0;
                for (int i = 0; i < compare.X.Length - 1; i++)
                {
                    curveErrors.X[i] = compare.X[i];
                    if (error.X.Contains(compare.X[i]))
                    {
                        curveErrors.Y[i] = (this._bShowRelativeErrors) ? error.Y[j] : 1;
                        if (compare.X[i + 1] > compare.X[i])
                        {
                            j++;
                        }
                    }
                    else
                    {
                        curveErrors.Y[i] = 0;
                    }
                }

                ch.Series.Add(new Series()
                {
                    Color       = Color.Red,
                    ArrayString = (bDrawBitmapPlots) ? string.Empty : Series.GetArrayString(curveErrors.X, curveErrors.Y),
                    Title       = curveErrors.Name,
                    XAxis       = (bDrawBitmapPlots) ? error.X : null,
                    YAxis       = (bDrawBitmapPlots) ? error.Y : null
                });

                //Calculate delta error
                List <double> lDeltas = new List <double>();
                j = 0;
                for (int i = 1; i < compare.X.Length - 1; i++)
                {
                    if (j < error.X.Length)
                    {
                        while (compare.X[i] < error.X[j])
                        {
                            i++;
                            continue;
                        }

                        if (i < compare.X.Length - 1)
                        {
                            lDeltas.Add((Math.Abs(error.Y[j]) * ((Math.Abs(compare.X[i] - compare.X[i - 1])) + (Math.Abs(compare.X[i + 1] - compare.X[i])))) / 2);
                        }
                        else // handle errors in the last point (there is no i+1)
                        {
                            lDeltas.Add((Math.Abs(error.Y[j]) * ((Math.Abs(compare.X[i] - compare.X[i - 1])))) / 2);
                        }
                        j++;
                    }
                }
                ch.DeltaError = lDeltas.Sum() / (1e-3 + compare.Y.Max(x => Math.Abs(x)));
            }
            if (null != tubeReport && tubeReport.Lower.X.ToList <double>().Count > 2)//Remember Start and Stop values for graph scaling
            {
                ch.MinValue = tubeReport.Lower.X[0];
                ch.MaxValue = tubeReport.Lower.X.Last();
            }
            rep.Chart.Add(ch);
        }
コード例 #5
0
        public Report CompareFiles(Log log, CsvFile csvBase, string sReportPath, ref Options options)
        {
            int iInvalids = 0;

            Report rep = new Report(sReportPath);

            log.WriteLine("Comparing \"{0}\" to \"{1}\"", _fileName, csvBase.ToString());

            rep.BaseFile    = csvBase.ToString();
            rep.CompareFile = _fileName;

            Curve      reference    = new Curve();
            Curve      compareCurve = new Curve();
            TubeReport tubeReport   = new TubeReport();
            TubeSize   size         = null;
            Tube       tube         = new Tube(size);

            switch (options.Direction)
            {
            case ToleranceDirection.X:
                userchoice = 1;     ///set to 1 for tolerenace in X axis
                break;

            case ToleranceDirection.Y:
                userchoice = 0;     ///set to 0 for tolerance in Y-axis
                break;

            default:    //Invalid mode
                Console.WriteLine(options.GetUsage());
                break;
            }

            if (userchoice == 1)
            {
                IOptions tubeOptions = new Options1(_dRangeDelta, Axes.X);
            }
            else if (userchoice == 0)
            {
                IOptions tubeOptions = new Options1(_dRangeDelta, Axes.Y);
            }
            else
            {
                Console.WriteLine("opted for wrong choice");
                Environment.ExitCode = 2;
            }


            foreach (KeyValuePair <string, List <double> > res in csvBase.Results)
            {
                if (!this.Results.ContainsKey(res.Key))
                {
                    log.Error("{0} not found in \"{1}\", skipping checks.", res.Key, this._fileName);
                    rep.Chart.Add(new Chart()
                    {
                        Title = res.Key, Errors = 1
                    });
                    Environment.ExitCode = 1;
                    continue;
                }
                else
                {
                    compareCurve = new Curve(res.Key, this.XAxis.ToArray <double>(), this.Results[res.Key].ToArray <double>());

                    if (res.Value.Count == 0)
                    {
                        log.Error("{0} has no y-Values! Maybe error during parsing? Skipping", res.Key);
                        continue;
                    }
                    reference = new Curve("Reference ", csvBase.XAxis.ToArray(), csvBase.Results[res.Key].ToArray());
                    if (!reference.ImportSuccessful)
                    {
                        log.Error("Error in the calculation of the tubes. Skipping {0}", res.Key);
                        rep.Chart.Add(new Chart()
                        {
                            Title = res.Key, Errors = 1
                        });
                        continue;
                    }

                    if (reference.X.Length < compareCurve.X.Length)
                    {
                        log.WriteLine(LogLevel.Warning, "The resolution of the base x-axis is smaller than the compare x-axis. The better the base resolution is, the better the validation result will be!");
                    }
                    else
                    {
                        log.WriteLine(LogLevel.Debug, "The resolution of the base x-axis is good.");
                    }

                    size = new TubeSize(reference, true);
                    switch (options.Method)
                    {
                    case ExecutionMethod.Relative:
                        if (userchoice == 1)
                        {
                            size.Calculate(_dRangeDelta, Axes.X, Relativity.Relative);
                        }
                        else
                        {
                            size.Calculate(_dRangeDelta, Axes.Y, Relativity.Relative);
                        }
                        break;

                    case ExecutionMethod.Absolute:
                        if (userchoice == 1)
                        {
                            size.Calculate(_dRangeDelta, Axes.X, Relativity.Absolute);
                        }
                        else
                        {
                            size.Calculate(_dRangeDelta, Axes.Y, Relativity.Absolute);
                        }
                        break;

                    default:    //Invalid mode
                        Console.WriteLine(options.GetUsage());
                        break;
                    }
                    tube       = new Tube(size);
                    tubeReport = tube.Calculate(reference);
                    tube.Validate(compareCurve);

                    if (tubeReport.Valid == Validity.Valid)
                    {
                        log.WriteLine(res.Key + " is valid");
                    }
                    else
                    {
                        log.WriteLine(LogLevel.Warning, "{0} is invalid! {1} errors have been found during validation.", res.Key,
                                      (null != tube.Report.Errors && null != tube.Report.Errors.X) ? tube.Report.Errors.X.Length : 0);
                        iInvalids++;
                        Environment.ExitCode = 1;
                    }
                }
                if (null != tube.Report)//No charts for missing reports
                {
                    PrepareCharts(reference, compareCurve, tube.Report.Errors, rep, tubeReport, res, options.UseBitmapPlots);
                }
            }
            rep.Tolerance = _dRangeDelta;

            string sResult = "na";

            if (rep.TotalErrors == 0)
            {
                sResult = "passed";
            }
            else
            {
                sResult = "failed";
            }

            if (options.ComparisonFlag)
            {
                using (TextWriter writer = File.CreateText(string.Format("{0}{1}compare_{2}.log", Path.GetDirectoryName(_fileName), Path.DirectorySeparatorChar, sResult)))
                {
                    //Content needs to be defined
                    writer.WriteLine("CSV Compare Version {0} ({1})", Info.AssemblyVersion, Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture);
                    writer.WriteLine("Comparison result file for {0}", _fileName);
                    writer.WriteLine(". Time:        {0:o}", DateTime.Now);
                    writer.WriteLine(". Operation:   {0}", options.Mode);
                    writer.WriteLine(". Tolerance:   {0}", options.Tolerance);
                    writer.WriteLine(". Execution Method:   {0}", options.Method);
                    writer.WriteLine(". Direction of Tolerence:   {0}", options.Direction);
                    writer.WriteLine(". Result:      {0}", sResult);

                    if (rep.TotalErrors > 0)
                    {
                        Chart pairMax = rep.Chart.Aggregate((l, r) => l.DeltaError > r.DeltaError ? l : r);
                        if (pairMax.DeltaError > 0)
                        {
                            writer.WriteLine(". Largest error: {0}=>{1}", pairMax.Title, pairMax.DeltaError);
                            writer.WriteLine(". Failed values:");

                            foreach (Chart c in (from r in rep.Chart where r.DeltaError > 0 select r).OrderByDescending(er => er.DeltaError))
                            {
                                writer.WriteLine("{0}=>{1}", c.Title, c.DeltaError.ToString(CultureInfo.InvariantCulture));
                            }
                        }
                    }
                }
            }

            rep.WriteReport(log, (string.IsNullOrEmpty(options.ReportDir) || options.NoMetaReport) ? string.Empty : options.ReportDir, options);
            GC.Collect();//immediately forget big charts and data
            return(rep);
        }
コード例 #6
0
        /// <summary>
        /// Calculates a lower and an upper tube curve.
        /// </summary>
        /// <param name="reference">Reference curve with x and y values.</param>
        /// <param name="size">Size of tube.</param>
        /// <returns>Collection of return values.</returns>
        public virtual TubeReport Calculate(Curve reference, TubeSize size)
        {
            TubeReport report = new TubeReport();

            return(report);
        }
コード例 #7
0
ファイル: Algorithm.cs プロジェクト: harmanpa/csv-compare
 /// <summary>
 /// Calculates a lower and an upper tube curve.
 /// </summary>
 /// <param name="reference">Reference curve with x and y values.</param>
 /// <param name="size">Size of tube.</param>
 /// <returns>Collection of return values.</returns>
 public virtual TubeReport Calculate(Curve reference, TubeSize size)
 {
     TubeReport report = new TubeReport();
     return report;
 }
コード例 #8
0
ファイル: Ellipse.cs プロジェクト: harmanpa/csv-compare
        /// <summary>
        /// Calculates a lower and an upper tube curve.
        /// </summary>
        /// <param name="reference">Reference curve with x and y values..</param>
        /// <param name="size">Size of tube.</param>
        /// <returns>Collection of return values.</returns>
        public override TubeReport Calculate(Curve reference, TubeSize size)
        {
            /*
            ///This method generates tubes around a given curve.
            /// @param x The time values for the base curve
            /// @param y The y values of the base curve
            /// @param x_low An empty, initialized list that is to be filled with the time values for the lower tube curve
            /// @param y_low An empty, initialized list that is to be filled with the y values for the lower tube curve
            /// @param x_high An empty, initialized list that is to be filled with the time values for the upper tube curve
            /// @param y_high An empty, initialized list that is to be filled with the y values for the upper tube curve
            /// @param r relative tolerance argument
            /// @param bAllIntervals used all intervals
             * */
            double[] x = reference.X.ToArray();
            double[] y = reference.Y.ToArray();
            _dDelta = size.X;
            List<double> xHigh = new List<double>();
            List<double> yHigh = new List<double>();
            List<double> xLow = new List<double>();
            List<double> yLow = new List<double>();

            TubeReport report = new TubeReport();
            successful = false;

            if (reference != null && size != null)
            {
                report.Reference = reference;
                report.Size = size;
                report.Algorithm = AlgorithmOptions.Ellipse;

                /// SBR: Wir gehen erstmal prinzipiell davon aus das der Algorithmus korrekt verläuft.
                //_bAllIntervals = true;
                // set tStart and tStop
                _dtStart = x[0];
                _dtStop = x[x.Length - 1];
                _dXMinStep = ((_dtStop - _dtStart) + Math.Abs(_dtStart)) * _dXRelEps;

                // Initialize lists (upper tube)
                _lmh = new ArrayList(x.Length);	// slope in i
                _li0h = new ArrayList(x.Length);	// i
                _li1h = new ArrayList(x.Length);	// i - 1

                // Initialize lists (lower tube)
                _lml = new ArrayList(x.Length);		// slope in i
                _li0l = new ArrayList(x.Length);	// i
                _li1l = new ArrayList(x.Length);	// i-1

                // calculate the tubes delta
                //_dDelta = r * (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart));

                // calculate S:
                double max = y[0];
                double min = y[0];

                xHigh.Clear();
                yHigh.Clear();
                xLow.Clear();
                yLow.Clear();

                if (xHigh.Capacity < x.Length) xHigh.Capacity = x.Length;
                if (yHigh.Capacity < x.Length) yHigh.Capacity = x.Length;
                if (xLow.Capacity < x.Length) xLow.Capacity = x.Length;
                if (yLow.Capacity < x.Length) yLow.Capacity = x.Length;

                for (int i = 1; i < y.Length; i++)
                {
                    try
                    {
                        double Y = y[i];
                        if (Y > max)
                        {
                            max = Y;
                        }
                        if (Y < min)
                        {
                            min = Y;
                        }
                    }
                    catch (IndexOutOfRangeException) { break; }
                }
                //            _dS = Math.Abs(4 * (max - min) / (Math.Abs(_dtStop - _dtStart)));
                _dS = (Math.Abs(max - min) + Math.Abs(min)) / (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart));

                if (_dS < 0.0004 / (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart)))
                {
                    _dS = 0.0004 / (Math.Abs(_dtStop - _dtStart) + Math.Abs(_dtStart));
                }

                bool bJump = false;

                // Begin calculation for the tubes
                for (int i = 1; i < x.Length; i++)
                {
                    try
                    {
                        // get current value
                        _dX1 = x[i];
                        _dY1 = y[i];

                        // get previous value
                        _dX2 = x[i - 1];
                        _dY2 = y[i - 1];
                    }
                    catch (IndexOutOfRangeException) { break; }

                    // catch jumps
                    bJump = false;
                    if ((_dX1 <= _dX2) && (_dY1 == _dY2) && (xHigh.Count == 0))
                        continue;
                    if ((_dX1 <= _dX2) && (_dY1 == _dY2))
                    {
                        _dX1 = Math.Max(x[(int)_li1l[_li1l.Count - 1]] + _dXMinStep, Math.Max(x[(int)_li1h[_li1h.Count - 1]] + _dXMinStep, _dX1));
                        x.SetValue(_dX1, i);
                        _dCurrentSlope = (double)_lmh[_lmh.Count - 1];
                    }
                    else
                    {
                        if (_dX1 <= _dX2)
                        {
                            bJump = true;
                            _dX1 = _dX2 + _dXMinStep;
                            x.SetValue(_dX1, i);
                        }
                        _dCurrentSlope = (_dY1 - _dY2) / (_dX1 - _dX2); // calculate current slope ( 3.2.6.1)
                    }

                    // fill lists with new values: values upper tube
                    _li0h.Add(i);
                    _li1h.Add(i - 1);
                    _lmh.Add(_dCurrentSlope);

                    // fill lists with new values: values lower tube
                    _li0l.Add(i);
                    _li1l.Add(i - 1);
                    if ((_dX1 <= _dX2) && (_dY1 == _dY2))
                        _dCurrentSlope = (double)_lml[_lml.Count - 1];
                    _lml.Add(_dCurrentSlope);

                    if (xHigh.Count == 0) // 1st interval (3.2.5)
                    {
                        if (bJump)
                        {
                            // initial values upper tube
                            _li0h[0] = i - 1;
                            _lmh[0] = 0.0;
                            xHigh.Add(_dX2 - _dDelta - _dXMinStep);
                            yHigh.Add(_dY2 + _dDelta * _dS);
                            _li0h.Add(i);
                            _li1h.Add(i - 1);
                            _lmh.Add(_dCurrentSlope);
                            xHigh.Add(_dX2 - _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                            yHigh.Add(_dY2 + _dDelta * _dS);

                            // initial values lower tube
                            _li0l[0] = i - 1;
                            _lml[0] = 0.0;
                            xLow.Add(_dX2 - _dDelta - _dXMinStep);
                            yLow.Add(_dY2 - _dDelta * _dS);
                            _li0l.Add(i);
                            _li1l.Add(i - 1);
                            _lml.Add(_dCurrentSlope);
                            xLow.Add(_dX2 + _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                            yLow.Add(_dY2 - _dDelta * _dS);
                        }
                        else
                        {       // initial values upper tube
                            xHigh.Add(_dX2 - _dDelta);
                            yHigh.Add(_dY2 - _dCurrentSlope * _dDelta + _dDelta * Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS)));

                            // initial values lower tube
                            xLow.Add(_dX2 - _dDelta);
                            yLow.Add(_dY2 - _dCurrentSlope * _dDelta - _dDelta * Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS)));
                        }
                    }
                    else	// if not 1st interval (3.2.6)
                    {
                        // fill lists with new values, set X and Y to arbitrary value (3.2.6.1)
                        xHigh.Add(1);
                        yHigh.Add(1);

                        xLow.Add(1);
                        yLow.Add(1);

                        // begin procedure for upper tube
                        GenerateHighTube(x, y, xHigh, yHigh);

                        // begin procedure for lower tube
                        GenerateLowTube(x, y, xLow, yLow);
                    }

                }

                // calculate terminal value
                _dX2 = (double)x.GetValue(x.Length - 1);
                if (bJump)
                {
                    _dY2 = (double)y.GetValue(y.Length - 1);
                    // upper tube
                    _dCurrentSlope = (double)_lmh[_lmh.Count - 1];

                    xHigh.Add(_dX2 - _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                    yHigh.Add(_dY2 + _dDelta * _dS);
                    xHigh.Add(_dX2 + _dDelta + _dXMinStep);
                    yHigh.Add(_dY2 + _dDelta * _dS);

                    // lower tube
                    _dCurrentSlope = (double)_lml[_lml.Count - 1];

                    xLow.Add(_dX2 + _dDelta * _dCurrentSlope / (_dS + Math.Sqrt((_dCurrentSlope * _dCurrentSlope) + (_dS * _dS))));
                    yLow.Add(_dY2 - _dDelta * _dS);
                    xLow.Add(_dX2 + _dDelta + _dXMinStep);
                    yLow.Add(_dY2 - _dDelta * _dS);
                }
                else
                {
                    // upper tube
                    _dX1 = (double)xHigh[xHigh.Count - 1];
                    _dY1 = (double)yHigh[yHigh.Count - 1];

                    _dCurrentSlope = (double)_lmh[_lmh.Count - 1];

                    xHigh.Add(_dX2 + _dDelta);
                    yHigh.Add(_dY1 + _dCurrentSlope * (_dX2 + _dDelta - _dX1));

                    // lower tube
                    _dX1 = (double)xLow[xLow.Count - 1];
                    _dY1 = (double)yLow[yLow.Count - 1];

                    _dCurrentSlope = (double)_lml[_lml.Count - 1];

                    xLow.Add(_dX2 + _dDelta);
                    yLow.Add(_dY1 + _dCurrentSlope * (_dX2 + _dDelta - _dX1));
                }
                report.Lower = new Curve("Lower", xLow.ToArray(), yLow.ToArray());
                report.Upper = new Curve("Upper", xHigh.ToArray(), yHigh.ToArray());
                if (report.Lower.ImportSuccessful && report.Upper.ImportSuccessful)
                    successful = true;
            }
            return report;
        }