NonLinearOptimization.cpp File Reference
#include <stdio.h>
#include "main.h"
#include <unsupported/Eigen/NonLinearOptimization>
#include <Eigen/src/Core/util/DisableStupidWarnings.h>

Classes

struct  Functor< Scalar_, NX, NY >
 
struct  lmder_functor
 
struct  hybrj_functor
 
struct  hybrd_functor
 
struct  lmstr_functor
 
struct  lmdif_functor
 
struct  chwirut2_functor
 
struct  misra1a_functor
 
struct  hahn1_functor
 
struct  misra1d_functor
 
struct  lanczos1_functor
 
struct  rat42_functor
 
struct  MGH10_functor
 
struct  BoxBOD_functor
 
struct  MGH17_functor
 
struct  MGH09_functor
 
struct  Bennett5_functor
 
struct  thurber_functor
 
struct  rat43_functor
 
struct  eckerle4_functor
 

Macros

#define LM_EVAL_COUNT_TOL   2
 
#define LM_CHECK_N_ITERS(SOLVER, NFEV, NJEV)
 

Functions

int fcn_chkder (const VectorXd &x, VectorXd &fvec, MatrixXd &fjac, int iflag)
 
void testChkder ()
 
void testLmder1 ()
 
void testLmder ()
 
void testHybrj1 ()
 
void testHybrj ()
 
void testHybrd1 ()
 
void testHybrd ()
 
void testLmstr1 ()
 
void testLmstr ()
 
void testLmdif1 ()
 
void testLmdif ()
 
void testNistChwirut2 (void)
 
void testNistMisra1a (void)
 
void testNistHahn1 (void)
 
void testNistMisra1d (void)
 
void testNistLanczos1 (void)
 
void testNistRat42 (void)
 
void testNistMGH10 (void)
 
void testNistBoxBOD (void)
 
void testNistMGH17 (void)
 
void testNistMGH09 (void)
 
void testNistBennett5 (void)
 
void testNistThurber (void)
 
void testNistRat43 (void)
 
void testNistEckerle4 (void)
 
 EIGEN_DECLARE_TEST (NonLinearOptimization)
 

Macro Definition Documentation

◆ LM_CHECK_N_ITERS

#define LM_CHECK_N_ITERS (   SOLVER,
  NFEV,
  NJEV 
)
Value:
{ \
VERIFY(SOLVER.nfev <= NFEV * LM_EVAL_COUNT_TOL); \
VERIFY(SOLVER.njev <= NJEV * LM_EVAL_COUNT_TOL); \
}
#define LM_EVAL_COUNT_TOL
Definition: NonLinearOptimization.cpp:16

◆ LM_EVAL_COUNT_TOL

#define LM_EVAL_COUNT_TOL   2

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( NonLinearOptimization  )
1824  {
1825  // Tests using the examples provided by (c)minpack
1826  CALL_SUBTEST /*_1*/ (testChkder());
1827  CALL_SUBTEST /*_1*/ (testLmder1());
1828  CALL_SUBTEST /*_1*/ (testLmder());
1829  CALL_SUBTEST /*_2*/ (testHybrj1());
1830  CALL_SUBTEST /*_2*/ (testHybrj());
1831  CALL_SUBTEST /*_2*/ (testHybrd1());
1832  CALL_SUBTEST /*_2*/ (testHybrd());
1833  CALL_SUBTEST /*_3*/ (testLmstr1());
1834  CALL_SUBTEST /*_3*/ (testLmstr());
1835  CALL_SUBTEST /*_3*/ (testLmdif1());
1836  CALL_SUBTEST /*_3*/ (testLmdif());
1837 
1838  // NIST tests, level of difficulty = "Lower"
1839  CALL_SUBTEST /*_4*/ (testNistMisra1a());
1840  CALL_SUBTEST /*_4*/ (testNistChwirut2());
1841 
1842  // NIST tests, level of difficulty = "Average"
1843  CALL_SUBTEST /*_5*/ (testNistHahn1());
1844  CALL_SUBTEST /*_6*/ (testNistMisra1d());
1845  CALL_SUBTEST /*_7*/ (testNistMGH17());
1846  CALL_SUBTEST /*_8*/ (testNistLanczos1());
1847 
1848  // // NIST tests, level of difficulty = "Higher"
1849  CALL_SUBTEST /*_9*/ (testNistRat42());
1850  // CALL_SUBTEST/*_10*/(testNistMGH10());
1851  CALL_SUBTEST /*_11*/ (testNistBoxBOD());
1852  // CALL_SUBTEST/*_12*/(testNistMGH09());
1853  CALL_SUBTEST /*_13*/ (testNistBennett5());
1854  CALL_SUBTEST /*_14*/ (testNistThurber());
1855  CALL_SUBTEST /*_15*/ (testNistRat43());
1856  CALL_SUBTEST /*_16*/ (testNistEckerle4());
1857 }
void testNistEckerle4(void)
Definition: NonLinearOptimization.cpp:1779
void testLmder1()
Definition: NonLinearOptimization.cpp:148
void testHybrj1()
Definition: NonLinearOptimization.cpp:251
void testHybrj()
Definition: NonLinearOptimization.cpp:278
void testLmstr()
Definition: NonLinearOptimization.cpp:448
void testLmdif()
Definition: NonLinearOptimization.cpp:528
void testLmder()
Definition: NonLinearOptimization.cpp:175
void testNistBoxBOD(void)
Definition: NonLinearOptimization.cpp:1221
void testNistRat43(void)
Definition: NonLinearOptimization.cpp:1691
void testNistBennett5(void)
Definition: NonLinearOptimization.cpp:1510
void testLmstr1()
Definition: NonLinearOptimization.cpp:420
void testNistHahn1(void)
Definition: NonLinearOptimization.cpp:823
void testHybrd()
Definition: NonLinearOptimization.cpp:352
void testNistThurber(void)
Definition: NonLinearOptimization.cpp:1603
void testChkder()
Definition: NonLinearOptimization.cpp:64
void testLmdif1()
Definition: NonLinearOptimization.cpp:499
void testNistMisra1a(void)
Definition: NonLinearOptimization.cpp:696
void testNistRat42(void)
Definition: NonLinearOptimization.cpp:1074
void testNistMisra1d(void)
Definition: NonLinearOptimization.cpp:906
void testNistChwirut2(void)
Definition: NonLinearOptimization.cpp:619
void testNistMGH17(void)
Definition: NonLinearOptimization.cpp:1308
void testHybrd1()
Definition: NonLinearOptimization.cpp:326
void testNistLanczos1(void)
Definition: NonLinearOptimization.cpp:989
#define CALL_SUBTEST(FUNC)
Definition: main.h:382

References CALL_SUBTEST, testChkder(), testHybrd(), testHybrd1(), testHybrj(), testHybrj1(), testLmder(), testLmder1(), testLmdif(), testLmdif1(), testLmstr(), testLmstr1(), testNistBennett5(), testNistBoxBOD(), testNistChwirut2(), testNistEckerle4(), testNistHahn1(), testNistLanczos1(), testNistMGH17(), testNistMisra1a(), testNistMisra1d(), testNistRat42(), testNistRat43(), and testNistThurber().

◆ fcn_chkder()

int fcn_chkder ( const VectorXd &  x,
VectorXd &  fvec,
MatrixXd &  fjac,
int  iflag 
)
24  {
25  /* subroutine fcn for chkder example. */
26 
27  int i;
28  assert(15 == fvec.size());
29  assert(3 == x.size());
30  double tmp1, tmp2, tmp3, tmp4;
31  static const double y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, 3.9e-1,
32  3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39};
33 
34  if (iflag == 0) return 0;
35 
36  if (iflag != 2)
37  for (i = 0; i < 15; i++) {
38  tmp1 = i + 1;
39  tmp2 = 16 - i - 1;
40  tmp3 = tmp1;
41  if (i >= 8) tmp3 = tmp2;
42  fvec[i] = y[i] - (x[0] + tmp1 / (x[1] * tmp2 + x[2] * tmp3));
43  }
44  else {
45  for (i = 0; i < 15; i++) {
46  tmp1 = i + 1;
47  tmp2 = 16 - i - 1;
48 
49  /* error introduced into next statement for illustration. */
50  /* corrected statement should read tmp3 = tmp1 . */
51 
52  tmp3 = tmp2;
53  if (i >= 8) tmp3 = tmp2;
54  tmp4 = (x[1] * tmp2 + x[2] * tmp3);
55  tmp4 = tmp4 * tmp4;
56  fjac(i, 0) = -1.;
57  fjac(i, 1) = tmp1 * tmp2 / tmp4;
58  fjac(i, 2) = tmp1 * tmp3 / tmp4;
59  }
60  }
61  return 0;
62 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define assert(e,...)
Definition: Logger.h:744
Scalar * y
Definition: level1_cplx_impl.h:128
list x
Definition: plotDoE.py:28

References assert, i, plotDoE::x, and y.

Referenced by testChkder().

◆ testChkder()

void testChkder ( )
64  {
65  const int m = 15, n = 3;
66  VectorXd x(n), fvec(m), xp, fvecp(m), err;
67  MatrixXd fjac(m, n);
68  VectorXi ipvt;
69 
70  /* the following values should be suitable for */
71  /* checking the jacobian matrix. */
72  x << 9.2e-1, 1.3e-1, 5.4e-1;
73 
74  internal::chkder(x, fvec, fjac, xp, fvecp, 1, err);
75  fcn_chkder(x, fvec, fjac, 1);
76  fcn_chkder(x, fvec, fjac, 2);
77  fcn_chkder(xp, fvecp, fjac, 1);
78  internal::chkder(x, fvec, fjac, xp, fvecp, 2, err);
79 
80  fvecp -= fvec;
81 
82  // check those
83  VectorXd fvec_ref(m), fvecp_ref(m), err_ref(m);
84  fvec_ref << -1.181606, -1.429655, -1.606344, -1.745269, -1.840654, -1.921586, -1.984141, -2.022537, -2.468977,
85  -2.827562, -3.473582, -4.437612, -6.047662, -9.267761, -18.91806;
86  fvecp_ref << -7.724666e-09, -3.432406e-09, -2.034843e-10, 2.313685e-09, 4.331078e-09, 5.984096e-09, 7.363281e-09,
87  8.53147e-09, 1.488591e-08, 2.33585e-08, 3.522012e-08, 5.301255e-08, 8.26666e-08, 1.419747e-07, 3.19899e-07;
88  err_ref << 0.1141397, 0.09943516, 0.09674474, 0.09980447, 0.1073116, 0.1220445, 0.1526814, 1, 1, 1, 1, 1, 1, 1, 1;
89 
90  VERIFY_IS_APPROX(fvec, fvec_ref);
91  VERIFY_IS_APPROX(fvecp, fvecp_ref);
92  VERIFY_IS_APPROX(err, err_ref);
93 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
int fcn_chkder(const VectorXd &x, VectorXd &fvec, MatrixXd &fjac, int iflag)
Definition: NonLinearOptimization.cpp:24
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
int * m
Definition: level2_cplx_impl.h:294
void chkder(const Matrix< Scalar, Dynamic, 1 > &x, const Matrix< Scalar, Dynamic, 1 > &fvec, const Matrix< Scalar, Dynamic, Dynamic > &fjac, Matrix< Scalar, Dynamic, 1 > &xp, const Matrix< Scalar, Dynamic, 1 > &fvecp, int mode, Matrix< Scalar, Dynamic, 1 > &err)
Definition: chkder.h:12

References Eigen::internal::chkder(), fcn_chkder(), m, n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testHybrd()

void testHybrd ( )
352  {
353  const int n = 9;
354  int info;
355  VectorXd x;
356 
357  /* the following starting values provide a rough fit. */
358  x.setConstant(n, -1.);
359 
360  // do the computation
361  hybrd_functor functor;
363  solver.parameters.nb_of_subdiagonals = 1;
364  solver.parameters.nb_of_superdiagonals = 1;
365  solver.diag.setConstant(n, 1.);
366  solver.useExternalScaling = true;
367  info = solver.solveNumericalDiff(x);
369 
370  // check return value
371  // VERIFY_IS_EQUAL(info, 1);
372  VERIFY(solver.nfev <= 14 * LM_EVAL_COUNT_TOL);
373 
374  // check norm
375  VERIFY_IS_APPROX(solver.fvec.blueNorm(), 1.192636e-08);
376 
377  // check x
378  VectorXd x_ref(n);
379  x_ref << -0.5706545, -0.6816283, -0.7017325, -0.7042129, -0.701369, -0.6918656, -0.665792, -0.5960342, -0.4164121;
380  VERIFY_IS_APPROX(x, x_ref);
381 }
BiCGSTAB< SparseMatrix< double > > solver
Definition: BiCGSTAB_simple.cpp:5
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:966
Finds a zero of a system of n nonlinear functions in n variables by a modification of the Powell hybr...
Definition: HybridNonLinearSolver.h:46
int info
Definition: level2_cplx_impl.h:39
#define VERIFY(a)
Definition: main.h:362
Definition: NonLinearOptimization.cpp:307

References EIGEN_UNUSED_VARIABLE, info, LM_EVAL_COUNT_TOL, n, solver, VERIFY, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testHybrd1()

void testHybrd1 ( )
326  {
327  int n = 9, info;
328  VectorXd x(n);
329 
330  /* the following starting values provide a rough solution. */
331  x.setConstant(n, -1.);
332 
333  // do the computation
334  hybrd_functor functor;
336  info = solver.hybrd1(x);
338 
339  // check return value
340  // VERIFY_IS_EQUAL(info, 1);
341  VERIFY(solver.nfev <= 20 * LM_EVAL_COUNT_TOL);
342 
343  // check norm
344  VERIFY_IS_APPROX(solver.fvec.blueNorm(), 1.192636e-08);
345 
346  // check x
347  VectorXd x_ref(n);
348  x_ref << -0.5706545, -0.6816283, -0.7017325, -0.7042129, -0.701369, -0.6918656, -0.665792, -0.5960342, -0.4164121;
349  VERIFY_IS_APPROX(x, x_ref);
350 }

References EIGEN_UNUSED_VARIABLE, info, LM_EVAL_COUNT_TOL, n, solver, VERIFY, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testHybrj()

void testHybrj ( )
278  {
279  const int n = 9;
280  int info;
281  VectorXd x(n);
282 
283  /* the following starting values provide a rough fit. */
284  x.setConstant(n, -1.);
285 
286  // do the computation
287  hybrj_functor functor;
289  solver.diag.setConstant(n, 1.);
290  solver.useExternalScaling = true;
291  info = solver.solve(x);
293 
294  // check return value
295  // VERIFY_IS_EQUAL(info, 1);
296  LM_CHECK_N_ITERS(solver, 11, 1);
297 
298  // check norm
299  VERIFY_IS_APPROX(solver.fvec.blueNorm(), 1.192636e-08);
300 
301  // check x
302  VectorXd x_ref(n);
303  x_ref << -0.5706545, -0.6816283, -0.7017325, -0.7042129, -0.701369, -0.6918656, -0.665792, -0.5960342, -0.4164121;
304  VERIFY_IS_APPROX(x, x_ref);
305 }
#define LM_CHECK_N_ITERS(SOLVER, NFEV, NJEV)
Definition: NonLinearOptimization.cpp:18
Definition: NonLinearOptimization.cpp:220

References EIGEN_UNUSED_VARIABLE, info, LM_CHECK_N_ITERS, n, solver, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testHybrj1()

void testHybrj1 ( )
251  {
252  const int n = 9;
253  int info;
254  VectorXd x(n);
255 
256  /* the following starting values provide a rough fit. */
257  x.setConstant(n, -1.);
258 
259  // do the computation
260  hybrj_functor functor;
262  info = solver.hybrj1(x);
264 
265  // check return value
266  // VERIFY_IS_EQUAL(info, 1);
267  LM_CHECK_N_ITERS(solver, 11, 1);
268 
269  // check norm
270  VERIFY_IS_APPROX(solver.fvec.blueNorm(), 1.192636e-08);
271 
272  // check x
273  VectorXd x_ref(n);
274  x_ref << -0.5706545, -0.6816283, -0.7017325, -0.7042129, -0.701369, -0.6918656, -0.665792, -0.5960342, -0.4164121;
275  VERIFY_IS_APPROX(x, x_ref);
276 }

References EIGEN_UNUSED_VARIABLE, info, LM_CHECK_N_ITERS, n, solver, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testLmder()

void testLmder ( )
175  {
176  const int m = 15, n = 3;
177  int info;
178  double fnorm, covfac;
179  VectorXd x;
180 
181  /* the following starting values provide a rough fit. */
182  x.setConstant(n, 1.);
183 
184  // do the computation
185  lmder_functor functor;
187  info = lm.minimize(x);
189 
190  // check return values
191  // VERIFY_IS_EQUAL(info, 1);
192  LM_CHECK_N_ITERS(lm, 6, 5);
193 
194  // check norm
195  fnorm = lm.fvec.blueNorm();
196  VERIFY_IS_APPROX(fnorm, 0.09063596);
197 
198  // check x
199  VectorXd x_ref(n);
200  x_ref << 0.08241058, 1.133037, 2.343695;
201  VERIFY_IS_APPROX(x, x_ref);
202 
203  // check covariance
204  covfac = fnorm * fnorm / (m - n);
205  internal::covar(lm.fjac, lm.permutation.indices()); // TODO : move this as a function of lm
206 
207  MatrixXd cov_ref(n, n);
208  cov_ref << 0.0001531202, 0.002869941, -0.002656662, 0.002869941, 0.09480935, -0.09098995, -0.002656662, -0.09098995,
209  0.08778727;
210 
211  // std::cout << fjac*covfac << std::endl;
212 
213  MatrixXd cov;
214  cov = covfac * lm.fjac.topLeftCorner<n, n>();
215  VERIFY_IS_APPROX(cov, cov_ref);
216  // TODO: why isn't this allowed ? :
217  // VERIFY_IS_APPROX( covfac*fjac.topLeftCorner<n,n>() , cov_ref);
218 }
Performs non linear optimization over a non-linear function, using a variant of the Levenberg Marquar...
Definition: LevenbergMarquardt/LevenbergMarquardt.h:102
void covar(Matrix< Scalar, Dynamic, Dynamic > &r, const VectorXi &ipvt, Scalar tol=std::sqrt(NumTraits< Scalar >::epsilon()))
Definition: LMcovar.h:23
Definition: levenberg_marquardt.cpp:27

References Eigen::internal::covar(), EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fjac, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, Eigen::PermutationMatrix< SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_ >::indices(), info, LM_CHECK_N_ITERS, m, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::permutation, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testLmder1()

void testLmder1 ( )
148  {
149  int n = 3, info;
150 
151  VectorXd x;
152 
153  /* the following starting values provide a rough fit. */
154  x.setConstant(n, 1.);
155 
156  // do the computation
157  lmder_functor functor;
159  info = lm.lmder1(x);
161 
162  // check return value
163  // VERIFY_IS_EQUAL(info, 1);
164  LM_CHECK_N_ITERS(lm, 6, 5);
165 
166  // check norm
167  VERIFY_IS_APPROX(lm.fvec.blueNorm(), 0.09063596);
168 
169  // check x
170  VectorXd x_ref(n);
171  x_ref << 0.08241058, 1.133037, 2.343695;
172  VERIFY_IS_APPROX(x, x_ref);
173 }

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::lmder1(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testLmdif()

void testLmdif ( )
528  {
529  const int m = 15, n = 3;
530  int info;
531  double fnorm, covfac;
532  VectorXd x(n);
533 
534  /* the following starting values provide a rough fit. */
535  x.setConstant(n, 1.);
536 
537  // do the computation
538  lmdif_functor functor;
539  NumericalDiff<lmdif_functor> numDiff(functor);
541  info = lm.minimize(x);
543 
544  // check return values
545  // VERIFY_IS_EQUAL(info, 1);
546  VERIFY(lm.nfev <= 26 * LM_EVAL_COUNT_TOL);
547 
548  // check norm
549  fnorm = lm.fvec.blueNorm();
550  VERIFY_IS_APPROX(fnorm, 0.09063596);
551 
552  // check x
553  VectorXd x_ref(n);
554  x_ref << 0.08241058, 1.133037, 2.343695;
555  VERIFY_IS_APPROX(x, x_ref);
556 
557  // check covariance
558  covfac = fnorm * fnorm / (m - n);
559  internal::covar(lm.fjac, lm.permutation.indices()); // TODO : move this as a function of lm
560 
561  MatrixXd cov_ref(n, n);
562  cov_ref << 0.0001531202, 0.002869942, -0.002656662, 0.002869942, 0.09480937, -0.09098997, -0.002656662, -0.09098997,
563  0.08778729;
564 
565  // std::cout << fjac*covfac << std::endl;
566 
567  MatrixXd cov;
568  cov = covfac * lm.fjac.topLeftCorner<n, n>();
569  VERIFY_IS_APPROX(cov, cov_ref);
570  // TODO: why isn't this allowed ? :
571  // VERIFY_IS_APPROX( covfac*fjac.topLeftCorner<n,n>() , cov_ref);
572 }
Definition: NumericalDiff.h:35
Definition: levenberg_marquardt.cpp:132

References Eigen::internal::covar(), EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fjac, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, Eigen::PermutationMatrix< SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_ >::indices(), info, LM_EVAL_COUNT_TOL, m, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::nfev, Eigen::LevenbergMarquardt< FunctorType_ >::permutation, VERIFY, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testLmdif1()

void testLmdif1 ( )
499  {
500  const int n = 3;
501  int info;
502 
503  VectorXd x(n), fvec(15);
504 
505  /* the following starting values provide a rough fit. */
506  x.setConstant(n, 1.);
507 
508  // do the computation
509  lmdif_functor functor;
510  DenseIndex nfev = -1; // initialize to avoid maybe-uninitialized warning
513 
514  // check return value
515  // VERIFY_IS_EQUAL(info, 1);
516  VERIFY(nfev <= 26 * LM_EVAL_COUNT_TOL);
517 
518  // check norm
519  functor(x, fvec);
520  VERIFY_IS_APPROX(fvec.blueNorm(), 0.09063596);
521 
522  // check x
523  VectorXd x_ref(n);
524  x_ref << 0.0824106, 1.1330366, 2.3436947;
525  VERIFY_IS_APPROX(x, x_ref);
526 }
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:75

References EIGEN_UNUSED_VARIABLE, info, LM_EVAL_COUNT_TOL, n, VERIFY, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testLmstr()

void testLmstr ( )
448  {
449  const int n = 3;
450  int info;
451  double fnorm;
452  VectorXd x(n);
453 
454  /* the following starting values provide a rough fit. */
455  x.setConstant(n, 1.);
456 
457  // do the computation
458  lmstr_functor functor;
460  info = lm.minimizeOptimumStorage(x);
462 
463  // check return values
464  // VERIFY_IS_EQUAL(info, 1);
465  LM_CHECK_N_ITERS(lm, 6, 5);
466 
467  // check norm
468  fnorm = lm.fvec.blueNorm();
469  VERIFY_IS_APPROX(fnorm, 0.09063596);
470 
471  // check x
472  VectorXd x_ref(n);
473  x_ref << 0.08241058, 1.133037, 2.343695;
474  VERIFY_IS_APPROX(x, x_ref);
475 }
Definition: NonLinearOptimization.cpp:383

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimizeOptimumStorage(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testLmstr1()

void testLmstr1 ( )
420  {
421  const int n = 3;
422  int info;
423 
424  VectorXd x(n);
425 
426  /* the following starting values provide a rough fit. */
427  x.setConstant(n, 1.);
428 
429  // do the computation
430  lmstr_functor functor;
432  info = lm.lmstr1(x);
434 
435  // check return value
436  // VERIFY_IS_EQUAL(info, 1);
437  LM_CHECK_N_ITERS(lm, 6, 5);
438 
439  // check norm
440  VERIFY_IS_APPROX(lm.fvec.blueNorm(), 0.09063596);
441 
442  // check x
443  VectorXd x_ref(n);
444  x_ref << 0.08241058, 1.133037, 2.343695;
445  VERIFY_IS_APPROX(x, x_ref);
446 }

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::lmstr1(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistBennett5()

void testNistBennett5 ( void  )
1510  {
1511  const int n = 3;
1512  int info;
1513 
1514  VectorXd x(n);
1515 
1516  /*
1517  * First try
1518  */
1519  x << -2000., 50., 0.8;
1520  // do the computation
1521  Bennett5_functor functor;
1523  lm.parameters.maxfev = 1000;
1524  info = lm.minimize(x);
1526 
1527  // check return value
1528  // VERIFY_IS_EQUAL(info, 1);
1529  LM_CHECK_N_ITERS(lm, 758, 744);
1530  // check norm^2
1531  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.2404744073E-04);
1532  // check x
1533  VERIFY_IS_APPROX(x[0], -2.5235058043E+03);
1534  VERIFY_IS_APPROX(x[1], 4.6736564644E+01);
1535  VERIFY_IS_APPROX(x[2], 9.3218483193E-01);
1536  /*
1537  * Second try
1538  */
1539  x << -1500., 45., 0.85;
1540  // do the computation
1541  lm.resetParameters();
1542  info = lm.minimize(x);
1544 
1545  // check return value
1546  // VERIFY_IS_EQUAL(info, 1);
1547  LM_CHECK_N_ITERS(lm, 203, 192);
1548  // check norm^2
1549  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.2404744073E-04);
1550  // check x
1551  VERIFY_IS_APPROX(x[0], -2523.3007865); // should be -2.5235058043E+03
1552  VERIFY_IS_APPROX(x[1], 46.735705771); // should be 4.6736564644E+01);
1553  VERIFY_IS_APPROX(x[2], 0.93219881891); // should be 9.3218483193E-01);
1554 }
Definition: levenberg_marquardt.cpp:1140

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::maxfev, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistBoxBOD()

void testNistBoxBOD ( void  )
1221  {
1222  const int n = 2;
1223  int info;
1224 
1225  VectorXd x(n);
1226 
1227  /*
1228  * First try
1229  */
1230  x << 1., 1.;
1231  // do the computation
1232  BoxBOD_functor functor;
1234  lm.parameters.ftol = 1.E6 * NumTraits<double>::epsilon();
1235  lm.parameters.xtol = 1.E6 * NumTraits<double>::epsilon();
1236  lm.parameters.factor = 10.;
1237  info = lm.minimize(x);
1239 
1240  // check return value
1241  // VERIFY_IS_EQUAL(info, 1);
1242  LM_CHECK_N_ITERS(lm, 31, 25);
1243  // check norm^2
1244  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.1680088766E+03);
1245  // check x
1246  VERIFY_IS_APPROX(x[0], 2.1380940889E+02);
1247  VERIFY_IS_APPROX(x[1], 5.4723748542E-01);
1248 
1249  /*
1250  * Second try
1251  */
1252  x << 100., 0.75;
1253  // do the computation
1254  lm.resetParameters();
1255  lm.parameters.ftol = NumTraits<double>::epsilon();
1256  lm.parameters.xtol = NumTraits<double>::epsilon();
1257  info = lm.minimize(x);
1259 
1260  // check return value
1261  // VERIFY_IS_EQUAL(info, 1);
1262  LM_CHECK_N_ITERS(lm, 20, 14);
1263  // check norm^2
1264  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.1680088766E+03);
1265  // check x
1266  VERIFY_IS_APPROX(x[0], 2.1380940889E+02);
1267  VERIFY_IS_APPROX(x[1], 5.4723748542E-01);
1268 }
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
Definition: levenberg_marquardt.cpp:880

