Eigen::HybridNonLinearSolver< FunctorType, Scalar > Class Template Reference

Finds a zero of a system of n nonlinear functions in n variables by a modification of the Powell hybrid method ("dogleg"). More...

#include <HybridNonLinearSolver.h>

Classes

struct  Parameters
 

Public Types

typedef DenseIndex Index
 
typedef Matrix< Scalar, Dynamic, 1 > FVectorType
 
typedef Matrix< Scalar, Dynamic, DynamicJacobianType
 
typedef Matrix< Scalar, Dynamic, DynamicUpperTriangularType
 

Public Member Functions

 HybridNonLinearSolver (FunctorType &_functor)
 
HybridNonLinearSolverSpace::Status hybrj1 (FVectorType &x, const Scalar tol=numext::sqrt(NumTraits< Scalar >::epsilon()))
 
HybridNonLinearSolverSpace::Status solveInit (FVectorType &x)
 
HybridNonLinearSolverSpace::Status solveOneStep (FVectorType &x)
 
HybridNonLinearSolverSpace::Status solve (FVectorType &x)
 
HybridNonLinearSolverSpace::Status hybrd1 (FVectorType &x, const Scalar tol=numext::sqrt(NumTraits< Scalar >::epsilon()))
 
HybridNonLinearSolverSpace::Status solveNumericalDiffInit (FVectorType &x)
 
HybridNonLinearSolverSpace::Status solveNumericalDiffOneStep (FVectorType &x)
 
HybridNonLinearSolverSpace::Status solveNumericalDiff (FVectorType &x)
 
void resetParameters (void)
 

Public Attributes

Parameters parameters
 
FVectorType fvec
 
FVectorType qtf
 
FVectorType diag
 
JacobianType fjac
 
UpperTriangularType R
 
Index nfev
 
Index njev
 
Index iter
 
Scalar fnorm
 
bool useExternalScaling
 

Private Member Functions

HybridNonLinearSolveroperator= (const HybridNonLinearSolver &)
 

Private Attributes

FunctorType & functor
 
Index n
 
Scalar sum
 
bool sing
 
Scalar temp
 
Scalar delta
 
bool jeval
 
Index ncsuc
 
Scalar ratio
 
Scalar pnorm
 
Scalar xnorm
 
Scalar fnorm1
 
Index nslow1
 
Index nslow2
 
Index ncfail
 
Scalar actred
 
Scalar prered
 
FVectorType wa1
 
FVectorType wa2
 
FVectorType wa3
 
FVectorType wa4
 

Detailed Description

template<typename FunctorType, typename Scalar = double>
class Eigen::HybridNonLinearSolver< FunctorType, Scalar >

Finds a zero of a system of n nonlinear functions in n variables by a modification of the Powell hybrid method ("dogleg").

The user must provide a subroutine which calculates the functions. The Jacobian is either provided by the user, or approximated using a forward-difference method.

Member Typedef Documentation

◆ FVectorType

template<typename FunctorType , typename Scalar = double>
typedef Matrix<Scalar, Dynamic, 1> Eigen::HybridNonLinearSolver< FunctorType, Scalar >::FVectorType

◆ Index

template<typename FunctorType , typename Scalar = double>
typedef DenseIndex Eigen::HybridNonLinearSolver< FunctorType, Scalar >::Index

◆ JacobianType

template<typename FunctorType , typename Scalar = double>
typedef Matrix<Scalar, Dynamic, Dynamic> Eigen::HybridNonLinearSolver< FunctorType, Scalar >::JacobianType

◆ UpperTriangularType

template<typename FunctorType , typename Scalar = double>
typedef Matrix<Scalar, Dynamic, Dynamic> Eigen::HybridNonLinearSolver< FunctorType, Scalar >::UpperTriangularType

Constructor & Destructor Documentation

◆ HybridNonLinearSolver()

template<typename FunctorType , typename Scalar = double>
Eigen::HybridNonLinearSolver< FunctorType, Scalar >::HybridNonLinearSolver ( FunctorType &  _functor)
inline
50  : functor(_functor) {
51  nfev = njev = iter = 0;
52  fnorm = 0.;
53  useExternalScaling = false;
54  }
Index iter
Definition: HybridNonLinearSolver.h:97
bool useExternalScaling
Definition: HybridNonLinearSolver.h:99
Index nfev
Definition: HybridNonLinearSolver.h:95
Scalar fnorm
Definition: HybridNonLinearSolver.h:98
Index njev
Definition: HybridNonLinearSolver.h:96
FunctorType & functor
Definition: HybridNonLinearSolver.h:102

References Eigen::HybridNonLinearSolver< FunctorType, Scalar >::fnorm, Eigen::HybridNonLinearSolver< FunctorType, Scalar >::iter, Eigen::HybridNonLinearSolver< FunctorType, Scalar >::nfev, Eigen::HybridNonLinearSolver< FunctorType, Scalar >::njev, and Eigen::HybridNonLinearSolver< FunctorType, Scalar >::useExternalScaling.

Member Function Documentation

◆ hybrd1()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::hybrd1 ( FVectorType x,
const Scalar  tol = numext::sqrt(NumTraits<Scalar>::epsilon()) 
)
327  {
328  n = x.size();
329 
330  /* check the input parameters for errors. */
331  if (n <= 0 || tol < 0.) return HybridNonLinearSolverSpace::ImproperInputParameters;
332 
333  resetParameters();
334  parameters.maxfev = 200 * (n + 1);
335  parameters.xtol = tol;
336 
337  diag.setConstant(n, 1.);
338  useExternalScaling = true;
339  return solveNumericalDiff(x);
340 }
HybridNonLinearSolverSpace::Status solveNumericalDiff(FVectorType &x)
Definition: HybridNonLinearSolver.h:534
void resetParameters(void)
Definition: HybridNonLinearSolver.h:90
Parameters parameters
Definition: HybridNonLinearSolver.h:91
Index n
Definition: HybridNonLinearSolver.h:103
FVectorType diag
Definition: HybridNonLinearSolver.h:92
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:365
@ ImproperInputParameters
Definition: HybridNonLinearSolver.h:24
list x
Definition: plotDoE.py:28
Scalar xtol
Definition: HybridNonLinearSolver.h:66
Index maxfev
Definition: HybridNonLinearSolver.h:65

References diag, Eigen::HybridNonLinearSolverSpace::ImproperInputParameters, n, and plotDoE::x.

◆ hybrj1()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::hybrj1 ( FVectorType x,
const Scalar  tol = numext::sqrt(NumTraits<Scalar>::epsilon()) 
)
122  {
123  n = x.size();
124 
125  /* check the input parameters for errors. */
126  if (n <= 0 || tol < 0.) return HybridNonLinearSolverSpace::ImproperInputParameters;
127 
128  resetParameters();
129  parameters.maxfev = 100 * (n + 1);
130  parameters.xtol = tol;
131  diag.setConstant(n, 1.);
132  useExternalScaling = true;
133  return solve(x);
134 }
HybridNonLinearSolverSpace::Status solve(FVectorType &x)
Definition: HybridNonLinearSolver.h:318

References diag, Eigen::HybridNonLinearSolverSpace::ImproperInputParameters, n, solve, and plotDoE::x.

◆ operator=()

template<typename FunctorType , typename Scalar = double>
HybridNonLinearSolver& Eigen::HybridNonLinearSolver< FunctorType, Scalar >::operator= ( const HybridNonLinearSolver< FunctorType, Scalar > &  )
private

◆ resetParameters()

template<typename FunctorType , typename Scalar = double>
void Eigen::HybridNonLinearSolver< FunctorType, Scalar >::resetParameters ( void  )
inline

◆ solve()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solve ( FVectorType x)
318  {
320  if (status == HybridNonLinearSolverSpace::ImproperInputParameters) return status;
321  while (status == HybridNonLinearSolverSpace::Running) status = solveOneStep(x);
322  return status;
323 }
HybridNonLinearSolverSpace::Status solveInit(FVectorType &x)
Definition: HybridNonLinearSolver.h:137
HybridNonLinearSolverSpace::Status solveOneStep(FVectorType &x)
Definition: HybridNonLinearSolver.h:179
Status
Definition: HybridNonLinearSolver.h:22
@ Running
Definition: HybridNonLinearSolver.h:23

References Eigen::HybridNonLinearSolverSpace::ImproperInputParameters, Eigen::HybridNonLinearSolverSpace::Running, and plotDoE::x.

◆ solveInit()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveInit ( FVectorType x)
137  {
138  n = x.size();
139 
140  wa1.resize(n);
141  wa2.resize(n);
142  wa3.resize(n);
143  wa4.resize(n);
144  fvec.resize(n);
145  qtf.resize(n);
146  fjac.resize(n, n);
148  eigen_assert((!useExternalScaling || diag.size() == n) &&
149  "When useExternalScaling is set, the caller must provide a valid 'diag'");
150 
151  /* Function Body */
152  nfev = 0;
153  njev = 0;
154 
155  /* check the input parameters for errors. */
156  if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || parameters.factor <= 0.)
158  if (useExternalScaling)
159  for (Index j = 0; j < n; ++j)
161 
162  /* evaluate the function at the starting point */
163  /* and calculate its norm. */
164  nfev = 1;
166  fnorm = fvec.stableNorm();
167 
168  /* initialize iteration counter and monitors. */
169  iter = 1;
170  ncsuc = 0;
171  ncfail = 0;
172  nslow1 = 0;
173  nslow2 = 0;
174 
176 }
#define eigen_assert(x)
Definition: Macros.h:910
FVectorType fvec
Definition: HybridNonLinearSolver.h:92
FVectorType wa2
Definition: HybridNonLinearSolver.h:115
Index ncsuc
Definition: HybridNonLinearSolver.h:109
Index nslow1
Definition: HybridNonLinearSolver.h:112
FVectorType wa4
Definition: HybridNonLinearSolver.h:115
Index nslow2
Definition: HybridNonLinearSolver.h:112
FVectorType wa1
Definition: HybridNonLinearSolver.h:115
DenseIndex Index
Definition: HybridNonLinearSolver.h:48
FVectorType wa3
Definition: HybridNonLinearSolver.h:115
Index ncfail
Definition: HybridNonLinearSolver.h:113
JacobianType fjac
Definition: HybridNonLinearSolver.h:93
FVectorType qtf
Definition: HybridNonLinearSolver.h:92
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:294
@ UserAsked
Definition: HybridNonLinearSolver.h:30
Scalar factor
Definition: HybridNonLinearSolver.h:64
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References diag, eigen_assert, Eigen::HybridNonLinearSolverSpace::ImproperInputParameters, j, n, Eigen::HybridNonLinearSolverSpace::Running, Eigen::HybridNonLinearSolverSpace::UserAsked, and plotDoE::x.

◆ solveNumericalDiff()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveNumericalDiff ( FVectorType x)
534  {
536  if (status == HybridNonLinearSolverSpace::ImproperInputParameters) return status;
538  return status;
539 }
HybridNonLinearSolverSpace::Status solveNumericalDiffInit(FVectorType &x)
Definition: HybridNonLinearSolver.h:343
HybridNonLinearSolverSpace::Status solveNumericalDiffOneStep(FVectorType &x)
Definition: HybridNonLinearSolver.h:389

References Eigen::HybridNonLinearSolverSpace::ImproperInputParameters, Eigen::HybridNonLinearSolverSpace::Running, and plotDoE::x.

◆ solveNumericalDiffInit()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveNumericalDiffInit ( FVectorType x)
343  {
344  n = x.size();
345 
348 
349  wa1.resize(n);
350  wa2.resize(n);
351  wa3.resize(n);
352  wa4.resize(n);
353  qtf.resize(n);
354  fjac.resize(n, n);
355  fvec.resize(n);
357  eigen_assert((!useExternalScaling || diag.size() == n) &&
358  "When useExternalScaling is set, the caller must provide a valid 'diag'");
359 
360  /* Function Body */
361  nfev = 0;
362  njev = 0;
363 
364  /* check the input parameters for errors. */
365  if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || parameters.nb_of_subdiagonals < 0 ||
368  if (useExternalScaling)
369  for (Index j = 0; j < n; ++j)
371 
372  /* evaluate the function at the starting point */
373  /* and calculate its norm. */
374  nfev = 1;
376  fnorm = fvec.stableNorm();
377 
378  /* initialize iteration counter and monitors. */
379  iter = 1;
380  ncsuc = 0;
381  ncfail = 0;
382  nslow1 = 0;
383  nslow2 = 0;
384 
386 }
Index nb_of_subdiagonals
Definition: HybridNonLinearSolver.h:67
Index nb_of_superdiagonals
Definition: HybridNonLinearSolver.h:68

References diag, eigen_assert, Eigen::HybridNonLinearSolverSpace::ImproperInputParameters, j, n, Eigen::HybridNonLinearSolverSpace::Running, Eigen::HybridNonLinearSolverSpace::UserAsked, and plotDoE::x.

◆ solveNumericalDiffOneStep()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveNumericalDiffOneStep ( FVectorType x)
390  {
391  using std::abs;
392  using std::sqrt;
393 
394  eigen_assert(x.size() == n); // check the caller is not cheating us
395 
396  Index j;
397  std::vector<JacobiRotation<Scalar> > v_givens(n), w_givens(n);
398 
399  jeval = true;
402 
403  /* calculate the jacobian matrix. */
405  parameters.epsfcn) < 0)
408 
409  wa2 = fjac.colwise().blueNorm();
410 
411  /* on the first iteration and if external scaling is not used, scale according */
412  /* to the norms of the columns of the initial jacobian. */
413  if (iter == 1) {
414  if (!useExternalScaling)
415  for (j = 0; j < n; ++j) diag[j] = (wa2[j] == 0.) ? 1. : wa2[j];
416 
417  /* on the first iteration, calculate the norm of the scaled x */
418  /* and initialize the step bound delta. */
419  xnorm = diag.cwiseProduct(x).stableNorm();
421  if (delta == 0.) delta = parameters.factor;
422  }
423 
424  /* compute the qr factorization of the jacobian. */
425  HouseholderQR<JacobianType> qrfac(fjac); // no pivoting:
426 
427  /* copy the triangular factor of the qr factorization into r. */
428  R = qrfac.matrixQR();
429 
430  /* accumulate the orthogonal factor in fjac. */
431  fjac = qrfac.householderQ();
432 
433  /* form (q transpose)*fvec and store in qtf. */
434  qtf = fjac.transpose() * fvec;
435 
436  /* rescale if necessary. */
437  if (!useExternalScaling) diag = diag.cwiseMax(wa2);
438 
439  while (true) {
440  /* determine the direction p. */
441  internal::dogleg<Scalar>(R, diag, qtf, delta, wa1);
442 
443  /* store the direction p and x + p. calculate the norm of p. */
444  wa1 = -wa1;
445  wa2 = x + wa1;
446  pnorm = diag.cwiseProduct(wa1).stableNorm();
447 
448  /* on the first iteration, adjust the initial step bound. */
449  if (iter == 1) delta = (std::min)(delta, pnorm);
450 
451  /* evaluate the function at x + p and calculate its norm. */
453  ++nfev;
454  fnorm1 = wa4.stableNorm();
455 
456  /* compute the scaled actual reduction. */
457  actred = -1.;
458  if (fnorm1 < fnorm) /* Computing 2nd power */
459  actred = 1. - numext::abs2(fnorm1 / fnorm);
460 
461  /* compute the scaled predicted reduction. */
462  wa3 = R.template triangularView<Upper>() * wa1 + qtf;
463  temp = wa3.stableNorm();
464  prered = 0.;
465  if (temp < fnorm) /* Computing 2nd power */
466  prered = 1. - numext::abs2(temp / fnorm);
467 
468  /* compute the ratio of the actual to the predicted reduction. */
469  ratio = 0.;
470  if (prered > 0.) ratio = actred / prered;
471 
472  /* update the step bound. */
473  if (ratio < Scalar(.1)) {
474  ncsuc = 0;
475  ++ncfail;
476  delta = Scalar(.5) * delta;
477  } else {
478  ncfail = 0;
479  ++ncsuc;
480  if (ratio >= Scalar(.5) || ncsuc > 1) delta = (std::max)(delta, pnorm / Scalar(.5));
481  if (abs(ratio - 1.) <= Scalar(.1)) {
482  delta = pnorm / Scalar(.5);
483  }
484  }
485 
486  /* test for successful iteration. */
487  if (ratio >= Scalar(1e-4)) {
488  /* successful iteration. update x, fvec, and their norms. */
489  x = wa2;
490  wa2 = diag.cwiseProduct(x);
491  fvec = wa4;
492  xnorm = wa2.stableNorm();
493  fnorm = fnorm1;
494  ++iter;
495  }
496 
497  /* determine the progress of the iteration. */
498  ++nslow1;
499  if (actred >= Scalar(.001)) nslow1 = 0;
500  if (jeval) ++nslow2;
501  if (actred >= Scalar(.1)) nslow2 = 0;
502 
503  /* test for convergence. */
505 
506  /* tests for termination and stringent tolerances. */
508  if (Scalar(.1) * (std::max)(Scalar(.1) * delta, pnorm) <= NumTraits<Scalar>::epsilon() * xnorm)
512 
513  /* criterion for recalculating jacobian. */
514  if (ncfail == 2) break; // leave inner loop and go for the next outer loop iteration
515 
516  /* calculate the rank one modification to the jacobian */
517  /* and update qtf if necessary. */
518  wa1 = diag.cwiseProduct(diag.cwiseProduct(wa1) / pnorm);
519  wa2 = fjac.transpose() * wa4;
520  if (ratio >= Scalar(1e-4)) qtf = wa2;
521  wa2 = (wa2 - wa3) / pnorm;
522 
523  /* compute the qr factorization of the updated jacobian. */
524  internal::r1updt<Scalar>(R, wa1, v_givens, w_givens, wa2, wa3, &sing);
525  internal::r1mpyq<Scalar>(n, n, fjac.data(), v_givens, w_givens);
526  internal::r1mpyq<Scalar>(1, n, qtf.data(), v_givens, w_givens);
527 
528  jeval = false;
529  }
531 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
Array< double, 1, 3 > e(1./3., 0.5, 2.)
SCALAR Scalar
Definition: bench_gemm.cpp:45
Scalar delta
Definition: HybridNonLinearSolver.h:107
Scalar xnorm
Definition: HybridNonLinearSolver.h:111
Scalar fnorm1
Definition: HybridNonLinearSolver.h:111
UpperTriangularType R
Definition: HybridNonLinearSolver.h:94
Scalar prered
Definition: HybridNonLinearSolver.h:114
Scalar temp
Definition: HybridNonLinearSolver.h:106
Scalar ratio
Definition: HybridNonLinearSolver.h:110
bool sing
Definition: HybridNonLinearSolver.h:105
bool jeval
Definition: HybridNonLinearSolver.h:108
Scalar actred
Definition: HybridNonLinearSolver.h:114
Scalar pnorm
Definition: HybridNonLinearSolver.h:111
constexpr EIGEN_DEVICE_FUNC const Scalar * data() const
Definition: PlainObjectBase.h:273
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
@ TolTooSmall
Definition: HybridNonLinearSolver.h:27
@ NotMakingProgressIterations
Definition: HybridNonLinearSolver.h:29
@ TooManyFunctionEvaluation
Definition: HybridNonLinearSolver.h:26
@ NotMakingProgressJacobian
Definition: HybridNonLinearSolver.h:28
@ RelativeErrorTooSmall
Definition: HybridNonLinearSolver.h:25
DenseIndex fdjac1(const FunctorType &Functor, Matrix< Scalar, Dynamic, 1 > &x, Matrix< Scalar, Dynamic, 1 > &fvec, Matrix< Scalar, Dynamic, Dynamic > &fjac, DenseIndex ml, DenseIndex mu, Scalar epsfcn)
Definition: fdjac1.h:9
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: MathFunctions.h:1102
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
Scalar epsfcn
Definition: HybridNonLinearSolver.h:69

