示例#1
0
文件: BATests.cs 项目: iliaeg/ADBench
        void CheckJacobianCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetBATest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadBAInstance("batest.txt");

                module.Prepare(input);
                module.CalculateJacobian(times);

                var output = module.Output();


                var correct_jacobian_nrows = 30;
                var correct_jacobian_ncols = 62;
                var correct_jacobian_rows  = new[] { 0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310 };
                var correct_jacobian_cols  = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 23, 24, 52, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 23, 24, 52, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26, 27, 53, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26, 27, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 28, 29, 30, 54, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 28, 29, 30, 54, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 31, 32, 33, 55, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 31, 32, 33, 55, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 34, 35, 36, 56, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 34, 35, 36, 56, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 37, 38, 39, 57, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 37, 38, 39, 57, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 40, 41, 42, 58, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 40, 41, 42, 58, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 43, 44, 45, 59, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 43, 44, 45, 59, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 46, 47, 48, 60, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 46, 47, 48, 60, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 49, 50, 51, 61, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 49, 50, 51, 61, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61 };
                var correct_jacobian_vals  = new[] { 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, 2.28877202208246757e+02, 6.34574811495545418e+02, -7.82222866259340549e+02, 2.42892615607159668e+00, -1.17828079628011313e+01, 2.54169312487743460e+00, -1.03657084958518086e+00, 4.17022000000000004e-01, 0.00000000000000000e+00, -3.50739521096005205e+02, -9.12107773668008576e+02, -2.42892615607159668e+00, 1.17828079628011313e+01, -2.54169312487743460e+00, -6.45167039712987389e-01, -1.20542435994996879e+02, -3.85673240766460424e+02, 9.75476291403326456e+01, -1.78372108529576567e+00, 4.15466799433126077e+00, 2.04025718029898906e+00, 3.49176397433145880e-01, 0.00000000000000000e+00, 4.17022000000000004e-01, 1.18149147704414503e+02, 3.07250108960343255e+02, 1.78372108529576567e+00, -4.15466799433126077e+00, -2.04025718029898906e+00, 6.23335921553064054e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01, -8.34044000000000008e-01 };

                Assert.Equal(correct_jacobian_nrows, output.J.NRows);
                Assert.Equal(correct_jacobian_ncols, output.J.NCols);
                Assert.Equal(correct_jacobian_rows, output.J.Rows);
                Assert.Equal(correct_jacobian_cols, output.J.Cols);
                Assert.Equal(correct_jacobian_vals, output.J.Vals, comparer);
            }
        }
示例#2
0
        void CheckComplicatedJacobianCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetHandTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadHandInstance("hand_complicatedtest.txt", true);

                module.Prepare(input);
                module.CalculateJacobian(times);

                var output = module.Output();

                var correctJacobian = new[]
                {
                    new[] { 3.19994705650605837e-03, 5.94121036324768426e-03, -3.16780414139280486e-02, 2.51273846313546725e-02, -3.43751692490045363e-02, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -2.67300459304900973e-03, -2.05375964421033422e-04, -0.00000000000000000e+00, -0.00000000000000000e+00 },
                    new[] { -5.83664316352128232e-03, -2.25087272196717869e-02, -1.17603133455238852e-02, -6.73431005210687033e-03, -7.93824304538508912e-02, 0.00000000000000000e+00, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 2.51903206295353913e-03, 6.35746365607068199e-03, 0.00000000000000000e+00, 0.00000000000000000e+00 },
                    new[] { 5.26539698350125818e-03, -7.98030902470658887e-04, -4.00357012848860105e-02, 4.48594779455911905e-02, 1.08995867664168408e-02, 0.00000000000000000e+00, 0.00000000000000000e+00, -1.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -1.65741767881614870e-03, 2.11520284492772506e-03, -0.00000000000000000e+00, -0.00000000000000000e+00 },
                    new[] { 6.09513107611836524e-03, 4.72340259356063275e-03, -2.21424420388885296e-02, 3.97751453573731983e-02, -8.70476400071599210e-02, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, -3.33849263402929107e-03, 1.28209220660817119e-03, -0.00000000000000000e+00, -0.00000000000000000e+00, 1.37205123955743335e-03, -5.45177232375653083e-03, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00 },
                    new[] { -1.30273083127474543e-02, 5.73648537699011918e-03, -9.03798668988376082e-03, -1.01785098875940283e-02, -4.37081649532052238e-02, 0.00000000000000000e+00, -1.00000000000000000e+00, 0.00000000000000000e+00, 9.53458231126915585e-04, 4.01972269593312698e-03, 0.00000000000000000e+00, 0.00000000000000000e+00, -9.33621518070085026e-04, -1.38222424349224984e-03, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00 },
                    new[] { -1.97054905573765815e-02, 8.52371287096032049e-03, 1.63019777955282150e-03, 7.14646422504415374e-02, 2.94403102374449152e-02, 0.00000000000000000e+00, 0.00000000000000000e+00, -1.00000000000000000e+00, 3.24947244952083786e-03, 8.49942589390221431e-04, -0.00000000000000000e+00, -0.00000000000000000e+00, -5.87537490240527642e-03, 2.95494237613404438e-03, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00 }
                };

                Assert.Equal(correctJacobian.Length, output.Jacobian.Length);
                for (int i = 0; i < correctJacobian.Length; ++i)
                {
                    Assert.Equal(correctJacobian[i], output.Jacobian[i], comparer);
                }
            }
        }
示例#3
0
文件: BATests.cs 项目: iliaeg/ADBench
        // helper methods
        void CheckObjectiveCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetBATest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadBAInstance("batest.txt");

                module.Prepare(input);
                module.CalculateObjective(times);

                var output = module.Output();

                for (int i = 0; i < 20; i += 2)
                {
                    Assert.Equal(-2.69048849235189402e-01, output.ReprojErr[i], comparer);
                    Assert.Equal(2.59944792677901881e-01, output.ReprojErr[i + 1], comparer);
                }
                for (int i = 0; i < 10; i++)
                {
                    Assert.Equal(8.26092651515999976e-01, output.WErr[i], comparer);
                }
            }
        }
示例#4
0
        void CheckSimpleJacobianCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetHandTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadHandInstance("handtest.txt", false);

                module.Prepare(input);
                module.CalculateJacobian(times);

                var output = module.Output();

                var correctJacobian = new[]
                {
                    new[] { -1.95512959341282745e-02, 1.18421319736437044e-02, -1.08140043450366714e-02, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -2.21537299179855318e-02, 2.98023294354714807e-02, -8.89718384720838799e-03, -2.24887887916698764e-03 },
                    new[] { -6.81027576369377941e-03, 1.74108797580776152e-03, -6.54731655106268462e-02, 0.00000000000000000e+00, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 1.42669175415592216e-02, 2.58519935565392558e-02, 2.30412622537484605e-03, 3.09895230315512067e-03 },
                    new[] { -4.09359630708754085e-02, 2.57836165362687400e-02, 2.95529253068245066e-03, 0.00000000000000000e+00, 0.00000000000000000e+00, -1.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -3.12350905279757118e-02, -9.40429974684049881e-03, -1.84753145105870202e-02, -3.09211880497457705e-04 },
                    new[] { -7.10032003143440671e-02, 5.14892578985870278e-02, -6.33408854067304267e-02, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -3.45326893768281365e-02, -1.95437595587887036e-02, -1.29102628630682510e-02, 1.99738182488361877e-03, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00 },
                    new[] { -2.81346929141111299e-02, -4.50591977492771356e-02, -8.98189200086859235e-02, 0.00000000000000000e+00, -1.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 2.42024596962444292e-02, -1.84392814127634017e-02, 9.76606245804552756e-03, -1.42570914120403679e-03, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00, 0.00000000000000000e+00 },
                    new[] { -2.54484136783155838e-02, 6.23981738234076627e-02, 2.07440902671436785e-02, 0.00000000000000000e+00, 0.00000000000000000e+00, -1.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -3.10675692993888850e-03, 6.52740542794425036e-03, 8.49553578389919579e-03, -4.35490319929073976e-04, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00, -0.00000000000000000e+00 }
                };

                Assert.Equal(correctJacobian.Length, output.Jacobian.Length);
                for (int i = 0; i < correctJacobian.Length; ++i)
                {
                    Assert.Equal(correctJacobian[i], output.Jacobian[i], comparer);
                }
            }
        }
示例#5
0
        // helper methods
        void CheckObjectiveCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetGMMTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadGMMInstance("gmmtest.txt", false);

                module.Prepare(input);
                module.CalculateObjective(times);

                var output = module.Output();

                Assert.Equal(8.07380408004975791, output.Objective, comparer);
            }
        }
示例#6
0
        // helper methods
        void CheckObjectiveCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetLSTMTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadLSTMInstance("lstm_l2_c1024.txt");

                module.Prepare(input);
                module.CalculateObjective(times);

                var output = module.Output();

                Assert.Equal(6.66665179558852183e-01, output.Objective, comparer);
            }
        }
示例#7
0
        void CheckComplicatedObjectiveCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetHandTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadHandInstance("hand_complicatedtest.txt", true);

                module.Prepare(input);
                module.CalculateObjective(times);

                var output = module.Output();

                var correctObjective = new[] { 1.56187661696463698e-01, -1.49300526003322220e-01, 1.72238089826454832e-01, -9.88770451849596554e-02, -1.61238035462101248e-02, -1.97586768465579654e-01 };
                Assert.Equal(correctObjective, output.Objective, comparer);
            }
        }
示例#8
0
        // helper methods
        void CheckSimpleObjectiveCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetHandTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadHandInstance("handtest.txt", false);

                module.Prepare(input);
                module.CalculateObjective(times);

                var output = module.Output();

                var correctObjective = new[] { 1.65193147941611551e-01, -1.74542769272742593e-01, 1.54751161622253441e-01, -1.25651749731793605e-01, -4.25102935355075040e-02, -1.30665781132340175e-01 };
                Assert.Equal(correctObjective, output.Objective, comparer);
            }
        }
示例#9
0
        void CheckJacobianCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetGMMTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadGMMInstance("gmmtest.txt", false);

                module.Prepare(input);
                module.CalculateJacobian(times);

                var output = module.Output();

                var correct_gradient = new[] { 1.08662855508652456e-01, -7.41270039523898472e-01, 6.32607184015246071e-01, 1.11692576532787013e+00, 1.63333013551455269e-01, -2.19989824071193142e-02, 2.27778292254236098e-01, 1.20963025612832187e+00, -6.06375920733956339e-02, 2.58529994051162237e+00, 1.12632694524213789e-01, 3.85744309849611777e-01, 7.35180573182305508e-02, 5.41836362715595232e+00, -3.21494409677446469e-01, 1.71892309775004937e+00, 8.60091090790866875e-01, -9.94640930466322848e-01 };

                Assert.Equal(correct_gradient, output.Gradient, comparer);
            }
        }
示例#10
0
        void CheckJacobianCalculation(string moduleName, double tolerance, int times)
        {
            using (var moduleLoader = new ModuleLoader(moduleName))
            {
                var module = moduleLoader.GetLSTMTest();
                Assert.NotNull(module);
                var comparer = new TolerantDoubleComparer(tolerance);

                // Read instance
                var input = DataLoader.ReadLSTMInstance("lstm_l2_c1024.txt");

                module.Prepare(input);
                module.CalculateJacobian(times);

                var output = module.Output();

                var correct_gradient = new[] { 3.14387024996101187e-06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -3.67840807336070475e-05, -1.54848612683180522e-04, 5.48717267869773910e-06, -4.04527413533285253e-06, -8.77353908686236070e-07, -1.81973718092835457e-06, -6.61404620766666418e-07, 1.25432314145999742e-04, 5.26459549995064566e-06, 3.42833197850334681e-06, 2.79076684010150125e-05, 4.45603055235501376e-05, 4.04185405141412220e-05, 1.13487138666022078e-05, -7.36119414163935681e-05, -3.92318596883106641e-04, 6.03607595779890245e-06, -2.50749024433336479e-05, -4.83955404587018941e-06, -4.94175793354897013e-06, -1.49848451794559008e-06, 4.01789457601843220e-06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -6.16501771215585166e-05, -2.14471058586458561e-04, 5.56661202545761896e-06, -5.22021372686648383e-06, -1.95401365542668346e-06, -4.68776054707821880e-06, -2.67879854428802963e-06, 8.49896476968742872e-04, 2.14480696808520274e-04, 1.27240956373907973e-04, 1.03380278076147588e-04, 3.26983387274766885e-05, 1.47321495437521366e-04, 2.03767485364521309e-05, -1.71027241883012373e-04, -9.97102906947628905e-04, 1.05573445256271496e-04, -4.10813160791978987e-05, -4.66363145389210376e-06, -5.61458724856520127e-06, -1.72719535440704236e-06, 7.41562400488615767e-04, 1.35905892236421730e-04, 9.18319427682989299e-05, 1.14039861417365726e-04, 1.31037490514354042e-04, 1.89958003915723621e-04, 6.66667089111214168e-05, -2.99753093683376040e-04, -1.39428488543169235e-03, 7.81997486731591678e-05, -7.11003463557882681e-05, -1.56689414959509608e-05, -1.59132673852719420e-05, -5.88701856095873723e-06, 3.65214776221949554e-04, 1.08440867176087962e-04, 6.75251197117822909e-05, 5.07904844905876160e-05, 6.94964603070496247e-05, 9.71513382958139477e-05, 2.40897410354102865e-05, -1.31891358419510490e-04, -7.36772740642002493e-04, 4.48757608883305795e-05, -4.51743229379305454e-05, -7.63715831354149397e-06, -8.36900345795258848e-06, -2.41858043904271068e-06, 8.00930878140701909e-04, 8.05738754618121506e-05, 7.04205639535801850e-05, 1.34615500556859374e-04, 2.07383290113708586e-04, 2.94203848388590759e-04, 2.08296283404346797e-04, -5.00619564307732703e-04, -1.90384053275097134e-03, 6.83889421204583172e-05, -8.85415990620916452e-05, -4.01278522469193820e-05, -3.19293895829058307e-05, -2.48575295654621768e-05, 2.47822472805507175e-03, 5.07502578529807780e-03, 2.53859920727141910e-03, 1.88350319998056696e-04, 5.10157230919509725e-05, 3.54335963584264193e-04, 4.32702650224108475e-05, -3.06537980830570744e-04, -1.87256106103047193e-03, 7.86527299400905083e-04, -7.40280147056494078e-05, -7.36222276800657044e-06, -9.51938152613299431e-06, -2.78936845972344488e-06, 5.38571851736894072e-04, 4.12509633131798620e-05, 6.47788903296268593e-05, 3.76860255482900047e-04, 1.00145332877384172e-03, 2.29657803047558681e-04, 4.44627297218581029e-04, -9.73952035222110210e-04, -4.51211367568013846e-03, 1.41925554887538418e-04, -1.66675086094364628e-05, -2.28915871203058926e-05, -6.90861176975165640e-05, -2.81513790989548166e-04, 2.53531909024735675e-04, 2.91530880231834222e-04, 2.87839568382086426e-04, 6.61417346851010207e-05, 6.11690024226054017e-04, 1.08165251111585849e-04, 9.94833840089197921e-05, -5.39732825546851164e-04, -1.95313692267145384e-03, 2.87262803065020395e-04, -6.42028361615228470e-06, -6.81225636233755266e-06, -3.58438396937832646e-05, -1.41607977576401395e-04, 9.90063334626659942e-04, 6.71457692678222891e-05, 9.64171460882922153e-05, 2.83657185457934097e-04, 1.41431021522050158e-03, 7.42601545855336369e-04, 1.63135992873617838e-04, -1.80905573085369175e-03, -5.78938583485935632e-03, 1.08933179139588087e-04, -2.82053334001221257e-04, -1.58448932394055300e-04, -1.62053197372598410e-04, -4.44062656277905885e-04, 1.23784405389406552e-03, 3.70797204635395672e-04, 8.95872992208362269e-04, 9.54650103551505725e-04, 7.94492683033071450e-04, 1.33045599071493839e-04, 1.90972131022078425e-03, -1.27723370300947075e-03, -7.98761497515965146e-03, 1.31804902759735014e-03, -1.18749502523366873e-05, -1.17265333639628955e-05, -5.72852084344175575e-05, -1.76267731147033947e-04, 1.57111882911252715e-03, 9.63872765804848195e-04, 1.29692708705586861e-03, 6.85018812295237929e-04, 1.56084730076406770e-03, 5.51507203835322228e-04, 9.44664300904442429e-04, -1.74595527620669054e-03, -8.47272040239691569e-03, 1.06146398161773513e-03, -3.01166484114288631e-05, -3.61150963335128990e-05, -1.17040277318999298e-04, -4.53714566010890040e-04, 4.83883598142451641e-04, 5.36532886336024261e-04, 7.10491025781043260e-04, 4.03370948422198858e-04, 9.21362107223384799e-04, 1.83544588672272390e-04, 5.84842906913008364e-04, -9.12226698645542925e-04, -3.71928760349100754e-03, 5.24341732641706525e-04, -8.78104574502159225e-06, -9.40356235117202346e-06, -6.16753351894278713e-05, -2.59729129852274867e-04, 2.88643409216300618e-03, 1.56939967321338843e-03, 1.92928469338899343e-03, 5.15538874537588353e-04, 2.20418224227594915e-03, 1.78306235870001779e-03, 3.46590677977152962e-04, -3.24323971790235277e-03, -1.08700028019174302e-02, 8.13601709951329772e-04, -5.09026696834261072e-04, -2.50224828500900109e-04, -2.74229202243154427e-04, -7.15862244954266883e-04, 2.36221822129175068e-03, 6.82455302403955932e-04, 2.21184971904590886e-03, 5.81458374769466737e-03, 1.19699412544996883e-03, 2.26008787507052335e-04, 1.12207195875873196e-02, -2.15943584477549123e-03, -1.52105422913329149e-02, 2.40692059621100754e-03, -1.62908509623434489e-05, -1.62307954324598644e-05, -9.93149651364052892e-05, -3.23349485361925845e-04, 8.95056656284422921e-06, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.73683965955792591e-04, -3.21979564391077671e-04, 7.71925547683623476e-06, -2.98807224102069401e-05, -1.11738854533001905e-05, -2.92505411923477579e-06, -2.04187281292674588e-06, 1.14042748169088035e-02, 9.93947389065250562e-03, 4.53876797372907911e-03, 1.46753585074672422e-03, 1.59578501610211192e-02, 7.13215996147348839e-03, 2.52120644391976836e-03, -1.79990239825079217e-02, -2.62659614088943671e-02, 2.44293992080160194e-03, -3.67074714937877696e-03, -1.31444481103537205e-02, -4.54999892021307108e-03, -1.09270983790279372e-02, 2.17348662792538061e-02, 1.82857375496154884e-02, 1.11887441899222798e-02, 8.97672919990902263e-03, 2.39853893219980456e-02, 1.20800375241284126e-02, 1.48638788575309582e-02, -3.02324690101714345e-02, -5.00116775406580991e-02, 4.46620942840666828e-03, -5.23602406001136191e-03, -1.79316285235904226e-02, -7.73167106472800580e-03, -2.00225690895980656e-02 };

                Assert.Equal(correct_gradient, output.Gradient, comparer);
            }
        }