Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement different rules for step size in derivatives approximation #28

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

pnevyk
Copy link
Collaborator

@pnevyk pnevyk commented Nov 16, 2023

Step size can heavily influence the solving process based on the derivatives. For that reason, derivative approximations now allow to choose the relative epsilon value and step size computation and experiment with it to achieve the best results for the specific use case.

Step size can heavily influence the solving process based on the
derivatives. For that reason, derivative approximations now allow to
choose the relative epsilon value and step size computation and
experiment with it to achieve the best results for the specific use
case.

Short notes about the implemented rules:

* Fixed -- Using the machine precision without any scaling.
* ValueScaled -- Scaling the machine precision by the current value,
  which avoids small steps for large variables and "big" steps for very
  small variables. This is often recommended on the internet.
* AbsValueScaled -- A variation of the previous, which always uses
  positive value of the step. This "rule" is used in GSL. It is the
  default, because it was one of the rules for which our current test
  for scaled rosenbrock passed, together with Fixed (which I consider
  naive) and other always-positive step size rules (from which this is
  the most standard, more on that below). The real reason why the scaled
  rosenbrock test fails is that, when negative step size is used, it
  results in singular Jacobian in the first iteration, forcing the trust
  region algorithm to use LM step, which doesn't behave well apparently.
* ValueOrMagScaled -- Scaling the machine precision by the absolute
  value of the variable or typical magnitude, whatever is larger, to
  avoid problems when the variable is close to zero. This "rule" is used
  in Numerical Methods for Unconstrained Optimization and Nonlinear
  Equations by Dennis and Schnabel.
* AbsValueOrMagScaled -- A variation of the previous, which always uses
  positive value of the step.
* ValueOrMagTimesValueScaled -- A variation of the next rule, which uses
  the sign of the variable value for the sign of the step size.
* AbsValueOrMagTimesAbsValueScaled -- This is actually the original
  rule used in gomez, implemented by accident by swapping the arguments
  in copysign function (see 4161c56). So it was a bug, but for some
  reason from all these rules it works the best for my use case. I
  assume it relates to using bigger step size (if x > 1) and smaller
  step size (if x < 1). Nevertheless, using max(|x|, mag) * x is
  seems important, because variants like x^2 * sign(x) or similar did
  not work well. Anyway, I consider it non-standard, because it isn't
  based on any literature, but I want to have it in gomez, because it
  works well for me.
@pnevyk pnevyk merged commit 2ee24f0 into main Nov 16, 2023
8 checks passed
@pnevyk pnevyk deleted the finite-diff-step-rule branch November 16, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant