-
Notifications
You must be signed in to change notification settings - Fork 572
optimize/scalar: add Brent's method for univariate minimization #2067
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: master
Are you sure you want to change the base?
optimize/scalar: add Brent's method for univariate minimization #2067
Conversation
kortschak
left a comment
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.
Initial review only.
optimize/scalar/brent_min.go
Outdated
| const c = 0.3819660112501051517954131656343618822796908201942371 | ||
|
|
||
| // Default settings | ||
| tol := math.Sqrt(epsilon) |
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.
This can be a const.
optimize/scalar/brent_min_test.go
Outdated
| settings *Settings | ||
| wantX float64 | ||
| wantStatus Status | ||
| distTol float64 // 許容する x の誤差 (wantX との距離) |
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.
Comments in English please.
Thanks, applied Co-authored-by: Dan Kortschak <[email protected]>
Thanks, applied Co-authored-by: Dan Kortschak <[email protected]>
Update epsilon to use the hexadecimal floating-point literal 0x1p-52. Define the default tolerance (sqrt of epsilon) as a constant 0x1p-26 instead of calculating it at runtime.
- Translate Japanese comments in tests to English. - Use hexadecimal floating-point literals for epsilon. - Clarify documentation for default MaxIterations.
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
- Group constants and state variables (e, d) into blocks. - Simplify numeric expressions and literals (e.g., use /2 instead of *0.5). - Use hexadecimal floating-point literals for epsilon. - Prepare Status type for stringer and remove manual String method.
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
Updated the implementation to align with Gonum coding standards: - Improved constant/variable grouping and numeric expressions. - Integrated stringer for Status type. - Refactored tests by hoisting cases and simplifying identifiers.
Co-authored-by: Dan Kortschak <[email protected]>
Co-authored-by: Dan Kortschak <[email protected]>
This PR addresses issue #483 by introducing a new sub-package
optimize/scalarand implementing Brent's method for finding the local minimum of a univariate function.Summary of Changes
gonum/optimize/scalarpackage.BrentMin, a derivative-free minimization algorithm combining the golden section search and successive parabolic interpolation.fmin.f(by Richard Brent) to ensure numerical stability and correctness.brent_min_test.go.Design Decisions
brent_min.go(instead of justbrent.go) to explicitly distinguish it from Brent's root-finding method (Zeroin). This leaves room to add the root-finding algorithm (discussed in optimize, all: Re-use of the optimize implementation #925) asbrent_root.goin the same package in the future.Settingsstruct for fine-grained control (tolerance, max iterations) and returns aResultstruct with metadata (status, iteration count), following the convention of theoptimizepackage.Reference
fmin: http://www.netlib.org/opt/fmin.fNote for reviewers:
I am a university student studying numerical analysis, and this is my first contribution to Gonum (and OSS in general). I have tried to follow the project's conventions, but I would greatly appreciate any feedback or guidance if there are areas for improvement.