Accord.Tests.Math.GoldfarbIdnaniTest.RunTest C# (CSharp) Method

RunTest() private method

private RunTest ( ) : void
return void
        public void RunTest()
        {
            double[,] D = Matrix.Identity(3);
            double[] d = { 0, 5, 0 };

            double[,] A = 
            {
                { -4,  2,  0 },
                { -3,  1, -2 },
                {  0,  0,  1 },
            };


            double[] b = { -8, 2, 0 };

            GoldfarbIdnani target = new GoldfarbIdnani(D, d.Multiply(-1), A.Transpose(), b);

            double[] expectedSolution = { 0.4761905, 1.0476190, 2.0952381 };
            double expected = -2.380952;
            Assert.IsTrue(target.Minimize());
            double actual = target.Value;
            Assert.AreEqual(expected, actual, 1e-6);
            Assert.IsFalse(double.IsNaN(actual));
            Assert.AreEqual(3, target.Iterations);

            Assert.AreEqual(0.4761905, target.Solution[0], 1e-6);
            Assert.AreEqual(1.0476190, target.Solution[1], 1e-6);
            Assert.AreEqual(2.0952381, target.Solution[2], 0.02);

            Assert.AreEqual(0.0000000, target.Lagrangian[0], 1e-6);
            Assert.AreEqual(0.2380952, target.Lagrangian[1], 1e-6);
            Assert.AreEqual(2.0952381, target.Lagrangian[2], 1e-6);


            foreach (double v in target.Solution)
                Assert.IsFalse(double.IsNaN(v));

            foreach (double v in target.Lagrangian)
                Assert.IsFalse(double.IsNaN(v));
        }