References abs(), Eigen::numext::abs2(), MultiOpt::delta, diag, e(), eigen_assert, Eigen::internal::fdjac1(), Eigen::HouseholderQR< MatrixType_ >::householderQ(), j, Eigen::HouseholderQR< MatrixType_ >::matrixQR(), max, min, n, Eigen::HybridNonLinearSolverSpace::NotMakingProgressIterations, Eigen::HybridNonLinearSolverSpace::NotMakingProgressJacobian, R, Eigen::HybridNonLinearSolverSpace::RelativeErrorTooSmall, Eigen::HybridNonLinearSolverSpace::Running, sqrt(), Eigen::HybridNonLinearSolverSpace::TolTooSmall, Eigen::HybridNonLinearSolverSpace::TooManyFunctionEvaluation, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::transpose(), Eigen::HybridNonLinearSolverSpace::UserAsked, and plotDoE::x.

◆ solveOneStep()

template<typename FunctorType , typename Scalar >
HybridNonLinearSolverSpace::Status Eigen::HybridNonLinearSolver< FunctorType, Scalar >::solveOneStep ( FVectorType x)
179  {
180  using std::abs;
181 
182  eigen_assert(x.size() == n); // check the caller is not cheating us
183 
184  Index j;
185  std::vector<JacobiRotation<Scalar> > v_givens(n), w_givens(n);
186 
187  jeval = true;
188 
189  /* calculate the jacobian matrix. */
191  ++njev;
192 
193  wa2 = fjac.colwise().blueNorm();
194 
195  /* on the first iteration and if external scaling is not used, scale according */
196  /* to the norms of the columns of the initial jacobian. */
197  if (iter == 1) {
198  if (!useExternalScaling)
199  for (j = 0; j < n; ++j) diag[j] = (wa2[j] == 0.) ? 1. : wa2[j];
200 
201  /* on the first iteration, calculate the norm of the scaled x */
202  /* and initialize the step bound delta. */
203  xnorm = diag.cwiseProduct(x).stableNorm();
205  if (delta == 0.) delta = parameters.factor;
206  }
207 
208  /* compute the qr factorization of the jacobian. */
209  HouseholderQR<JacobianType> qrfac(fjac); // no pivoting:
210 
211  /* copy the triangular factor of the qr factorization into r. */
212  R = qrfac.matrixQR();
213 
214  /* accumulate the orthogonal factor in fjac. */
215  fjac = qrfac.householderQ();
216 
217  /* form (q transpose)*fvec and store in qtf. */
218  qtf = fjac.transpose() * fvec;
219 
220  /* rescale if necessary. */
221  if (!useExternalScaling) diag = diag.cwiseMax(wa2);
222 
223  while (true) {
224  /* determine the direction p. */
225  internal::dogleg<Scalar>(R, diag, qtf, delta, wa1);
226 
227  /* store the direction p and x + p. calculate the norm of p. */
228  wa1 = -wa1;
229  wa2 = x + wa1;
230  pnorm = diag.cwiseProduct(wa1).stableNorm();
231 
232  /* on the first iteration, adjust the initial step bound. */
233  if (iter == 1) delta = (std::min)(delta, pnorm);
234 
235  /* evaluate the function at x + p and calculate its norm. */
237  ++nfev;
238  fnorm1 = wa4.stableNorm();
239 
240  /* compute the scaled actual reduction. */
241  actred = -1.;
242  if (fnorm1 < fnorm) /* Computing 2nd power */
243  actred = 1. - numext::abs2(fnorm1 / fnorm);
244 
245  /* compute the scaled predicted reduction. */
246  wa3 = R.template triangularView<Upper>() * wa1 + qtf;
247  temp = wa3.stableNorm();
248  prered = 0.;
249  if (temp < fnorm) /* Computing 2nd power */
250  prered = 1. - numext::abs2(temp / fnorm);
251 
252  /* compute the ratio of the actual to the predicted reduction. */
253  ratio = 0.;
254  if (prered > 0.) ratio = actred / prered;
255 
256  /* update the step bound. */
257  if (ratio < Scalar(.1)) {
258  ncsuc = 0;
259  ++ncfail;
260  delta = Scalar(.5) * delta;
261  } else {
262  ncfail = 0;
263  ++ncsuc;
264  if (ratio >= Scalar(.5) || ncsuc > 1) delta = (std::max)(delta, pnorm / Scalar(.5));
265  if (abs(ratio - 1.) <= Scalar(.1)) {
266  delta = pnorm / Scalar(.5);
267  }
268  }
269 
270  /* test for successful iteration. */
271  if (ratio >= Scalar(1e-4)) {
272  /* successful iteration. update x, fvec, and their norms. */
273  x = wa2;
274  wa2 = diag.cwiseProduct(x);
275  fvec = wa4;
276  xnorm = wa2.stableNorm();
277  fnorm = fnorm1;
278  ++iter;
279  }
280 
281  /* determine the progress of the iteration. */
282  ++nslow1;
283  if (actred >= Scalar(.001)) nslow1 = 0;
284  if (jeval) ++nslow2;
285  if (actred >= Scalar(.1)) nslow2 = 0;
286 
287  /* test for convergence. */
289 
290  /* tests for termination and stringent tolerances. */
292  if (Scalar(.1) * (std::max)(Scalar(.1) * delta, pnorm) <= NumTraits<Scalar>::epsilon() * xnorm)
296 
297  /* criterion for recalculating jacobian. */
298  if (ncfail == 2) break; // leave inner loop and go for the next outer loop iteration
299 
300  /* calculate the rank one modification to the jacobian */
301  /* and update qtf if necessary. */
302  wa1 = diag.cwiseProduct(diag.cwiseProduct(wa1) / pnorm);
303  wa2 = fjac.transpose() * wa4;
304  if (ratio >= Scalar(1e-4)) qtf = wa2;
305  wa2 = (wa2 - wa3) / pnorm;
306 
307  /* compute the qr factorization of the updated jacobian. */
308  internal::r1updt<Scalar>(R, wa1, v_givens, w_givens, wa2, wa3, &sing);
309  internal::r1mpyq<Scalar>(n, n, fjac.data(), v_givens, w_givens);
310  internal::r1mpyq<Scalar>(1, n, qtf.data(), v_givens, w_givens);
311 
312  jeval = false;
313  }
315 }

References abs(), Eigen::numext::abs2(), MultiOpt::delta, diag, e(), eigen_assert, Eigen::HouseholderQR< MatrixType_ >::householderQ(), j, Eigen::HouseholderQR< MatrixType_ >::matrixQR(), max, min, n, Eigen::HybridNonLinearSolverSpace::NotMakingProgressIterations, Eigen::HybridNonLinearSolverSpace::NotMakingProgressJacobian, R, Eigen::HybridNonLinearSolverSpace::RelativeErrorTooSmall, Eigen::HybridNonLinearSolverSpace::Running, Eigen::HybridNonLinearSolverSpace::TolTooSmall, Eigen::HybridNonLinearSolverSpace::TooManyFunctionEvaluation, Eigen::HouseholderSequence< VectorsType, CoeffsType, Side >::transpose(), Eigen::HybridNonLinearSolverSpace::UserAsked, and plotDoE::x.

Member Data Documentation

◆ actred

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::actred
private

◆ delta

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::delta
private

◆ diag

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::diag

◆ fjac

template<typename FunctorType , typename Scalar = double>
JacobianType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::fjac

◆ fnorm

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::fnorm

◆ fnorm1

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::fnorm1
private

◆ functor

template<typename FunctorType , typename Scalar = double>
FunctorType& Eigen::HybridNonLinearSolver< FunctorType, Scalar >::functor
private

