|
|
@ -4,7 +4,7 @@ |
|
|
// http://github.com/mathnet/mathnet-numerics
|
|
|
// http://github.com/mathnet/mathnet-numerics
|
|
|
// http://mathnetnumerics.codeplex.com
|
|
|
// http://mathnetnumerics.codeplex.com
|
|
|
//
|
|
|
//
|
|
|
// Copyright (c) 2009-2013 Math.NET
|
|
|
// Copyright (c) 2009-2015 Math.NET
|
|
|
//
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
@ -28,22 +28,17 @@ |
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
|
// </copyright>
|
|
|
// </copyright>
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Linq; |
|
|
|
|
|
using System.Text; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using MathNet.Numerics.LinearAlgebra; |
|
|
using MathNet.Numerics.LinearAlgebra; |
|
|
using NUnit.Framework; |
|
|
|
|
|
using MathNet.Numerics.LinearAlgebra.Double; |
|
|
using MathNet.Numerics.LinearAlgebra.Double; |
|
|
using MathNet.Numerics.RootFinding; |
|
|
using MathNet.Numerics.Optimization; |
|
|
|
|
|
using NUnit.Framework; |
|
|
|
|
|
|
|
|
namespace MathNet.Numerics.UnitTests.RootFindingTests |
|
|
namespace MathNet.Numerics.UnitTests.OptimizationTests |
|
|
{ |
|
|
{ |
|
|
[TestFixture, Category("RootFinding")] |
|
|
[TestFixture, Category("RootFinding")] |
|
|
internal class BfgsTest |
|
|
internal class BfgsTest |
|
|
{ |
|
|
{ |
|
|
private const double precision = 1e-4; |
|
|
private const double Precision = 1e-4; |
|
|
|
|
|
|
|
|
[Test] |
|
|
[Test] |
|
|
public void MinimizeRosenbrock() |
|
|
public void MinimizeRosenbrock() |
|
|
@ -56,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.RootFindingTests |
|
|
private static void CheckRosenbrock(double a, double b, double expectedMin) |
|
|
private static void CheckRosenbrock(double a, double b, double expectedMin) |
|
|
{ |
|
|
{ |
|
|
var x = BfgsSolver.Solve(new DenseVector(new[] { a, b }), Rosenbrock, RosenbrockGradient); |
|
|
var x = BfgsSolver.Solve(new DenseVector(new[] { a, b }), Rosenbrock, RosenbrockGradient); |
|
|
Precision.AlmostEqual(expectedMin, Rosenbrock(x), precision); |
|
|
Numerics.Precision.AlmostEqual(expectedMin, Rosenbrock(x), Precision); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static double Rosenbrock(Vector<double> x) |
|
|
private static double Rosenbrock(Vector<double> x) |