-
Notifications
You must be signed in to change notification settings - Fork 24
Rescaled tolerances #93
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
base: main
Are you sure you want to change the base?
Changes from all commits
d7ac83a
1a81319
f6a8b39
8faac49
cce2e67
97e7bc5
cc1866f
f4bf904
2e54add
fb0608d
3341c1f
a08693f
00467f2
9eba0de
a867a48
aa14ba7
37d35f1
99ce90c
dd06af1
4516d2b
a24aa73
f842fd4
75d441d
07690ae
841d481
b1e9a40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ namespace polysolve::nonlinear | |
| { | ||
| bool is_converged_status(const Status s) | ||
| { | ||
| return s == Status::XDeltaTolerance || s == Status::FDeltaTolerance || s == Status::GradNormTolerance; | ||
| return s == Status::XDeltaTolerance || s == Status::FDeltaTolerance || s == Status::GradNormTolerance || s == Status::NewtonDecrementTolerance || s == Status::RelGradNormTolerance || s == Status::RelXDeltaTolerance; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why newton here? this interface is more generic
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Newton decrement is a generic estimate of how close you are to the optimum and applies for non-Newton methods. |
||
| } | ||
|
|
||
| Criteria::Criteria() | ||
|
|
@@ -26,6 +26,9 @@ namespace polysolve::nonlinear | |
| firstGradNorm = 0; | ||
| fDeltaCount = 0; | ||
| xDeltaDotGrad = 0; | ||
| relGradNorm = 0; | ||
| relXDelta = 0; | ||
| newtonDecrement = 0; | ||
| } | ||
|
|
||
| void Criteria::print(std::ostream &os) const | ||
|
|
@@ -34,12 +37,16 @@ namespace polysolve::nonlinear | |
| } | ||
| std::string Criteria::print_message() const { | ||
| return fmt::format( | ||
| "iters={:d} {}={:g} {}={:g} {}={:g} {}={:g}", | ||
| "iters={:d} {}={:g} {}={:g} {}_rel={:g} {}={:g} {}_rel={:g} {}={:g} {}={:g}", | ||
| iterations, | ||
| log::delta("f"), fDelta, | ||
| log::norm(log::grad("f")), gradNorm, | ||
| log::norm(log::grad("f")), relGradNorm, | ||
| log::norm(log::delta("x")), xDelta, | ||
| log::delta("x") + log::dot() + log::grad("f(x)"), xDeltaDotGrad); | ||
| log::norm(log::delta("x")), relXDelta, | ||
| log::delta("x") + log::dot() + log::grad("f(x)"), xDeltaDotGrad, | ||
| "1/2" + log::delta("x") + "^TH" + log::delta("x"), newtonDecrement | ||
| ); | ||
| } | ||
|
|
||
| Status checkConvergence(const Criteria &stop, const Criteria ¤t) | ||
|
|
@@ -53,6 +60,18 @@ namespace polysolve::nonlinear | |
| { | ||
| return Status::GradNormTolerance; | ||
| } | ||
| if (stop.relXDelta > 0 && current.relXDelta < stop.relXDelta) | ||
| { | ||
| return Status::RelXDeltaTolerance; | ||
| } | ||
| if (stop.relGradNorm > 0 && current.relGradNorm < stop.relGradNorm) | ||
| { | ||
| return Status::RelGradNormTolerance; | ||
| } | ||
| if (stop.newtonDecrement > 0 && current.newtonDecrement < stop.newtonDecrement) | ||
| { | ||
| return Status::NewtonDecrementTolerance; | ||
| } | ||
| if (stop.xDelta > 0 && current.xDelta < stop.xDelta) | ||
| { | ||
| return Status::XDeltaTolerance; | ||
|
|
@@ -84,6 +103,12 @@ namespace polysolve::nonlinear | |
| return "Change in cost function value too small"; | ||
| case Status::GradNormTolerance: | ||
| return "Gradient vector norm too small"; | ||
| case Status::RelGradNormTolerance: | ||
| return "Relative gradient vector too small"; | ||
| case Status::RelXDeltaTolerance: | ||
| return "Relative change in parameter vector too small"; | ||
| case Status::NewtonDecrementTolerance: | ||
| return "Newton decrement too small"; | ||
| case Status::ObjectiveCustomStop: | ||
| return "Objective function specified to stop"; | ||
| case Status::NanEncountered: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use options to enumearte all. in the code is called euclidean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed