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

RunTest5() private method

private RunTest5 ( ) : void
return void
        public void RunTest5()
        {
            // example from http://www.mail-archive.com/[email protected]/msg00831.html

            var cma = Matrix.Identity(10);

            var dva = new double[10];

            double[,] Ama =
            {
                {  1, 1, -1, 0,  0, 0,  0, 0,  0, 0,  0, 0 },
                { -1, 1,  0, 1,  0, 0,  0, 0,  0, 0,  0, 0 },
                {  1, 1,  0, 0, -1, 0,  0, 0,  0, 0,  0, 0 },
                { -1, 1,  0, 0,  0, 1,  0, 0,  0, 0,  0, 0 },
                {  1, 1,  0, 0,  0, 0, -1, 0,  0, 0,  0, 0 },
                { -1, 1,  0, 0,  0, 0,  0, 1,  0, 0,  0, 0 },
                {  1, 1,  0, 0,  0, 0,  0, 0, -1, 0,  0, 0 },
                { -1, 1,  0, 0,  0, 0,  0, 0,  0, 1,  0, 0 },
                {  1, 1,  0, 0,  0, 0,  0, 0,  0, 0, -1, 0 },
                { -1, 1,  0, 0,  0, 0,  0, 0,  0, 0,  0, 1 },
            };

            double[] bva = { 1, 1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0 };

            int meq = 2;

            GoldfarbIdnani target = new GoldfarbIdnani(cma, dva.Multiply(-1), Ama.Transpose(), bva, meq);

            Assert.IsTrue(target.Minimize());
            double value = target.Value;

            for (int i = 0; i < target.Solution.Length; i += 2)
            {
                int N = target.Solution.Length / 2;
                Assert.AreEqual(1.0 / N, target.Solution[i], 1e-6);
                Assert.AreEqual(0.0, target.Solution[i + 1], 1e-6);
            }

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

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

        }