◆ fvec

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::fvec

◆ iter

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::iter

◆ jeval

template<typename FunctorType , typename Scalar = double>
bool Eigen::HybridNonLinearSolver< FunctorType, Scalar >::jeval
private

◆ n

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::n
private

◆ ncfail

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::ncfail
private

◆ ncsuc

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::ncsuc
private

◆ nfev

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::nfev

◆ njev

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::njev

◆ nslow1

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::nslow1
private

◆ nslow2

template<typename FunctorType , typename Scalar = double>
Index Eigen::HybridNonLinearSolver< FunctorType, Scalar >::nslow2
private

◆ parameters

template<typename FunctorType , typename Scalar = double>
Parameters Eigen::HybridNonLinearSolver< FunctorType, Scalar >::parameters

◆ pnorm

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::pnorm
private

◆ prered

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::prered
private

◆ qtf

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::qtf

◆ R

template<typename FunctorType , typename Scalar = double>
UpperTriangularType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::R

◆ ratio

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::ratio
private

◆ sing

template<typename FunctorType , typename Scalar = double>
bool Eigen::HybridNonLinearSolver< FunctorType, Scalar >::sing
private

◆ sum

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::sum
private

◆ temp

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::temp
private

◆ useExternalScaling

template<typename FunctorType , typename Scalar = double>
bool Eigen::HybridNonLinearSolver< FunctorType, Scalar >::useExternalScaling

◆ wa1

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::wa1
private

◆ wa2

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::wa2
private

◆ wa3

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::wa3
private

◆ wa4

template<typename FunctorType , typename Scalar = double>
FVectorType Eigen::HybridNonLinearSolver< FunctorType, Scalar >::wa4
private

◆ xnorm

template<typename FunctorType , typename Scalar = double>
Scalar Eigen::HybridNonLinearSolver< FunctorType, Scalar >::xnorm
private

The documentation for this class was generated from the following file: