Accord.Tests.Interop.Math.LBFGSComparer.Expected C# (CSharp) Method

Expected() public method

public Expected ( Specification problem ) : Info[]
problem Specification
return Info[]
        public Info[] Expected(Specification problem)
        {
            Function function = problem.Function.Invoke;
            Gradient gradient = problem.Gradient.Invoke;

            Param param = new Param()
            {
                m = m,
                epsilon = epsilon,
                past = past,
                delta = delta,
                max_iterations = max_iterations,
                linesearch = (int)linesearch,
                max_linesearch = max_linesearch,
                min_step = min_step,
                max_step = max_step,
                ftol = ftol,
                wolfe = wolfe,
                gtol = gtol,
                xtol = xtol,
                orthantwise_c = orthantwise_c,
                orthantwise_start = orthantwise_start,
                orthantwise_end = orthantwise_end
            };

            NativeCode = Wrapper.Libbfgs((double[])problem.Start.Clone(), function, gradient, param);

            // Convergence and success have the same
            // enumeration value in the original code
            if (NativeCode == "LBFGS_CONVERGENCE")
                NativeCode = "LBFGS_SUCCESS";

            return Wrapper.list.ToArray();
        }

Usage Example

Exemplo n.º 1
0
        public void DefaultBatchTest()
        {
            foreach (var problem in problems)
            {
                LBFGSComparer cmp = new LBFGSComparer();

                var expected = cmp.Expected(problem);
                var actual   = cmp.Actual(problem);

                Assert.AreEqual(expected.Length, actual.Length);
                for (int i = 0; i < expected.Length; i++)
                {
                    var a = actual[i];
                    var e = expected[i];

                    Assert.AreEqual(e.fx, a.Value);

                    for (int j = 0; j < e.g.Length; j++)
                    {
                        Assert.AreEqual(e.g[j], a.Gradient[j]);
                    }
                    Assert.AreEqual(e.gnorm, a.GradientNorm);
                    Assert.AreEqual(e.step, a.Step);
                }
            }
        }
All Usage Examples Of Accord.Tests.Interop.Math.LBFGSComparer::Expected