References EIGEN_UNUSED_VARIABLE, oomph::SarahBL::epsilon, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::factor, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::ftol, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, plotDoE::x, and Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::xtol.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistChwirut2()

void testNistChwirut2 ( void  )
619  {
620  const int n = 3;
621  int info;
622 
623  VectorXd x(n);
624 
625  /*
626  * First try
627  */
628  x << 0.1, 0.01, 0.02;
629  // do the computation
630  chwirut2_functor functor;
632  info = lm.minimize(x);
634 
635  // check return value
636  // VERIFY_IS_EQUAL(info, 1);
637  LM_CHECK_N_ITERS(lm, 10, 8);
638  // check norm^2
639  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.1304802941E+02);
640  // check x
641  VERIFY_IS_APPROX(x[0], 1.6657666537E-01);
642  VERIFY_IS_APPROX(x[1], 5.1653291286E-03);
643  VERIFY_IS_APPROX(x[2], 1.2150007096E-02);
644 
645  /*
646  * Second try
647  */
648  x << 0.15, 0.008, 0.010;
649  // do the computation
650  lm.resetParameters();
651  lm.parameters.ftol = 1.E6 * NumTraits<double>::epsilon();
652  lm.parameters.xtol = 1.E6 * NumTraits<double>::epsilon();
653  info = lm.minimize(x);
655 
656  // check return value
657  // VERIFY_IS_EQUAL(info, 1);
658  LM_CHECK_N_ITERS(lm, 7, 6);
659  // check norm^2
660  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.1304802941E+02);
661  // check x
662  VERIFY_IS_APPROX(x[0], 1.6657666537E-01);
663  VERIFY_IS_APPROX(x[1], 5.1653291286E-03);
664  VERIFY_IS_APPROX(x[2], 1.2150007096E-02);
665 }
Definition: levenberg_marquardt.cpp:229

References EIGEN_UNUSED_VARIABLE, oomph::SarahBL::epsilon, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::ftol, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, plotDoE::x, and Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::xtol.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistEckerle4()

void testNistEckerle4 ( void  )
1779  {
1780  const int n = 3;
1781  int info;
1782 
1783  VectorXd x(n);
1784 
1785  /*
1786  * First try
1787  */
1788  x << 1., 10., 500.;
1789  // do the computation
1790  eckerle4_functor functor;
1792  info = lm.minimize(x);
1794 
1795  // check return value
1796  // VERIFY_IS_EQUAL(info, 1);
1797  LM_CHECK_N_ITERS(lm, 18, 15);
1798  // check norm^2
1799  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.4635887487E-03);
1800  // check x
1801  VERIFY_IS_APPROX(x[0], 1.5543827178);
1802  VERIFY_IS_APPROX(x[1], 4.0888321754);
1803  VERIFY_IS_APPROX(x[2], 4.5154121844E+02);
1804 
1805  /*
1806  * Second try
1807  */
1808  x << 1.5, 5., 450.;
1809  // do the computation
1810  info = lm.minimize(x);
1812 
1813  // check return value
1814  // VERIFY_IS_EQUAL(info, 1);
1815  LM_CHECK_N_ITERS(lm, 7, 6);
1816  // check norm^2
1817  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.4635887487E-03);
1818  // check x
1819  VERIFY_IS_APPROX(x[0], 1.5543827178);
1820  VERIFY_IS_APPROX(x[1], 4.0888321754);
1821  VERIFY_IS_APPROX(x[2], 4.5154121844E+02);
1822 }
Definition: levenberg_marquardt.cpp:1444

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistHahn1()

void testNistHahn1 ( void  )
823  {
824  const int n = 7;
825  int info;
826 
827  VectorXd x(n);
828 
829  /*
830  * First try
831  */
832  x << 10., -1., .05, -.00001, -.05, .001, -.000001;
833  // do the computation
834  hahn1_functor functor;
836  info = lm.minimize(x);
838 
839  // check return value
840  // VERIFY_IS_EQUAL(info, 1);
841  LM_CHECK_N_ITERS(lm, 11, 10);
842  // check norm^2
843  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.5324382854E+00);
844  // check x
845  VERIFY_IS_APPROX(x[0], 1.0776351733E+00);
846  VERIFY_IS_APPROX(x[1], -1.2269296921E-01);
847  VERIFY_IS_APPROX(x[2], 4.0863750610E-03);
848  VERIFY_IS_APPROX(x[3], -1.426264e-06); // shoulde be : -1.4262662514E-06
849  VERIFY_IS_APPROX(x[4], -5.7609940901E-03);
850  VERIFY_IS_APPROX(x[5], 2.4053735503E-04);
851  VERIFY_IS_APPROX(x[6], -1.2314450199E-07);
852 
853  /*
854  * Second try
855  */
856  x << .1, -.1, .005, -.000001, -.005, .0001, -.0000001;
857  // do the computation
858  info = lm.minimize(x);
860 
861  // check return value
862  // VERIFY_IS_EQUAL(info, 1);
863  LM_CHECK_N_ITERS(lm, 11, 10);
864  // check norm^2
865  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.5324382854E+00);
866  // check x
867  VERIFY_IS_APPROX(x[0], 1.077640); // should be : 1.0776351733E+00
868  VERIFY_IS_APPROX(x[1], -0.1226933); // should be : -1.2269296921E-01
869  VERIFY_IS_APPROX(x[2], 0.004086383); // should be : 4.0863750610E-03
870  VERIFY_IS_APPROX(x[3], -1.426277e-06); // shoulde be : -1.4262662514E-06
871  VERIFY_IS_APPROX(x[4], -5.7609940901E-03);
872  VERIFY_IS_APPROX(x[5], 0.00024053772); // should be : 2.4053735503E-04
873  VERIFY_IS_APPROX(x[6], -1.231450e-07); // should be : -1.2314450199E-07
874 }
Definition: levenberg_marquardt.cpp:398

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistLanczos1()

void testNistLanczos1 ( void  )
989  {
990  const int n = 6;
991  int info;
992 
993  VectorXd x(n);
994 
995  /*
996  * First try
997  */
998  x << 1.2, 0.3, 5.6, 5.5, 6.5, 7.6;
999  // do the computation
1000  lanczos1_functor functor;
1002  info = lm.minimize(x);
1004 
1005  // check return value
1006  // VERIFY_IS_EQUAL(info, 2);
1007  LM_CHECK_N_ITERS(lm, 79, 72);
1008  // check norm^2
1009  // std::cout.precision(30);
1010  // std::cout << lm.fvec.squaredNorm() << "\n";
1011  VERIFY(lm.fvec.squaredNorm() <= 1.44E-25);
1012  // check x
1013  VERIFY_IS_APPROX(x[0], 9.5100000027E-02);
1014  VERIFY_IS_APPROX(x[1], 1.0000000001E+00);
1015  VERIFY_IS_APPROX(x[2], 8.6070000013E-01);
1016  VERIFY_IS_APPROX(x[3], 3.0000000002E+00);
1017  VERIFY_IS_APPROX(x[4], 1.5575999998E+00);
1018  VERIFY_IS_APPROX(x[5], 5.0000000001E+00);
1019 
1020  /*
1021  * Second try
1022  */
1023  x << 0.5, 0.7, 3.6, 4.2, 4., 6.3;
1024  // do the computation
1025  info = lm.minimize(x);
1027 
1028  // check return value
1029  // VERIFY_IS_EQUAL(info, 2);
1030  LM_CHECK_N_ITERS(lm, 9, 8);
1031  // check norm^2
1032  VERIFY(lm.fvec.squaredNorm() <= 1.44E-25);
1033  // check x
1034  VERIFY_IS_APPROX(x[0], 9.5100000027E-02);
1035  VERIFY_IS_APPROX(x[1], 1.0000000001E+00);
1036  VERIFY_IS_APPROX(x[2], 8.6070000013E-01);
1037  VERIFY_IS_APPROX(x[3], 3.0000000002E+00);
1038  VERIFY_IS_APPROX(x[4], 1.5575999998E+00);
1039  VERIFY_IS_APPROX(x[5], 5.0000000001E+00);
1040 }
Definition: levenberg_marquardt.cpp:612

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistMGH09()

void testNistMGH09 ( void  )
1396  {
1397  const int n = 4;
1398  int info;
1399 
1400  VectorXd x(n);
1401 
1402  /*
1403  * First try
1404  */
1405  x << 25., 39, 41.5, 39.;
1406  // do the computation
1407  MGH09_functor functor;
1409  lm.parameters.maxfev = 1000;
1410  info = lm.minimize(x);
1412 
1413  // check return value
1414  // VERIFY_IS_EQUAL(info, 1);
1415  LM_CHECK_N_ITERS(lm, 490, 376);
1416  // check norm^2
1417  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 3.0750560385E-04);
1418  // check x
1419  VERIFY_IS_APPROX(x[0], 0.1928077089); // should be 1.9280693458E-01
1420  VERIFY_IS_APPROX(x[1], 0.19126423573); // should be 1.9128232873E-01
1421  VERIFY_IS_APPROX(x[2], 0.12305309914); // should be 1.2305650693E-01
1422  VERIFY_IS_APPROX(x[3], 0.13605395375); // should be 1.3606233068E-01
1423 
1424  /*
1425  * Second try
1426  */
1427  x << 0.25, 0.39, 0.415, 0.39;
1428  // do the computation
1429  lm.resetParameters();
1430  info = lm.minimize(x);
1432 
1433  // check return value
1434  // VERIFY_IS_EQUAL(info, 1);
1435  LM_CHECK_N_ITERS(lm, 18, 16);
1436  // check norm^2
1437  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 3.0750560385E-04);
1438  // check x
1439  VERIFY_IS_APPROX(x[0], 0.19280781); // should be 1.9280693458E-01
1440  VERIFY_IS_APPROX(x[1], 0.19126265); // should be 1.9128232873E-01
1441  VERIFY_IS_APPROX(x[2], 0.12305280); // should be 1.2305650693E-01
1442  VERIFY_IS_APPROX(x[3], 0.13605322); // should be 1.3606233068E-01
1443 }
Definition: levenberg_marquardt.cpp:1055

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::maxfev, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, and plotDoE::x.

◆ testNistMGH10()

void testNistMGH10 ( void  )
1151  {
1152  const int n = 3;
1153  int info;
1154 
1155  VectorXd x(n);
1156 
1157  /*
1158  * First try
1159  */
1160  x << 2., 400000., 25000.;
1161  // do the computation
1162  MGH10_functor functor;
1164  info = lm.minimize(x);
1166 
1167  // check return value
1168  // VERIFY_IS_EQUAL(info, 2);
1169  LM_CHECK_N_ITERS(lm, 284, 249);
1170  // check norm^2
1171  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 8.7945855171E+01);
1172  // check x
1173  VERIFY_IS_APPROX(x[0], 5.6096364710E-03);
1174  VERIFY_IS_APPROX(x[1], 6.1813463463E+03);
1175  VERIFY_IS_APPROX(x[2], 3.4522363462E+02);
1176 
1177  /*
1178  * Second try
1179  */
1180  x << 0.02, 4000., 250.;
1181  // do the computation
1182  info = lm.minimize(x);
1184 
1185  // check return value
1186  // VERIFY_IS_EQUAL(info, 3);
1187  LM_CHECK_N_ITERS(lm, 126, 116);
1188  // check norm^2
1189  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 8.7945855171E+01);
1190  // check x
1191  VERIFY_IS_APPROX(x[0], 5.6096364710E-03);
1192  VERIFY_IS_APPROX(x[1], 6.1813463463E+03);
1193  VERIFY_IS_APPROX(x[2], 3.4522363462E+02);
1194 }
Definition: levenberg_marquardt.cpp:784

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY_IS_APPROX, and plotDoE::x.

◆ testNistMGH17()

void testNistMGH17 ( void  )
1308  {
1309  const int n = 5;
1310  int info;
1311 
1312  VectorXd x(n);
1313 
1314  /*
1315  * First try
1316  */
1317  x << 50., 150., -100., 1., 2.;
1318  // do the computation
1319  MGH17_functor functor;
1321  lm.parameters.ftol = NumTraits<double>::epsilon();
1322  lm.parameters.xtol = NumTraits<double>::epsilon();
1323  lm.parameters.maxfev = 1000;
1324  info = lm.minimize(x);
1326 
1327  // check norm^2
1328  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.4648946975E-05);
1329  // check x
1330  VERIFY_IS_APPROX(x[0], 3.7541005211E-01);
1331  VERIFY_IS_APPROX(x[1], 1.9358469127E+00);
1332  VERIFY_IS_APPROX(x[2], -1.4646871366E+00);
1333  VERIFY_IS_APPROX(x[3], 1.2867534640E-02);
1334  VERIFY_IS_APPROX(x[4], 2.2122699662E-02);
1335 
1336  // check return value
1337  // VERIFY_IS_EQUAL(info, 2);
1338  LM_CHECK_N_ITERS(lm, 602, 545);
1339 
1340  /*
1341  * Second try
1342  */
1343  x << 0.5, 1.5, -1, 0.01, 0.02;
1344  // do the computation
1345  lm.resetParameters();
1346  info = lm.minimize(x);
1348 
1349  // check return value
1350  // VERIFY_IS_EQUAL(info, 1);
1351  LM_CHECK_N_ITERS(lm, 18, 15);
1352  // check norm^2
1353  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.4648946975E-05);
1354  // check x
1355  VERIFY_IS_APPROX(x[0], 3.7541005211E-01);
1356  VERIFY_IS_APPROX(x[1], 1.9358469127E+00);
1357  VERIFY_IS_APPROX(x[2], -1.4646871366E+00);
1358  VERIFY_IS_APPROX(x[3], 1.2867534640E-02);
1359  VERIFY_IS_APPROX(x[4], 2.2122699662E-02);
1360 }
Definition: levenberg_marquardt.cpp:961

References EIGEN_UNUSED_VARIABLE, oomph::SarahBL::epsilon, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::ftol, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::maxfev, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, plotDoE::x, and Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::xtol.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistMisra1a()

void testNistMisra1a ( void  )
696  {
697  const int n = 2;
698  int info;
699 
700  VectorXd x(n);
701 
702  /*
703  * First try
704  */
705  x << 500., 0.0001;
706  // do the computation
707  misra1a_functor functor;
709  info = lm.minimize(x);
711 
712  // check return value
713  // VERIFY_IS_EQUAL(info, 1);
714  LM_CHECK_N_ITERS(lm, 19, 15);
715  // check norm^2
716  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.2455138894E-01);
717  // check x
718  VERIFY_IS_APPROX(x[0], 2.3894212918E+02);
719  VERIFY_IS_APPROX(x[1], 5.5015643181E-04);
720 
721  /*
722  * Second try
723  */
724  x << 250., 0.0005;
725  // do the computation
726  info = lm.minimize(x);
728 
729  // check return value
730  // VERIFY_IS_EQUAL(info, 1);
731  LM_CHECK_N_ITERS(lm, 5, 4);
732  // check norm^2
733  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 1.2455138894E-01);
734  // check x
735  VERIFY_IS_APPROX(x[0], 2.3894212918E+02);
736  VERIFY_IS_APPROX(x[1], 5.5015643181E-04);
737 }
Definition: levenberg_marquardt.cpp:324

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistMisra1d()

void testNistMisra1d ( void  )
906  {
907  const int n = 2;
908  int info;
909 
910  VectorXd x(n);
911 
912  /*
913  * First try
914  */
915  x << 500., 0.0001;
916  // do the computation
917  misra1d_functor functor;
919  info = lm.minimize(x);
921 
922  // check return value
923  // VERIFY_IS_EQUAL(info, 3);
924  LM_CHECK_N_ITERS(lm, 9, 7);
925  // check norm^2
926  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.6419295283E-02);
927  // check x
928  VERIFY_IS_APPROX(x[0], 4.3736970754E+02);
929  VERIFY_IS_APPROX(x[1], 3.0227324449E-04);
930 
931  /*
932  * Second try
933  */
934  x << 450., 0.0003;
935  // do the computation
936  info = lm.minimize(x);
938 
939  // check return value
940  // VERIFY_IS_EQUAL(info, 1);
941  LM_CHECK_N_ITERS(lm, 4, 3);
942  // check norm^2
943  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.6419295283E-02);
944  // check x
945  VERIFY_IS_APPROX(x[0], 4.3736970754E+02);
946  VERIFY_IS_APPROX(x[1], 3.0227324449E-04);
947 }
Definition: levenberg_marquardt.cpp:537

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistRat42()

void testNistRat42 ( void  )
1074  {
1075  const int n = 3;
1076  int info;
1077 
1078  VectorXd x(n);
1079 
1080  /*
1081  * First try
1082  */
1083  x << 100., 1., 0.1;
1084  // do the computation
1085  rat42_functor functor;
1087  info = lm.minimize(x);
1089 
1090  // check return value
1091  // VERIFY_IS_EQUAL(info, 1);
1092  LM_CHECK_N_ITERS(lm, 10, 8);
1093  // check norm^2
1094  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 8.0565229338E+00);
1095  // check x
1096  VERIFY_IS_APPROX(x[0], 7.2462237576E+01);
1097  VERIFY_IS_APPROX(x[1], 2.6180768402E+00);
1098  VERIFY_IS_APPROX(x[2], 6.7359200066E-02);
1099 
1100  /*
1101  * Second try
1102  */
1103  x << 75., 2.5, 0.07;
1104  // do the computation
1105  info = lm.minimize(x);
1107 
1108  // check return value
1109  // VERIFY_IS_EQUAL(info, 1);
1110  LM_CHECK_N_ITERS(lm, 6, 5);
1111  // check norm^2
1112  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 8.0565229338E+00);
1113  // check x
1114  VERIFY_IS_APPROX(x[0], 7.2462237576E+01);
1115  VERIFY_IS_APPROX(x[1], 2.6180768402E+00);
1116  VERIFY_IS_APPROX(x[2], 6.7359200066E-02);
1117 }
Definition: levenberg_marquardt.cpp:705

References EIGEN_UNUSED_VARIABLE, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, VERIFY_IS_APPROX, and plotDoE::x.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistRat43()

void testNistRat43 ( void  )
1691  {
1692  const int n = 4;
1693  int info;
1694 
1695  VectorXd x(n);
1696 
1697  /*
1698  * First try
1699  */
1700  x << 100., 10., 1., 1.;
1701  // do the computation
1702  rat43_functor functor;
1704  lm.parameters.ftol = 1.E6 * NumTraits<double>::epsilon();
1705  lm.parameters.xtol = 1.E6 * NumTraits<double>::epsilon();
1706  info = lm.minimize(x);
1708 
1709  // check return value
1710  // VERIFY_IS_EQUAL(info, 1);
1711  LM_CHECK_N_ITERS(lm, 27, 20);
1712  // check norm^2
1713  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 8.7864049080E+03);
1714  // check x
1715  VERIFY_IS_APPROX(x[0], 6.9964151270E+02);
1716  VERIFY_IS_APPROX(x[1], 5.2771253025E+00);
1717  VERIFY_IS_APPROX(x[2], 7.5962938329E-01);
1718  VERIFY_IS_APPROX(x[3], 1.2792483859E+00);
1719 
1720  /*
1721  * Second try
1722  */
1723  x << 700., 5., 0.75, 1.3;
1724  // do the computation
1725  lm.resetParameters();
1726  lm.parameters.ftol = 1.E5 * NumTraits<double>::epsilon();
1727  lm.parameters.xtol = 1.E5 * NumTraits<double>::epsilon();
1728  info = lm.minimize(x);
1730 
1731  // check return value
1732  // VERIFY_IS_EQUAL(info, 1);
1733  LM_CHECK_N_ITERS(lm, 9, 8);
1734  // check norm^2
1735  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 8.7864049080E+03);
1736  // check x
1737  VERIFY_IS_APPROX(x[0], 6.9964151270E+02);
1738  VERIFY_IS_APPROX(x[1], 5.2771253025E+00);
1739  VERIFY_IS_APPROX(x[2], 7.5962938329E-01);
1740  VERIFY_IS_APPROX(x[3], 1.2792483859E+00);
1741 }
Definition: levenberg_marquardt.cpp:1360

References EIGEN_UNUSED_VARIABLE, oomph::SarahBL::epsilon, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::ftol, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, plotDoE::x, and Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::xtol.

Referenced by EIGEN_DECLARE_TEST().

◆ testNistThurber()

void testNistThurber ( void  )
1603  {
1604  const int n = 7;
1605  int info;
1606 
1607  VectorXd x(n);
1608 
1609  /*
1610  * First try
1611  */
1612  x << 1000, 1000, 400, 40, 0.7, 0.3, 0.0;
1613  // do the computation
1614  thurber_functor functor;
1616  lm.parameters.ftol = 1.E4 * NumTraits<double>::epsilon();
1617  lm.parameters.xtol = 1.E4 * NumTraits<double>::epsilon();
1618  info = lm.minimize(x);
1620 
1621  // check return value
1622  // VERIFY_IS_EQUAL(info, 1);
1623  LM_CHECK_N_ITERS(lm, 39, 36);
1624  // check norm^2
1625  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.6427082397E+03);
1626  // check x
1627  VERIFY_IS_APPROX(x[0], 1.2881396800E+03);
1628  VERIFY_IS_APPROX(x[1], 1.4910792535E+03);
1629  VERIFY_IS_APPROX(x[2], 5.8323836877E+02);
1630  VERIFY_IS_APPROX(x[3], 7.5416644291E+01);
1631  VERIFY_IS_APPROX(x[4], 9.6629502864E-01);
1632  VERIFY_IS_APPROX(x[5], 3.9797285797E-01);
1633  VERIFY_IS_APPROX(x[6], 4.9727297349E-02);
1634 
1635  /*
1636  * Second try
1637  */
1638  x << 1300, 1500, 500, 75, 1, 0.4, 0.05;
1639  // do the computation
1640  lm.resetParameters();
1641  lm.parameters.ftol = 1.E4 * NumTraits<double>::epsilon();
1642  lm.parameters.xtol = 1.E4 * NumTraits<double>::epsilon();
1643  info = lm.minimize(x);
1645 
1646  // check return value
1647  // VERIFY_IS_EQUAL(info, 1);
1648  LM_CHECK_N_ITERS(lm, 29, 28);
1649  // check norm^2
1650  VERIFY_IS_APPROX(lm.fvec.squaredNorm(), 5.6427082397E+03);
1651  // check x
1652  VERIFY_IS_APPROX(x[0], 1.2881396800E+03);
1653  VERIFY_IS_APPROX(x[1], 1.4910792535E+03);
1654  VERIFY_IS_APPROX(x[2], 5.8323836877E+02);
1655  VERIFY_IS_APPROX(x[3], 7.5416644291E+01);
1656  VERIFY_IS_APPROX(x[4], 9.6629502864E-01);
1657  VERIFY_IS_APPROX(x[5], 3.9797285797E-01);
1658  VERIFY_IS_APPROX(x[6], 4.9727297349E-02);
1659 }
Definition: levenberg_marquardt.cpp:1253

References EIGEN_UNUSED_VARIABLE, oomph::SarahBL::epsilon, Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::ftol, Eigen::LevenbergMarquardt< FunctorType_ >::fvec, info, LM_CHECK_N_ITERS, Eigen::LevenbergMarquardt< FunctorType_ >::minimize(), n, Eigen::LevenbergMarquardt< FunctorType_ >::parameters, Eigen::LevenbergMarquardt< FunctorType_ >::resetParameters(), VERIFY_IS_APPROX, plotDoE::x, and Eigen::LevenbergMarquardt< FunctorType_ >::Parameters::xtol.

Referenced by EIGEN_DECLARE_TEST().