Esempio n. 1
0
        public void PolynomialRatingEquationListTimeConstraints()
        {
            //equation to test ( y = 2*x )
            PolynomialEquation eq1 = new PolynomialEquation(
                new double[] { 0, 2.0 }, 10, 50, "test equation");
            //equation to test ( y = 1*x )
            PolynomialEquation eq2 = new PolynomialEquation(
                new double[] { 0, 1.0 }, 10, 50, "test equation");
            Series s = new Series(null, "cfs", TimeInterval.Daily);

            s.Add(DateTime.Parse("2005-01-01"), 10);
            s.Add(DateTime.Parse("2005-01-02"), 20);
            s.Add(DateTime.Parse("2005-01-03"), 50);
            s.Add(DateTime.Parse("2005-01-04"), 60);
            s.Add(DateTime.Parse("2005-01-05"), 2);

            Console.WriteLine("--- input series ----");
            s.WriteToConsole(true);
            DateTime[] t1 = { new DateTime(2005, 1, 1), new DateTime(2005, 1, 2) };
            DateTime[] t2 = { new DateTime(2005, 1, 1), new DateTime(2005, 2, 2) };

            Series sp = Math.Polynomial(s, new PolynomialEquation[] { eq1, eq2 },
                                        t1, t2,
                                        DateTime.Parse("2005-01-01"),
                                        DateTime.Parse("2006-01-01"));

            Console.WriteLine(eq1.ToString());
            Console.WriteLine(eq2.ToString());

            Console.WriteLine("--- polynomial computed series ----");
            sp.WriteToConsole(true);

            Assert.AreEqual(5, sp.Count); // should have 4 return values

            double v = sp.Lookup(DateTime.Parse("2005-01-01"));

            Assert.AreEqual(20, v, 0.00001);


            v = sp.Lookup(DateTime.Parse("2005-01-02"));
            Assert.AreEqual(20, v, 0.00001);

            v = sp.Lookup(DateTime.Parse("2005-01-03"));

            Assert.AreEqual(sp[sp.LookupIndex(DateTime.Parse("2005-01-03"))].Flag, PointFlag.Computed);


            Assert.AreEqual(50, v, 0.00001);

            // should return missing (null) for  jan 4 and jan 6

            v = sp.Lookup(DateTime.Parse("2005-01-04"));
            Assert.AreEqual(Point.MissingValueFlag, v, 0.00001);
            v = sp.Lookup(DateTime.Parse("2005-01-05"));
            Assert.AreEqual(Point.MissingValueFlag, v, 0.00001);
        }
Esempio n. 2
0
        public void PolynomialRatingEquation()
        {
            //simple equation to test ( y = 2*x )
            PolynomialEquation eq = new PolynomialEquation(
                new double[] { 0, 2.0 }, 10, 50, "test equation");
            Series s = new Series(null, "cfs", TimeInterval.Daily);

            s.Add(DateTime.Parse("2005-01-01"), 10);
            s.Add(DateTime.Parse("2005-01-02"), 20);
            s.Add(DateTime.Parse("2005-01-03"), 50);
            s.Add(DateTime.Parse("2005-01-04"), 60);
            s.Add(DateTime.Parse("2005-01-05"), 2);

            Console.WriteLine("--- input series ----");
            s.WriteToConsole(true);
            Series sp = Math.Polynomial(s, eq,
                                        DateTime.Parse("2005-01-02"),
                                        DateTime.Parse("2006-01-01"));

            Console.WriteLine(eq.ToString());

            Console.WriteLine("--- polynomial computed series ----");
            sp.WriteToConsole(true);

            Assert.AreEqual(4, sp.Count); // should have 4 return values

            double v = sp.Lookup(DateTime.Parse("2005-01-02"));

            Assert.AreEqual(40, v, 0.00001);

            v = sp.Lookup(DateTime.Parse("2005-01-03"));

            Assert.AreEqual(sp[sp.LookupIndex(DateTime.Parse("2005-01-03"))].Flag, PointFlag.Computed);


            Assert.AreEqual(100, v, 0.00001);

            // should return missing (null) for  jan 4 and jan 6

            v = sp.Lookup(DateTime.Parse("2005-01-04"));
            Assert.AreEqual(Point.MissingValueFlag, v, 0.00001);
            v = sp.Lookup(DateTime.Parse("2005-01-05"));
            Assert.AreEqual(Point.MissingValueFlag, v, 0.00001);
        }
Esempio n. 3
0
        public void PolynomialRatingEquation()
        {
            //simple equation to test ( y = 2*x )
              PolynomialEquation eq = new PolynomialEquation(
            new double[]{0, 2.0},10, 50,"test equation");
             Series s = new Series(null,"cfs",TimeInterval.Daily);
              s.Add(DateTime.Parse("2005-01-01"),10);
              s.Add(DateTime.Parse("2005-01-02"),20);
              s.Add(DateTime.Parse("2005-01-03"),50);
              s.Add(DateTime.Parse("2005-01-04"),60);
              s.Add(DateTime.Parse("2005-01-05"),2);

              Console.WriteLine("--- input series ----");
            s.WriteToConsole(true);
              Series sp = Math.Polynomial(s,eq,
            DateTime.Parse("2005-01-02"),
            DateTime.Parse("2006-01-01"));
              Console.WriteLine(eq.ToString());

              Console.WriteLine("--- polynomial computed series ----");
              sp.WriteToConsole(true);

              Assert.AreEqual(4,sp.Count); // should have 4 return values

              double v = sp.Lookup(DateTime.Parse("2005-01-02"));
              Assert.AreEqual(40,v,0.00001);

              v = sp.Lookup(DateTime.Parse("2005-01-03"));

              Assert.AreEqual(sp[sp.LookupIndex(DateTime.Parse("2005-01-03"))].Flag,PointFlag.Computed);

            Assert.AreEqual(100,v,0.00001);

              // should return missing (null) for  jan 4 and jan 6

              v = sp.Lookup(DateTime.Parse("2005-01-04"));
              Assert.AreEqual(Point.MissingValueFlag,v,0.00001);
              v = sp.Lookup(DateTime.Parse("2005-01-05"));
              Assert.AreEqual(Point.MissingValueFlag,v,0.00001);
        }
Esempio n. 4
0
        public void PolynomialRatingEquationListTimeConstraints()
        {
            //equation to test ( y = 2*x )
              PolynomialEquation eq1 = new PolynomialEquation(
            new double[]{0, 2.0},10, 50,"test equation");
              //equation to test ( y = 1*x )
              PolynomialEquation eq2 = new PolynomialEquation(
            new double[]{0, 1.0},10, 50,"test equation");
              Series s = new Series(null,"cfs",TimeInterval.Daily);
              s.Add(DateTime.Parse("2005-01-01"),10);
              s.Add(DateTime.Parse("2005-01-02"),20);
              s.Add(DateTime.Parse("2005-01-03"),50);
              s.Add(DateTime.Parse("2005-01-04"),60);
              s.Add(DateTime.Parse("2005-01-05"),2);

              Console.WriteLine("--- input series ----");
              s.WriteToConsole(true);
              DateTime[] t1 = { new DateTime(2005,1,1), new DateTime(2005,1,2)};
              DateTime[] t2 = { new DateTime(2005,1,1), new DateTime(2005,2,2)};

              Series sp = Math.Polynomial(s,new PolynomialEquation[] {eq1,eq2},
            t1,t2,
            DateTime.Parse("2005-01-01"),
            DateTime.Parse("2006-01-01"));
              Console.WriteLine(eq1.ToString());
              Console.WriteLine(eq2.ToString());

              Console.WriteLine("--- polynomial computed series ----");
              sp.WriteToConsole(true);

              Assert.AreEqual(5,sp.Count); // should have 4 return values

              double v = sp.Lookup(DateTime.Parse("2005-01-01"));
              Assert.AreEqual(20,v,0.00001);

              v = sp.Lookup(DateTime.Parse("2005-01-02"));
              Assert.AreEqual(20,v,0.00001);

              v = sp.Lookup(DateTime.Parse("2005-01-03"));

              Assert.AreEqual(sp[sp.LookupIndex(DateTime.Parse("2005-01-03"))].Flag,PointFlag.Computed);

              Assert.AreEqual(50,v,0.00001);

              // should return missing (null) for  jan 4 and jan 6

              v = sp.Lookup(DateTime.Parse("2005-01-04"));
              Assert.AreEqual(Point.MissingValueFlag,v,0.00001);
              v = sp.Lookup(DateTime.Parse("2005-01-05"));
              Assert.AreEqual(Point.MissingValueFlag,v,0.00001);
        }